aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/apnic-to-csv.py11
-rw-r--r--scripts/arin-to-csv.py12
-rw-r--r--scripts/csvgrep.py16
-rw-r--r--scripts/generate-ripe-root-cert.py24
-rw-r--r--scripts/ripe-asns-to-csv.py7
-rw-r--r--scripts/ripe-to-csv.py9
-rw-r--r--scripts/test-myrpki-cms.py66
-rw-r--r--scripts/testbed-rootcert.py9
-rw-r--r--scripts/translate-handles.py12
9 files changed, 55 insertions, 111 deletions
diff --git a/scripts/apnic-to-csv.py b/scripts/apnic-to-csv.py
index 7413819e..f7b0d0a1 100644
--- a/scripts/apnic-to-csv.py
+++ b/scripts/apnic-to-csv.py
@@ -4,7 +4,7 @@ out (just) the RPKI-relevant fields in myrpki-format CSV syntax.
$Id$
-Copyright (C) 2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2010-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -19,10 +19,11 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import rpki.myrpki, rpki.ipaddrs
+from rpki.csv_utils import csv_writer
+from rpki.ipaddrs import v4addr
-asns = rpki.myrpki.csv_writer("asns.csv")
-prefixes = rpki.myrpki.csv_writer("prefixes.csv")
+asns = csv_writer("asns.csv")
+prefixes = csv_writer("prefixes.csv")
for line in open("delegated-apnic-extended-latest"):
@@ -45,7 +46,7 @@ for line in open("delegated-apnic-extended-latest"):
asns.writerow((opaque_id, "%s-%s" % (start, int(start) + int(value) - 1)))
elif rectype == "ipv4":
- prefixes.writerow((opaque_id, "%s-%s" % (start, rpki.ipaddrs.v4addr(rpki.ipaddrs.v4addr(start) + long(value) - 1))))
+ prefixes.writerow((opaque_id, "%s-%s" % (start, v4addr(v4addr(start) + long(value) - 1))))
elif rectype == "ipv6":
prefixes.writerow((opaque_id, "%s/%s" % (start, value)))
diff --git a/scripts/arin-to-csv.py b/scripts/arin-to-csv.py
index fc770983..63368723 100644
--- a/scripts/arin-to-csv.py
+++ b/scripts/arin-to-csv.py
@@ -13,7 +13,7 @@ see: http://www.ibm.com/developerworks/xml/library/x-hiperfparse/
$Id$
-Copyright (C) 2009-2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -28,7 +28,9 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import sys, lxml.etree, rpki.myrpki
+import sys, lxml.etree
+
+from rpki.csv_utils import csv_writer
def ns(tag):
return "{http://www.arin.net/bulkwhois/core/v1}" + tag
@@ -84,9 +86,9 @@ def do_net(node):
dispatch = { tag_asn : do_asn, tag_net : do_net }
-asns = rpki.myrpki.csv_writer("asns.csv")
-prefixes = rpki.myrpki.csv_writer("prefixes.csv")
-erx = rpki.myrpki.csv_writer("erx.csv")
+asns = csv_writer("asns.csv")
+prefixes = csv_writer("prefixes.csv")
+erx = csv_writer("erx.csv")
root = None
diff --git a/scripts/csvgrep.py b/scripts/csvgrep.py
index 8a680a99..66fd4c4f 100644
--- a/scripts/csvgrep.py
+++ b/scripts/csvgrep.py
@@ -13,7 +13,7 @@ any ASNs given, and prefixes.csv for any prefixes given.
$Id$
-Copyright (C) 2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2010-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -28,11 +28,13 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import sys, rpki.resource_set, rpki.myrpki
+import sys
+from rpki.resource_set import resource_set_as, resource_set_ipv4, resource_set_ipv6
+from rpki.csv_utils import csv_reader
-asn = rpki.resource_set.resource_set_as()
-ipv4 = rpki.resource_set.resource_set_ipv4()
-ipv6 = rpki.resource_set.resource_set_ipv6()
+asn = resource_set_as()
+ipv4 = resource_set_ipv4()
+ipv6 = resource_set_ipv6()
for datum in sys.argv[1:]:
if datum.replace("-", "").isdigit():
@@ -57,13 +59,13 @@ def matches(set1, datum):
return False
if asn:
- for h, a in rpki.myrpki.csv_reader("asns.csv", columns = 2):
+ for h, a in csv_reader("asns.csv", columns = 2):
m = matches(asn, a)
if m:
print h, m
if ipv4 or ipv6:
- for h, a in rpki.myrpki.csv_reader("prefixes.csv", columns = 2):
+ for h, a in csv_reader("prefixes.csv", columns = 2):
t = ipv6 if ":" in a else ipv4
m = t and matches(t, a)
if m:
diff --git a/scripts/generate-ripe-root-cert.py b/scripts/generate-ripe-root-cert.py
index 19b6dcf8..3d88c396 100644
--- a/scripts/generate-ripe-root-cert.py
+++ b/scripts/generate-ripe-root-cert.py
@@ -4,7 +4,7 @@ cert for Pseudo-RIPE.
$Id$
-Copyright (C) 2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2010-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -19,37 +19,37 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import sys, lxml.etree, rpki.myrpki
+import sys
+import lxml.etree
+from rpki.csv_utils import csv_writer
+
+def iterate_xml(filename, tag):
+ return lxml.etree.parse(filename).getroot().getiterator(tag)
def ns(tag):
return "{http://www.iana.org/assignments}" + tag
-tag_registry = ns("registry")
tag_description = ns("description")
tag_designation = ns("designation")
tag_record = ns("record")
tag_number = ns("number")
tag_prefix = ns("prefix")
-asn_xml = lxml.etree.parse("as-numbers.xml").getroot()
-ipv4_xml = lxml.etree.parse("ipv4-address-space.xml").getroot()
-ipv6_xml = lxml.etree.parse("ipv6-unicast-address-assignments.xml").getroot()
-
-asns = rpki.myrpki.csv_writer("asns.csv")
-prefixes = rpki.myrpki.csv_writer("prefixes.csv")
+asns = csv_writer("asns.csv")
+prefixes = csv_writer("prefixes.csv")
-for record in asn_xml.getiterator(tag_record):
+for record in iterate_xml("as-numbers.xml", tag_record):
if record.findtext(tag_description) == "Assigned by RIPE NCC":
asns.writerow(("RIPE", record.findtext(tag_number)))
-for record in ipv4_xml.getiterator(tag_record):
+for record in iterate_xml("ipv4-address-space.xml", tag_record):
if record.findtext(tag_designation) in ("RIPE NCC", "Administered by RIPE NCC"):
prefix = record.findtext(tag_prefix)
p, l = prefix.split("/")
assert l == "8", "Violated /8 assumption: %r" % prefix
prefixes.writerow(("RIPE", "%d.0.0.0/8" % int(p)))
-for record in ipv6_xml.getiterator(tag_record):
+for record in iterate_xml("ipv6-unicast-address-assignments.xml", tag_record):
if record.findtext(tag_description) == "RIPE NCC":
prefixes.writerow(("RIPE", record.findtext(tag_prefix)))
diff --git a/scripts/ripe-asns-to-csv.py b/scripts/ripe-asns-to-csv.py
index 122ed1fe..78e6f11d 100644
--- a/scripts/ripe-asns-to-csv.py
+++ b/scripts/ripe-asns-to-csv.py
@@ -8,7 +8,7 @@ the terms and conditions referenced by the data file header comments.
$Id$
-Copyright (C) 2009 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -23,7 +23,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import gzip, rpki.myrpki
+import gzip
+from rpki.csv_utils import csv_writer
class Handle(dict):
@@ -88,7 +89,7 @@ class main(object):
filenames = ("ripe.db.aut-num.gz",)
def __init__(self):
- self.asns = rpki.myrpki.csv_writer("asns.csv")
+ self.asns = csv_writer("asns.csv")
for fn in self.filenames:
f = gzip.open(fn)
self.statement = ""
diff --git a/scripts/ripe-to-csv.py b/scripts/ripe-to-csv.py
index a9077640..ff069732 100644
--- a/scripts/ripe-to-csv.py
+++ b/scripts/ripe-to-csv.py
@@ -21,7 +21,7 @@ the terms and conditions referenced by the data file header comments.
$Id$
-Copyright (C) 2009-2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -36,7 +36,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import gzip, csv, rpki.myrpki
+import gzip
+from rpki.csv_utils import csv_writer
class Handle(dict):
@@ -116,8 +117,8 @@ class main(object):
filenames = ("ripe.db.aut-num.gz", "ripe.db.inet6num.gz", "ripe.db.inetnum.gz")
def __init__(self):
- self.asns = rpki.myrpki.csv_writer("asns.csv")
- self.prefixes = rpki.myrpki.csv_writer("prefixes.csv")
+ self.asns = csv_writer("asns.csv")
+ self.prefixes = csv_writer("prefixes.csv")
for fn in self.filenames:
f = gzip.open(fn)
self.statement = ""
diff --git a/scripts/test-myrpki-cms.py b/scripts/test-myrpki-cms.py
deleted file mode 100644
index f2947f5c..00000000
--- a/scripts/test-myrpki-cms.py
+++ /dev/null
@@ -1,66 +0,0 @@
-"""
-Scratch pad for working out what CMS referral code looks like.
-
-This is only in subversion for archival and backup, I don't expect
-users to run this, and will delete it in the near future.
-
-
-$Id$
-
-Copyright (C) 2010 Internet Systems Consortium ("ISC")
-
-Permission to use, copy, modify, and distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-"""
-
-import subprocess, os, sys, rpki.myrpki
-
-original_xml = '''\
-<publication_referral xmlns="http://www.hactrn.net/uris/rpki/publication-spec/"
- sia_base=rsync://repository.example/path/to/me/space-i-give-to-my-child">
- Base64 encoded BPKI TA of resource holding aspect of my child xxx blah blah blah blah xxx
-</publication_referral>
-'''
-
-f = open("original.xml", "w")
-f.write(original_xml)
-f.close()
-
-rpki.myrpki.openssl = "/u/sra/rpki/subvert-rpki.hactrn.net/openssl/openssl/apps/openssl"
-os.putenv("OPENSSL_CONF", "/dev/null")
-
-bpki = rpki.myrpki.CA("test/Alice/rpki.conf", "test/Alice/bpki/resources")
-bpki.ee("/CN=Alice Signed Referral CMS Test EE Certificate", "CMSEE")
-
-# "id-ct-xml" from rpki.oids
-oid = ".".join(map(str, (1, 2, 840, 113549, 1, 9, 16, 1, 28)))
-
-format = "DER" # PEM or DER
-
-subprocess.check_call((rpki.myrpki.openssl, "cms", "-sign",
- "-binary", "-nodetach", "-nosmimecap", "-keyid", "-outform", format,
- "-econtent_type", oid, "-md", "sha256",
- "-inkey", "test/Alice/bpki/resources/CMSEE.key",
- "-signer", "test/Alice/bpki/resources/CMSEE.cer",
- "-in", "original.xml",
- "-out", "original.%s" % format.lower()))
-
-if format == "DER":
- subprocess.call(("dumpasn1", "-a", "original.cms"))
-
-# verifying may not be necessary here, that might be pubd's job. or
-# at least we can make it the job of the code formerly known as irdbd,
-# where we have full libraries available to us. but blunder ahead...
-
-subprocess.check_call((rpki.myrpki.openssl, "cms", "-verify", "-inform", format,
- "-CAfile", "test/Alice/bpki/resources/ca.cer",
- "-in", "original.%s" % format.lower()))
diff --git a/scripts/testbed-rootcert.py b/scripts/testbed-rootcert.py
index 2227f110..43885355 100644
--- a/scripts/testbed-rootcert.py
+++ b/scripts/testbed-rootcert.py
@@ -7,7 +7,7 @@ the fly rather than having to pull the entire database into memory.
$Id$
-Copyright (C) 2009-2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2009-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -22,7 +22,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import csv, rpki.myrpki, sys
+import sys
+from rpki.csv_utils import csv_reader
if len(sys.argv) not in (2, 4):
sys.exit("Usage: %s holder [asns.csv prefixes.csv]" % sys.argv[0])
@@ -51,7 +52,7 @@ sbgp-ipAddrBlock = critical,@rfc3997_addrs
''' % { "holder" : sys.argv[1].lower(),
"HOLDER" : sys.argv[1].upper() }
-for i, asn in enumerate(asn for handle, asn in rpki.myrpki.csv_reader(sys.argv[2] if len(sys.argv) > 2 else "asns.csv", columns = 2)):
+for i, asn in enumerate(asn for handle, asn in csv_reader(sys.argv[2] if len(sys.argv) > 2 else "asns.csv", columns = 2)):
print "AS.%d = %s" % (i, asn)
print '''\
@@ -60,6 +61,6 @@ print '''\
'''
-for i, prefix in enumerate(prefix for handle, prefix in rpki.myrpki.csv_reader(sys.argv[3] if len(sys.argv) > 2 else "prefixes.csv", columns = 2)):
+for i, prefix in enumerate(prefix for handle, prefix in csv_reader(sys.argv[3] if len(sys.argv) > 2 else "prefixes.csv", columns = 2)):
v = 6 if ":" in prefix else 4
print "IPv%d.%d = %s" % (v, i, prefix)
diff --git a/scripts/translate-handles.py b/scripts/translate-handles.py
index 68695e38..cdff4b77 100644
--- a/scripts/translate-handles.py
+++ b/scripts/translate-handles.py
@@ -16,7 +16,7 @@ rewrites them as needed after performing the translation.
$Id$
-Copyright (C) 2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2010-2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -31,15 +31,17 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, sys, rpki.myrpki
+import os
+import sys
+from rpki.csv_utils import csv_reader, csv_writer
-translations = dict((src, dst) for src, dst in rpki.myrpki.csv_reader("translations.csv", columns = 2))
+translations = dict((src, dst) for src, dst in csv_reader("translations.csv", columns = 2))
for filename in sys.argv[1:]:
- f = rpki.myrpki.csv_writer(filename)
+ f = csv_writer(filename)
- for cols in rpki.myrpki.csv_reader(filename):
+ for cols in csv_reader(filename):
if cols[0] in translations:
cols[0] = translations[cols[0]]
f.writerow(cols)