From: pcarana Date: Thu, 18 Feb 2021 04:41:33 +0000 (-0600) Subject: Update docs, set 'router-keys' as name for output.bgpsec in json format X-Git-Tag: v1.5.1~31^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=5d571428ca80941bccc9152299e1b9bdb3127d4f;p=thirdparty%2FFORT-validator.git Update docs, set 'router-keys' as name for output.bgpsec in json format --- diff --git a/docs/usage.md b/docs/usage.md index 83ad2c01..852eefb3 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -52,21 +52,22 @@ description: Guide to use arguments of FORT Validator. 40. [`--http.ca-path`](#--httpca-path) 41. [`--output.roa`](#--outputroa) 42. [`--output.bgpsec`](#--outputbgpsec) - 43. [`--asn1-decode-max-stack`](#--asn1-decode-max-stack) - 44. [`--stale-repository-period`](#--stale-repository-period) - 45. [`--configuration-file`](#--configuration-file) - 46. [`--rsync.enabled`](#--rsyncenabled) - 47. [`--rsync.priority`](#--rsyncpriority) - 48. [`--rsync.strategy`](#--rsyncstrategy) + 43. [`--output.format`](#--outputformat) + 44. [`--asn1-decode-max-stack`](#--asn1-decode-max-stack) + 45. [`--stale-repository-period`](#--stale-repository-period) + 46. [`--configuration-file`](#--configuration-file) + 47. [`--rsync.enabled`](#--rsyncenabled) + 48. [`--rsync.priority`](#--rsyncpriority) + 49. [`--rsync.strategy`](#--rsyncstrategy) 1. [`strict`](#strict) 2. [`root`](#root) 3. [`root-except-ta`](#root-except-ta) - 49. [`--rsync.retry.count`](#--rsyncretrycount) - 50. [`--rsync.retry.interval`](#--rsyncretryinterval) - 51. [`rsync.program`](#rsyncprogram) - 52. [`rsync.arguments-recursive`](#rsyncarguments-recursive) - 53. [`rsync.arguments-flat`](#rsyncarguments-flat) - 54. [`incidences`](#incidences) + 50. [`--rsync.retry.count`](#--rsyncretrycount) + 51. [`--rsync.retry.interval`](#--rsyncretryinterval) + 52. [`rsync.program`](#rsyncprogram) + 53. [`rsync.arguments-recursive`](#rsyncarguments-recursive) + 54. [`rsync.arguments-flat`](#rsyncarguments-flat) + 55. [`incidences`](#incidences) 3. [Deprecated arguments](#deprecated-arguments) 1. [`--sync-strategy`](#--sync-strategy) 2. [`--rrdp.enabled`](#--rrdpenabled) @@ -133,6 +134,7 @@ description: Guide to use arguments of FORT Validator. [--http.ca-path=] [--output.roa=] [--output.bgpsec=] + [--output.format=csv|json] ``` If an argument is declared more than once, the last one takes precedence: @@ -688,11 +690,28 @@ Otherwise, Fort will perform HTTP requests when needed (eg. an HTTPS URI at a TA - **Type:** String (Path to file) - **Availability:** `argv` and JSON -File where the ROAs will be stored in CSV format. +File where the ROAs will be stored in the configured format (see [`--output.format`](#--outputformat)). When the file is specified, its content will be removed to store the ROAs; if the file doesn't exists, it will be created. To print at console, use a hyphen `"-"`. If RTR server is enabled, then the ROAs will be printed every [`--server.interval.validation`](#--serverintervalvalidation) secs. -Each line of the result is printed in the following order: _AS, Prefix, Max prefix length_; the first line contains those column descriptors. +When [`--output.format`](#--outputformat)`=csv` (which is the default value), then each line of the result is printed in the following order: _AS, Prefix, Max prefix length_; the first line contains those column descriptors. + +When [`--output.format`](#--outputformat)`=json`, then each element is printed inside an object array of `roas`; ie: + +
{
+	"roas": [
+		{
+			"asn": "AS64496",
+			"prefix": "198.51.100.0/24",
+			"maxLength": 24
+		},
+		{
+			"asn": "AS64496",
+			"prefix": "2001:DB8::/32",
+			"maxLength": 48
+		}
+	]
+}
If a value isn't specified, then the ROAs aren't printed. @@ -701,16 +720,41 @@ If a value isn't specified, then the ROAs aren't printed. - **Type:** String (Path to file) - **Availability:** `argv` and JSON -File where the BGPsec Router Keys will be stored in CSV format. +File where the BGPsec Router Keys will be stored in the configured format (see [`--output.format`](#--outputformat)). Since most of the data is binary (Subject Key Identifier and Subject Public Key Info), such data is base64url encoded without trailing pads. When the file is specified, its content will be removed to store the Router Keys; if the file doesn't exists, it will be created. To print at console, use a hyphen `"-"`. If RTR server is enabled, then the BGPsec Router Keys will be printed every [`--server.interval.validation`](#--serverintervalvalidation) secs. -Each line of the result is printed in the following order: _AS, Subject Key Identifier, Subject Public Key Info_; the first line contains those column descriptors. +When [`--output.format`](#--outputformat)`=csv` (which is the default value), then each line of the result is printed in the following order: _AS, Subject Key Identifier, Subject Public Key Info_; the first line contains those column descriptors. + +When [`--output.format`](#--outputformat)`=json`, then each element is printed inside an object array of `router-keys`; ie: + +
{
+	"router-keys": [
+		{
+			"asn": "AS64496",
+			"ski": "",
+			"spki": ""
+		},
+		{
+			"asn": "AS64497",
+			"ski": "",
+			"spki": ""
+		}
+	]
+}
If a value isn't specified, then the BGPsec Router Keys aren't printed. +### `--output.format` + +- **Type:** Enumeration (`csv`, `json`) +- **Availability:** `argv` and JSON +- **Default:** `csv` + +Output format for [`--output.roa`](#--outputroa) and [`--output.bgpsec`](#--outputbgpsec). + ### `--asn1-decode-max-stack` - **Type:** Integer @@ -862,7 +906,8 @@ The configuration options are mostly the same as the ones from the `argv` interf "output": { "roa": "/tmp/fort/roas.csv", - "bgpsec": "/tmp/fort/bgpsec.csv" + "bgpsec": "/tmp/fort/bgpsec.csv", + "format": "csv" }, "asn1-decode-max-stack": 4096, diff --git a/examples/config.json b/examples/config.json index 71d9fdb2..a3276bbe 100644 --- a/examples/config.json +++ b/examples/config.json @@ -102,7 +102,8 @@ ], "output": { "roa": "/tmp/fort/roas.csv", - "bgpsec": "/tmp/fort/bgpsec.csv" + "bgpsec": "/tmp/fort/bgpsec.csv", + "format": "csv" }, "asn1-decode-max-stack": 4096, "stale-repository-period": 43200 diff --git a/man/fort.8 b/man/fort.8 index 3a4f51a0..b7841bd8 100644 --- a/man/fort.8 +++ b/man/fort.8 @@ -998,36 +998,92 @@ By default, the value is \fI5\fR. .B \-\-output.roa=\fIFILE\fR .RS 4 -File where the ROAs will be printed in CSV format. +File where the ROAs will be printed in the configured format (see +\fI--output.format\fR). .P When the \fIFILE\fR is specified, its content will be overwritten by the resulting ROAs of the validation (if FILE doesn't exists, it'll be created). .P -Each line of the result is printed in the following order: AS, Prefix, Max -prefix length; the first line contains those column descriptors. +When \fI--output.format=csv\fR (which is the default value), then each line of +the result is printed in the following order: AS, Prefix, Max prefix length; the +first line contains those column descriptors. +.P +When \fI--output.format=json\fR, then each element is printed inside an object +array of "roas"; ie: +.nf +{ + "roas": [ + { + "asn": "AS64496", + "prefix": "198.51.100.0/24", + "maxLength": 24 + }, + { + "asn": "AS64496", + "prefix": "2001:DB8::/32", + "maxLength": 48 + } + ] +} +.fi .P In order to print the ROAs at console, use a hyphen as the \fIFILE\fR value, eg. .B \-\-output.roa=- +.P +By default, it has no value set. .RE +.P .B \-\-output.bgpsec=\fIFILE\fR .RS 4 -File where the BGPsec Router Keys will be printed in CSV format. Since most of -the data is binary (Subject Key Identifier and Subject Public Key Info), such -data is base64url encoded without trailing pads. +File where the BGPsec Router Keys will be printed in the configured format (see +\fI--output.format\fR). +.P +Since most of the data is binary (Subject Key Identifier and Subject Public Key +Info), such data is base64url encoded without trailing pads. .P When the \fIFILE\fR is specified, its content will be overwritten by the resulting Router Keys of the validation (if FILE doesn't exists, it'll be created). .P -Each line of the result is printed in the following order: AS, Subject Key -Identifier, Subject Public Key Info; the first line contains those column -descriptors. +When \fI--output.format=csv\fR (which is the default value), then each line of +the result is printed in the following order: AS, Subject Key Identifier, +Subject Public Key Info; the first line contains those column descriptors. +.P +When \fI--output.format=json\fR, then each element is printed inside an object +array of "router-keys"; ie: +.nf +{ + "router-keys": [ + { + "asn": "AS64496", + "ski": "", + "spki": "" + }, + { + "asn": "AS64496", + "ski": "", + "spki": "" + } + ] +} +.fi .P In order to print the Router Keys at console, use a hyphen as the \fIFILE\fR value, eg. .B \-\-output.bgpsec=- +.P +By default, it has no value set. .RE +.P + +.B \-\-output.format=\fIcsv\fR|\fIjson\fR +.RS 4 +Output format for \fI--output.roa\fR and \fI--output.bgpsec\fR. +.P +By default, it has a value of \fIcsv\fR. +.RE +.P .B \-\-asn1-decode-max-stack=\fIUNSIGNED_INTEGER\fR .RS 4 @@ -1221,7 +1277,8 @@ to a specific value: ], "output": { "roa": "/tmp/fort/roas.csv", - "bgpsec": "/tmp/fort/bgpsec.csv" + "bgpsec": "/tmp/fort/bgpsec.csv", + "format": "csv" }, "asn1-decode-max-stack": 4096, "stale-repository-period": 43200 diff --git a/src/output_printer.c b/src/output_printer.c index 7c35de55..fcce9857 100644 --- a/src/output_printer.c +++ b/src/output_printer.c @@ -229,7 +229,7 @@ print_router_keys(struct db_table *db) json_out.file = out; json_out.first = true; - fprintf(out, "{ \"router_keys\" : ["); + fprintf(out, "{ \"router-keys\" : ["); error = db_table_foreach_router_key(db, print_router_key_json, &json_out); fprintf(out, "\n]}\n");