From 1bccf7abccfd0a0063f394d579984a4ea137b2bc Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 9 Mar 2010 22:52:27 +0000 Subject: Update RelaxNG schema to reflect what myrpki generates these days. This will need further cleanup, as what it's generating is icky. svn path=/myrpki.rototill/Makefile; revision=3055 --- myrpki.rototill/Makefile | 7 +- myrpki.rototill/myrpki.py | 4 +- myrpki.rototill/myrpki.rnc | 126 +++++++++++++----- myrpki.rototill/myrpki.rng | 322 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 348 insertions(+), 111 deletions(-) (limited to 'myrpki.rototill') diff --git a/myrpki.rototill/Makefile b/myrpki.rototill/Makefile index a8306e30..12c7e940 100644 --- a/myrpki.rototill/Makefile +++ b/myrpki.rototill/Makefile @@ -2,6 +2,9 @@ all: myrpki.rng +relaxng: myrpki.rng + xmllint --noout --relaxng myrpki.rng `find test -type f -name '*.xml'` + lint: myrpki.xml myrpki.rng xmllint --noout --relaxng myrpki.rng myrpki.xml @@ -29,5 +32,5 @@ backup: tar cvvzf test.$$(TZ='' date +%Y.%m.%d.%H.%M.%S).tgz screenlog.* test backup.*.sql rm backup.*.sql -test: all - python yamltest.py +test: myrpki.rng + MYRPKI_RNG=`pwd`/myrpki.rng python yamltest.py diff --git a/myrpki.rototill/myrpki.py b/myrpki.rototill/myrpki.py index c84a520b..ff0a7582 100644 --- a/myrpki.rototill/myrpki.py +++ b/myrpki.rototill/myrpki.py @@ -749,7 +749,7 @@ def etree_validate(e): print lxml.etree.tostring(e, pretty_print = True) raise -def etree_write(e, filename, verbose = True, validate = False): +def etree_write(e, filename, verbose = True, validate = True): """ Write out an etree to a file, safely. @@ -769,7 +769,7 @@ def etree_write(e, filename, verbose = True, validate = False): ElementTree(e).write(filename + ".tmp") os.rename(filename + ".tmp", filename) -def etree_read(filename, verbose = False, validate = False): +def etree_read(filename, verbose = True, validate = True): """ Read an etree from a file, verifying then stripping XML namespace cruft. diff --git a/myrpki.rototill/myrpki.rnc b/myrpki.rototill/myrpki.rnc index 29db7a67..feb3cf0f 100644 --- a/myrpki.rototill/myrpki.rnc +++ b/myrpki.rototill/myrpki.rnc @@ -7,6 +7,8 @@ default namespace = "http://www.hactrn.net/uris/rpki/myrpki/" +version = "2" + base64 = xsd:base64Binary { maxLength="512000" } object_handle = xsd:string { maxLength="255" pattern="[\-_A-Za-z0-9]*" } pubd_handle = xsd:string { maxLength="255" pattern="[\-_A-Za-z0-9/]*" } @@ -15,54 +17,108 @@ asn_list = xsd:string { maxLength="512000" pattern="[\-,0-9]*" } ipv4_list = xsd:string { maxLength="512000" pattern="[\-,0-9/.]*" } ipv6_list = xsd:string { maxLength="512000" pattern="[\-,0-9/:a-fA-F]*" } -start = element myrpki { - attribute version { "2" }, +start |= myrpki_pdu +start |= identity_pdu +start |= parent_pdu +start |= repository_pdu + +myrpki_pdu = element myrpki { + attribute version { version }, attribute handle { object_handle }, - roa_request_elt*, - child_elt*, - parent_elt*, - repository_elt*, - bpki_ca_certificate_elt?, - bpki_crl_elt?, - bpki_bsc_certificate_elt?, - bpki_bsc_pkcs10_elt? + element roa_request { + attribute asn { xsd:positiveInteger }, + attribute v4 { ipv4_list }, + attribute v6 { ipv6_list } + }*, + element child { + attribute handle { object_handle }, + attribute valid_until { xsd:dateTime { pattern=".*Z" } }, + attribute asns { asn_list }?, + attribute v4 { ipv4_list }?, + attribute v6 { ipv6_list }?, + element bpki_certificate { base64 }? + }*, + element parent { + attribute handle { object_handle }, + attribute service_uri { uri }?, + attribute myhandle { object_handle }?, + attribute sia_base { uri }?, + element bpki_cms_certificate { base64 }?, + element bpki_https_certificate { base64 }? + }*, + element repository { + attribute handle { object_handle }, + attribute service_uri { uri }?, + element bpki_certificate { base64 }? + }*, + element bpki_ca_certificate { base64 }?, + element bpki_crl { base64 }?, + element bpki_bsc_certificate { base64 }?, + element bpki_bsc_pkcs10 { base64 }? } -roa_request_elt = element roa_request { - attribute asn { xsd:positiveInteger }, - attribute v4 { ipv4_list }, - attribute v6 { ipv6_list } +identity_pdu = element identity { + attribute version { version }, + attribute handle { object_handle }, + element bpki_ta { base64 } } -child_elt = element child { - attribute handle { object_handle }, +parent_pdu = element parent { + attribute version { version }, attribute valid_until { xsd:dateTime { pattern=".*Z" } }, - attribute asns { asn_list }?, - attribute v4 { ipv4_list }?, - attribute v6 { ipv6_list }?, - element bpki_certificate { base64 }? + attribute service_uri { uri }?, + attribute child_handle { object_handle }, + attribute parent_handle { object_handle }, + element bpki_resource_ta { base64 }?, + element bpki_server_ta { base64 }?, + element bpki_child_ta { base64 }?, + element repository { + ((attribute type { "offer" }) | + (attribute type { "hint" }, + attribute proposed_sia_base { uri }, + element contact_info { xsd:string })) + }? } -parent_elt = element parent { - attribute handle { object_handle }, - attribute service_uri { uri }?, - attribute myhandle { object_handle }?, - attribute sia_base { uri }?, - element bpki_cms_certificate { base64 }?, - element bpki_https_certificate { base64 }? +repository_pdu |= element repository { + attribute version { version }, + attribute type { "confirmed" }, + attribute parent_handle { object_handle }, + attribute client_handle { pubd_handle }, + attribute service_uri { uri }, + attribute sia_base { uri }, + attribute repository_handle { object_handle }, + element bpki_server_ta { base64 }?, + element bpki_client_ta { base64 }?, + element contact_info { xsd:string }? } -repository_elt = element repository { - attribute handle { object_handle }, - attribute service_uri { uri }?, - element bpki_certificate { base64 }? +repository_pdu |= element repository { + attribute version { version }, + attribute type { "request" }, + attribute handle { pubd_handle }, + attribute parent_handle { object_handle }, + element contact_info { xsd:string }?, + element bpki_ta { base64 }? } -bpki_ca_certificate_elt = element bpki_ca_certificate { base64 } -bpki_crl_elt = element bpki_crl { base64 } +repository_pdu |= element repository { + attribute version { version }, + attribute type { "offer" }, + attribute handle { pubd_handle }, + attribute parent_handle { object_handle }, + element bpki_ta { base64 }? +} -bpki_bsc_certificate_elt = element bpki_bsc_certificate { base64 } -bpki_bsc_pkcs10_elt = element bpki_bsc_pkcs10 { base64 } +repository_pdu |= element repository { + attribute version { version }, + attribute type { "hint" }, + attribute handle { pubd_handle }, + attribute parent_handle { object_handle }, + attribute proposed_sia_base { uri }, + element contact_info { xsd:string }?, + element bpki_ta { base64 }? +} # Local Variables: # indent-tabs-mode: nil diff --git a/myrpki.rototill/myrpki.rng b/myrpki.rototill/myrpki.rng index 1fa2cd86..2202f4d2 100644 --- a/myrpki.rototill/myrpki.rng +++ b/myrpki.rototill/myrpki.rng @@ -8,6 +8,9 @@ run the compact syntax through trang to get XML syntax. --> + + 2 + 512000 @@ -48,57 +51,159 @@ [\-,0-9/:a-fA-F]* - + + + + + + + + + + + + + - 2 + - + + + + + + + + + + + - + + + + + + + .*Z + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + - + + + - + + + - + + + - + + + - - - - - - - - + + + + + - - + + + + + - - - - + + + + @@ -106,96 +211,169 @@ - - + + + + + + + + - - - + + + - - - + + + - + + + + + + offer + + + + hint + + + + + + + + + + + - - - + + + + + + + confirmed + + + + + + + + + + + + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + request + + + + + + + + + + + - + + + + + + + + + + offer + + + + + + + - + - + + + + + + hint + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - - - - - -