aboutsummaryrefslogtreecommitdiff
path: root/rp/utils
diff options
context:
space:
mode:
Diffstat (limited to 'rp/utils')
-rwxr-xr-xrp/utils/find_roa19
-rwxr-xr-xrp/utils/hashdir12
-rwxr-xr-xrp/utils/print_roa14
-rwxr-xr-xrp/utils/print_rpki_manifest10
-rwxr-xr-xrp/utils/scan_roas10
-rwxr-xr-xrp/utils/scan_routercerts9
-rwxr-xr-xrp/utils/uri10
7 files changed, 44 insertions, 40 deletions
diff --git a/rp/utils/find_roa b/rp/utils/find_roa
index 8b962d9c..9a387c6a 100755
--- a/rp/utils/find_roa
+++ b/rp/utils/find_roa
@@ -25,6 +25,7 @@ import os
import argparse
import rpki.POW
import rpki.oids
+import rpki.config
def check_dir(s):
@@ -135,15 +136,15 @@ class ROA(rpki.POW.ROA): # pylint: disable=W0232
print
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("-a", "--all", action = "store_true", help = "show all ROAs, do no prefix matching at all")
-parser.add_argument("-m", "--match-maxlength", action = "store_true", help = "pay attention to maxLength values")
-parser.add_argument("-e", "--show-expiration", action = "store_true", help = "show ROA chain expiration dates")
-parser.add_argument("-f", "--show-filenames", action = "store_true", help = "show filenames instead of URIs")
-parser.add_argument("-i", "--show-inception", action = "store_true", help = "show inception dates")
-parser.add_argument("rcynic_dir", type = check_dir, help = "rcynic authenticated output directory")
-parser.add_argument("prefixes", type = Prefix, nargs = "*", help = "ROA prefix(es) to match")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("-a", "--all", action = "store_true", help = "show all ROAs, do no prefix matching at all")
+cfg.argparser.add_argument("-m", "--match-maxlength", action = "store_true", help = "pay attention to maxLength values")
+cfg.argparser.add_argument("-e", "--show-expiration", action = "store_true", help = "show ROA chain expiration dates")
+cfg.argparser.add_argument("-f", "--show-filenames", action = "store_true", help = "show filenames instead of URIs")
+cfg.argparser.add_argument("-i", "--show-inception", action = "store_true", help = "show inception dates")
+cfg.argparser.add_argument("rcynic_dir", type = check_dir, help = "rcynic authenticated output directory")
+cfg.argparser.add_argument("prefixes", type = Prefix, nargs = "*", help = "ROA prefix(es) to match")
+args = cfg.argparser.parse_args()
# If there's some way to automate this in the parser, I don't know what it is, so just catch it here.
if args.all != (not args.prefixes):
diff --git a/rp/utils/hashdir b/rp/utils/hashdir
index 21619ce4..c2c100b8 100755
--- a/rp/utils/hashdir
+++ b/rp/utils/hashdir
@@ -26,7 +26,7 @@ distributed as part of the repository system.
import os
import sys
-import argparse
+import rpki.config
from rpki.rcynicdb.iterator import authenticated_objects
@@ -36,11 +36,11 @@ def check_dir(s):
else:
raise argparse.ArgumentTypeError("{!r} is not a directory".format(s))
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("-v", "--verbose", action = "store_true", help = "whistle while you work")
-parser.add_argument("rcynic_dir", nargs = "?", type = check_dir, help = "rcynic authenticated output directory")
-parser.add_argument("output_dir", help = "name of output directory to create")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("-v", "--verbose", action = "store_true", help = "whistle while you work")
+cfg.argparser.add_argument("rcynic_dir", nargs = "?", type = check_dir, help = "rcynic authenticated output directory")
+cfg.argparser.add_argument("output_dir", help = "name of output directory to create")
+args = cfg.argparser.parse_args()
if not os.path.isdir(args.output_dir):
os.makedirs(args.output_dir)
diff --git a/rp/utils/print_roa b/rp/utils/print_roa
index dd13447d..c5b7793a 100755
--- a/rp/utils/print_roa
+++ b/rp/utils/print_roa
@@ -21,7 +21,7 @@ Pretty-print the content of a ROA. Does NOT attempt to verify the
signature.
"""
-import argparse
+import rpki.config
import rpki.POW
class ROA(rpki.POW.ROA): # pylint: disable=W0232
@@ -42,12 +42,12 @@ class ROA(rpki.POW.ROA): # pylint: disable=W0232
self.v4_prefixes = [self._format_prefix(p) for p in (v4 or ())]
self.v6_prefixes = [self._format_prefix(p) for p in (v6 or ())]
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("-b", "--brief", action = "store_true", help = "show only ASN and prefix(es)")
-parser.add_argument("-c", "--cms", action = "store_true", help = "print text representation of entire CMS blob")
-parser.add_argument("-s", "--signing-time", action = "store_true", help = "show SigningTime in brief mode")
-parser.add_argument("roas", nargs = "+", type = ROA.derReadFile, help = "ROA(s) to print") # pylint: disable=E1101
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("--brief", action = "store_true", help = "show only ASN and prefix(es)")
+cfg.argparser.add_argument("--cms", action = "store_true", help = "print text representation of entire CMS blob")
+cfg.argparser.add_argument("--signing-time", action = "store_true", help = "show SigningTime in brief mode")
+cfg.argparser.add_argument("roas", nargs = "+", type = ROA.derReadFile, help = "ROA(s) to print") # pylint: disable=E1101
+args = cfg.argparser.parse_args()
for roa in args.roas:
roa.parse()
diff --git a/rp/utils/print_rpki_manifest b/rp/utils/print_rpki_manifest
index 83e5c16e..74a3fbd4 100755
--- a/rp/utils/print_rpki_manifest
+++ b/rp/utils/print_rpki_manifest
@@ -21,14 +21,14 @@ Pretty-print the content of a manifest. Does NOT attempt to verify the
signature.
"""
-import argparse
+import rpki.config
import rpki.POW
import rpki.oids
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("-c", "--cms", action = "store_true", help = "print text representation of entire CMS blob")
-parser.add_argument("manifests", nargs = "+", type = rpki.POW.Manifest.derReadFile, help = "manifest(s) to print")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("--cms", action = "store_true", help = "print text representation of entire CMS blob")
+cfg.argparser.add_argument("manifests", nargs = "+", type = rpki.POW.Manifest.derReadFile, help = "manifest(s) to print")
+args = cfg.argparser.parse_args()
for mft in args.manifests:
mft.extractWithoutVerifying()
diff --git a/rp/utils/scan_roas b/rp/utils/scan_roas
index 740d6628..510fd7a0 100755
--- a/rp/utils/scan_roas
+++ b/rp/utils/scan_roas
@@ -24,6 +24,8 @@ per line.
import os
import argparse
+
+import rpki.config
import rpki.POW
from rpki.rcynicdb.iterator import authenticated_objects
@@ -48,10 +50,10 @@ class ROA(rpki.POW.ROA): # pylint: disable=W0232
# pylint: disable=E1101
return "%s %s %s" % (self.signingTime(), self.getASID(), " ".join(self.prefixes))
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("rcynic_dir", nargs = "?", type = check_dir,
- help = "rcynic authenticated output directory")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("rcynic_dir", nargs = "?", type = check_dir,
+ help = "rcynic authenticated output directory")
+args = cfg.argparser.parse_args()
for uri, roa in authenticated_objects(args.rcynic_dir,
uri_suffix = ".roa",
diff --git a/rp/utils/scan_routercerts b/rp/utils/scan_routercerts
index 74cd2b69..540a8e25 100755
--- a/rp/utils/scan_routercerts
+++ b/rp/utils/scan_routercerts
@@ -26,6 +26,7 @@ import base64
import argparse
import rpki.POW
import rpki.oids
+import rpki.config
from rpki.rcynicdb.iterator import authenticated_objects
@@ -34,10 +35,10 @@ def check_dir(s):
raise argparse.ArgumentTypeError("{!r} is not a directory".format(s))
return s
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("rcynic_dir", nargs = "?", type = check_dir,
- help = "rcynic authenticated output directory")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("rcynic_dir", nargs = "?", type = check_dir,
+ help = "rcynic authenticated output directory")
+args = cfg.argparser.parse_args()
for uri, cer in authenticated_objects(args.rcynic_dir, uri_suffix = ".cer"):
diff --git a/rp/utils/uri b/rp/utils/uri
index cff3419a..d3d9eebb 100755
--- a/rp/utils/uri
+++ b/rp/utils/uri
@@ -24,7 +24,7 @@ Input files must be in DER format and may be either X.509v3 certificates
or CMS objects which contain X.509v3 certificates in the CMS wrapper.
"""
-import argparse
+import rpki.config
import rpki.POW
class Certificate(object):
@@ -71,10 +71,10 @@ class Certificate(object):
words.extend(" %s: %s" % (tag, uri) for tag, uri in self.uris if uri is not None)
return ("" if args.single_line else "\n").join(words)
-parser = argparse.ArgumentParser(description = __doc__)
-parser.add_argument("-s", "--single-line", action = "store_true", help = "single output line per object")
-parser.add_argument("certs", nargs = "+", type = Certificate, help = "RPKI objects to examine")
-args = parser.parse_args()
+cfg = rpki.config.argparser(doc = __doc__)
+cfg.argparser.add_argument("-s", "--single-line", action = "store_true", help = "single output line per object")
+cfg.argparser.add_argument("certs", nargs = "+", type = Certificate, help = "RPKI objects to examine")
+args = cfg.argparser.parse_args()
for cert in args.certs:
print cert