aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpkid/Makefile9
-rw-r--r--rpkid/irbe-setup.py4
-rwxr-xr-xrpkid/irbe_cli.py4
-rwxr-xr-xrpkid/irdbd.py7
-rw-r--r--rpkid/make-relaxng.py20
-rwxr-xr-xrpkid/pubd.py2
-rw-r--r--rpkid/resource-cert-samples.py2
-rwxr-xr-xrpkid/rootd.py2
-rw-r--r--rpkid/rpki/exceptions.py9
-rw-r--r--rpkid/rpki/https.py2
-rw-r--r--rpkid/rpki/left_right.py2
-rw-r--r--rpkid/rpki/publication.py15
-rw-r--r--rpkid/rpki/relaxng.py1
-rw-r--r--rpkid/rpki/rpki_engine.py3
-rw-r--r--rpkid/rpki/sql.py2
-rw-r--r--rpkid/rpki/up_down.py7
-rwxr-xr-xrpkid/rpkid.py2
-rw-r--r--rpkid/testbed.py2
-rw-r--r--rpkid/testpoke.py2
-rwxr-xr-xrpkid/xml-parse-test.py2
20 files changed, 62 insertions, 37 deletions
diff --git a/rpkid/Makefile b/rpkid/Makefile
index 3bdb46c4..981085c7 100644
--- a/rpkid/Makefile
+++ b/rpkid/Makefile
@@ -134,3 +134,12 @@ dox doxygen: irbe_cli.usage doc/irdbd.dot doc/pubd.dot doc/rpkid.dot
cd doc; tar -cf - html | gzip -9 >manual.tar.gz
doc:: dox
+
+# Preliminary experiment with pylint. Its default coding style
+# differs enough from mine that it's not really usable without
+# customization. In the long run this should be use a pylint config
+# file rather than attempting to do it inline here. Useful options
+# which lead to the others: --help, --rcfile, --generate-rcfile.
+
+lint:
+ find * -name .svn -prune -o -type f -name '*.py' -print0 | xargs -0 pylint --output-format parseable --indent-string ' '
diff --git a/rpkid/irbe-setup.py b/rpkid/irbe-setup.py
index 45da98bb..15b0d346 100644
--- a/rpkid/irbe-setup.py
+++ b/rpkid/irbe-setup.py
@@ -19,7 +19,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, MySQLdb, getopt, sys, lxml.etree
+import os, MySQLdb
import rpki.left_right, rpki.relaxng, rpki.https
import rpki.x509, rpki.config, rpki.log
@@ -45,7 +45,7 @@ def call_rpkid(pdu):
msg = rpki.left_right.msg((pdu,))
msg.type = "query"
- cms = rpki.x509.left_right_pdu.wrap(msg, irbe_key, irbe_cert)
+ cms = rpki.left_right.cms_msg.wrap(msg, irbe_key, irbe_cert)
der = rpki.https.client(client_key = irbe_key,
client_cert = irbe_cert,
server_ta = (bpki_ta, rpkid_cert),
diff --git a/rpkid/irbe_cli.py b/rpkid/irbe_cli.py
index dda476c5..8c2b3d81 100755
--- a/rpkid/irbe_cli.py
+++ b/rpkid/irbe_cli.py
@@ -150,11 +150,11 @@ class route_origin_elt(cmd_elt_mixin, rpki.left_right.route_origin_elt):
def client_query_ipv4(self, arg):
"""Handle IPv4 addresses."""
- self.ipv4 = resource_set.roa_prefix_set_ipv4(arg)
+ self.ipv4 = rpki.resource_set.roa_prefix_set_ipv4(arg)
def client_query_ipv6(self, arg):
"""Handle IPv6 addresses."""
- self.ipv6 = resource_set.roa_prefix_set_ipv6(arg)
+ self.ipv6 = rpki.resource_set.roa_prefix_set_ipv6(arg)
class left_right_msg(cmd_msg_mixin, rpki.left_right.msg):
pdus = dict((x.element_name, x)
diff --git a/rpkid/irdbd.py b/rpkid/irdbd.py
index 8d7c7c2b..46669049 100755
--- a/rpkid/irdbd.py
+++ b/rpkid/irdbd.py
@@ -22,8 +22,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import sys, os, time, getopt, urlparse, traceback
-import tlslite.api, MySQLdb, lxml.etree
+import sys, os, time, getopt, urlparse, traceback, MySQLdb
import rpki.https, rpki.config, rpki.resource_set, rpki.relaxng
import rpki.exceptions, rpki.left_right, rpki.log, rpki.x509
@@ -72,7 +71,7 @@ def handler(query, path, cb):
r_msg.append(r_pdu)
- return 200, rpki.left_right.cms_msg.wrap(r_msg, irdbd_key, irdbd_cert)
+ cb(200, rpki.left_right.cms_msg.wrap(r_msg, irdbd_key, irdbd_cert))
except Exception, data:
rpki.log.error(traceback.format_exc())
@@ -80,7 +79,7 @@ def handler(query, path, cb):
# We only get here in cases where we couldn't or wouldn't generate
# <report_error/>, so just return HTTP failure.
- return 500, "Unhandled exception %s: %s" % (data.__class__.__name__, data)
+ cb(500, "Unhandled exception %s: %s" % (data.__class__.__name__, data))
os.environ["TZ"] = "UTC"
time.tzset()
diff --git a/rpkid/make-relaxng.py b/rpkid/make-relaxng.py
index dc7c0e90..287e297b 100644
--- a/rpkid/make-relaxng.py
+++ b/rpkid/make-relaxng.py
@@ -18,13 +18,21 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-print "# Automatically generated, do not edit."
-print
-print "import lxml.etree"
+format_1 = """\
+# Automatically generated, do not edit.
+
+import lxml.etree
+"""
+
+format_2 = """\
+## @var %s
+## Parsed RelaxNG %s schema
+%s = lxml.etree.RelaxNG(lxml.etree.fromstring('''%s'''))
+"""
+
+print format_1
for varname, filename in (("left_right", "left-right-schema.rng"),
("up_down", "up-down-schema.rng"),
("publication", "publication-schema.rng")):
- f = open(filename)
- print "\n## @var %s\n## Parsed RelaxNG %s schema\n%s = lxml.etree.RelaxNG(lxml.etree.fromstring('''%s'''))" % (varname, varname, varname, f.read())
- f.close()
+ print format_2 % (varname, varname, varname, open(filename).read())
diff --git a/rpkid/pubd.py b/rpkid/pubd.py
index 0392db87..5fbfcb9a 100755
--- a/rpkid/pubd.py
+++ b/rpkid/pubd.py
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import traceback, os, time, getopt, sys, MySQLdb, lxml.etree
+import traceback, os, time, getopt, sys
import rpki.resource_set, rpki.up_down, rpki.left_right, rpki.x509, rpki.sql
import rpki.https, rpki.config, rpki.exceptions, rpki.relaxng, rpki.log
import rpki.publication
diff --git a/rpkid/resource-cert-samples.py b/rpkid/resource-cert-samples.py
index 212d7ff5..fd940194 100644
--- a/rpkid/resource-cert-samples.py
+++ b/rpkid/resource-cert-samples.py
@@ -95,7 +95,7 @@ class allocation(object):
parent = None
- def __init__(self, name, asn = None, ipv4 = None, ipv6 = None, children = [], allocation_map = None):
+ def __init__(self, name, asn = None, ipv4 = None, ipv6 = None, children = (), allocation_map = None):
"""Create a new allocation entry.
This binds the parent attributes of any children, and computes the
diff --git a/rpkid/rootd.py b/rpkid/rootd.py
index 21dc996a..74157281 100755
--- a/rpkid/rootd.py
+++ b/rpkid/rootd.py
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import traceback, os, time, getopt, sys, lxml
+import traceback, os, time, getopt, sys
import rpki.resource_set, rpki.up_down, rpki.left_right, rpki.x509
import rpki.https, rpki.config, rpki.exceptions, rpki.relaxng
import rpki.sundial, rpki.log
diff --git a/rpkid/rpki/exceptions.py b/rpkid/rpki/exceptions.py
index 70608f5f..c3638375 100644
--- a/rpkid/rpki/exceptions.py
+++ b/rpkid/rpki/exceptions.py
@@ -136,3 +136,12 @@ class NoActiveCA(RPKI_Exception):
class BadClientURL(RPKI_Exception):
"""URL given to HTTPS client does not match profile."""
+
+class ClientNotFound(RPKI_Exception):
+ """Could not find specified client in database."""
+
+class BadExtension(RPKI_Exception):
+ """Forbidden X.509 extension."""
+
+class ForbiddenURI(RPKI_Exception):
+ """Forbidden URI, does not start with correct base URI."""
diff --git a/rpkid/rpki/https.py b/rpkid/rpki/https.py
index 7f805377..0e51cec9 100644
--- a/rpkid/rpki/https.py
+++ b/rpkid/rpki/https.py
@@ -21,7 +21,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import httplib, BaseHTTPServer, tlslite.api, glob, traceback, urlparse, socket, signal
+import httplib, BaseHTTPServer, tlslite.api, traceback, urlparse, signal
import rpki.x509, rpki.exceptions, rpki.log
# This should be wrapped somewhere in rpki.x509 eventually
diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py
index 363feddb..a2f74ecf 100644
--- a/rpkid/rpki/left_right.py
+++ b/rpkid/rpki/left_right.py
@@ -17,7 +17,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import base64, lxml.etree, time, traceback, os
+import traceback
import rpki.resource_set, rpki.x509, rpki.sql, rpki.exceptions, rpki.xml_utils
import rpki.https, rpki.up_down, rpki.relaxng, rpki.sundial, rpki.log, rpki.roa
import rpki.publication, rpki.async
diff --git a/rpkid/rpki/publication.py b/rpkid/rpki/publication.py
index 8d5ff267..0b784e97 100644
--- a/rpkid/rpki/publication.py
+++ b/rpkid/rpki/publication.py
@@ -17,7 +17,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import base64, lxml.etree, time, traceback, os
+import base64, os
import rpki.resource_set, rpki.x509, rpki.sql, rpki.exceptions, rpki.xml_utils
import rpki.https, rpki.up_down, rpki.relaxng, rpki.sundial, rpki.log, rpki.roa
@@ -30,11 +30,11 @@ class publication_namespace(object):
class control_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistant, publication_namespace):
"""Virtual class for control channel objects."""
- def serve_dispatch(self, r_msg, client, cb):
+ def serve_dispatch(self, r_msg, cb):
"""Action dispatch handler. This needs special handling because
we need to make sure that this PDU arrived via the control channel.
"""
- if client is not None:
+ if self.client is not None:
raise rpki.exceptions.BadQuery, "Control query received on client channel"
rpki.xml_utils.data_elt.serve_dispatch(self, r_msg, cb)
@@ -162,15 +162,15 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace):
elt.text = base64.b64encode(self.payload.get_DER())
return elt
- def serve_dispatch(self, r_msg, client, cb):
+ def serve_dispatch(self, r_msg, cb):
"""Action dispatch handler."""
- if client is None:
+ if self.client is None:
raise rpki.exceptions.BadQuery, "Client query received on control channel"
dispatch = { "publish" : self.serve_publish,
"withdraw" : self.serve_withdraw }
if self.action not in dispatch:
raise rpki.exceptions.BadQuery, "Unexpected query: action %s" % self.action
- client.check_allowed_uri(self.uri)
+ self.client.check_allowed_uri(self.uri)
dispatch[self.action]()
r_pdu = self.__class__()
r_pdu.action = self.action
@@ -267,7 +267,8 @@ class msg(rpki.xml_utils.msg, publication_namespace):
def loop(iterator, q_pdu):
q_pdu.gctx = gctx
- q_pdu.serve_dispatch(r_msg, client, iterator)
+ q_pdu.client = client
+ q_pdu.serve_dispatch(r_msg, iterator)
def done():
cb(r_msg)
diff --git a/rpkid/rpki/relaxng.py b/rpkid/rpki/relaxng.py
index c66d965a..0f2d2ab5 100644
--- a/rpkid/rpki/relaxng.py
+++ b/rpkid/rpki/relaxng.py
@@ -1697,3 +1697,4 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" en
End:
-->
'''))
+
diff --git a/rpkid/rpki/rpki_engine.py b/rpkid/rpki/rpki_engine.py
index c373e856..d2b28abd 100644
--- a/rpkid/rpki/rpki_engine.py
+++ b/rpkid/rpki/rpki_engine.py
@@ -17,7 +17,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import traceback, os, time, getopt, sys, MySQLdb, lxml.etree
+import traceback, lxml.etree
import rpki.resource_set, rpki.up_down, rpki.left_right, rpki.x509, rpki.sql
import rpki.https, rpki.config, rpki.exceptions, rpki.relaxng, rpki.log, rpki.async
@@ -217,7 +217,6 @@ class ca_obj(rpki.sql.sql_persistant):
information and the parent's up-down protocol list_response PDU.
"""
- repository = parent.repository()
sia_uri = rc.suggested_sia_head and rc.suggested_sia_head.rsync()
if not sia_uri or not sia_uri.startswith(parent.sia_base):
sia_uri = parent.sia_base
diff --git a/rpkid/rpki/sql.py b/rpkid/rpki/sql.py
index e9284539..6705e53b 100644
--- a/rpkid/rpki/sql.py
+++ b/rpkid/rpki/sql.py
@@ -17,7 +17,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import MySQLdb, time, warnings, _mysql_exceptions
+import MySQLdb, warnings, _mysql_exceptions
import rpki.x509, rpki.resource_set, rpki.sundial, rpki.log
class session(object):
diff --git a/rpkid/rpki/up_down.py b/rpkid/rpki/up_down.py
index 15932c38..2d087b0d 100644
--- a/rpkid/rpki/up_down.py
+++ b/rpkid/rpki/up_down.py
@@ -21,7 +21,7 @@ import base64, lxml.etree, time
import rpki.resource_set, rpki.x509, rpki.exceptions
import rpki.xml_utils, rpki.relaxng
-xmlns="http://www.apnic.net/specs/rescerts/up-down/"
+xmlns = "http://www.apnic.net/specs/rescerts/up-down/"
nsmap = { None : xmlns }
@@ -242,9 +242,8 @@ class class_response_syntax(base_elt):
return [c.toXML() for c in self.classes]
class list_response_pdu(class_response_syntax):
- """Up-Down protocol "list_response" PDU."""
-
- pass
+ """Up-Down protocol "list_response" PDU."""
+ pass
class issue_pdu(base_elt):
"""Up-Down protocol "issue" PDU."""
diff --git a/rpkid/rpkid.py b/rpkid/rpkid.py
index 76701368..e9f16941 100755
--- a/rpkid/rpkid.py
+++ b/rpkid/rpkid.py
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import traceback, os, time, getopt, sys, MySQLdb, lxml.etree
+import os, time, getopt, sys
import rpki.resource_set, rpki.up_down, rpki.left_right, rpki.x509, rpki.sql
import rpki.https, rpki.config, rpki.exceptions, rpki.relaxng, rpki.log
import rpki.rpki_engine
diff --git a/rpkid/testbed.py b/rpkid/testbed.py
index 816e09ba..6df60086 100644
--- a/rpkid/testbed.py
+++ b/rpkid/testbed.py
@@ -48,7 +48,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, yaml, MySQLdb, subprocess, signal, time, re, getopt, sys, lxml, traceback
+import os, yaml, MySQLdb, subprocess, signal, time, getopt, sys
import rpki.resource_set, rpki.sundial, rpki.x509, rpki.https
import rpki.log, rpki.left_right, rpki.config, rpki.publication, rpki.async
diff --git a/rpkid/testpoke.py b/rpkid/testpoke.py
index a545e5bc..e1c583e4 100644
--- a/rpkid/testpoke.py
+++ b/rpkid/testpoke.py
@@ -27,7 +27,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, time, getopt, sys, lxml, yaml
+import os, time, getopt, sys, yaml
import rpki.resource_set, rpki.up_down, rpki.left_right, rpki.x509
import rpki.https, rpki.config, rpki.exceptions
import rpki.relaxng, rpki.oids, rpki.log
diff --git a/rpkid/xml-parse-test.py b/rpkid/xml-parse-test.py
index 27573ee0..a01244a8 100755
--- a/rpkid/xml-parse-test.py
+++ b/rpkid/xml-parse-test.py
@@ -16,7 +16,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import glob, xml.sax, lxml.etree, lxml.sax, POW, POW.pkix
+import glob, lxml.etree, lxml.sax
import rpki.up_down, rpki.left_right, rpki.publication, rpki.relaxng
verbose = False