]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Update docs, set 'router-keys' as name for output.bgpsec in json format
authorpcarana <pc.moreno2099@gmail.com>
Thu, 18 Feb 2021 04:41:33 +0000 (22:41 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Thu, 18 Feb 2021 04:41:33 +0000 (22:41 -0600)
docs/usage.md
examples/config.json
man/fort.8
src/output_printer.c

index 83ad2c014bc4094e7a9766e1cf84c6c6e1c7e8a7..852eefb33399b962222e37ed02d559225ec3d178 100644 (file)
@@ -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=<directory>]
         [--output.roa=<file>]
         [--output.bgpsec=<file>]
+        [--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:
+
+<pre><code>{
+       "roas": [
+               {
+                       "asn": "AS64496",
+                       "prefix": "198.51.100.0/24",
+                       "maxLength": 24
+               },
+               {
+                       "asn": "AS64496",
+                       "prefix": "2001:DB8::/32",
+                       "maxLength": 48
+               }
+       ]
+}</code></pre>
 
 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:
+
+<pre><code>{
+       "router-keys": [
+               {
+                       "asn": "AS64496",
+                       "ski": "<Base64 Encoded SKI>",
+                       "spki": "<Base64 Encoded SPKI>"
+               },
+               {
+                       "asn": "AS64497",
+                       "ski": "<Base64 Encoded SKI>",
+                       "spki": "<Base64 Encoded SPKI>"
+               }
+       ]
+}</code></pre>
 
 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": {
                "<a href="#--outputroa">roa</a>": "/tmp/fort/roas.csv",
-               "<a href="#--outputbgpsec">bgpsec</a>": "/tmp/fort/bgpsec.csv"
+               "<a href="#--outputbgpsec">bgpsec</a>": "/tmp/fort/bgpsec.csv",
+               "<a href="#--outputformat">format</a>": "csv"
        },
 
        "<a href="#--asn1-decode-max-stack">asn1-decode-max-stack</a>": 4096,
index 71d9fdb2b7fc8ecb68816f1f41976907b791c497..a3276bbe26f01252d6786c88851b15e739299049 100644 (file)
   ],
   "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
index 3a4f51a095ccc1537c629f1e64d8bf7501a9f70b..b7841bd8e0c4372e7bf19532f95e0aef747cd587 100644 (file)
@@ -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": "<Base64 Encoded SKI>",
+      "spki": "<Base64 Encoded SPKI>"
+    },
+    {
+      "asn": "AS64496",
+      "ski": "<Base64 Encoded SKI>",
+      "spki": "<Base64 Encoded 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
index 7c35de55d5183e41ae3b0666cc83b70248487c12..fcce985723bfc2d0ec54951b6e6baad8b1dfdeba 100644 (file)
@@ -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");