1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

fix sourceless irr validation (#706)

Co-authored-by: Stefan Pratter <stefan@20c.com>
This commit is contained in:
Matt Griswold
2020-04-23 08:49:53 -05:00
committed by GitHub
parent a4f72d3c2e
commit 095422f0f5
2 changed files with 13 additions and 5 deletions

View File

@@ -195,9 +195,12 @@ def validate_irr_as_set(value):
source = parts_match.group(1)
as_set = parts_match.group(2)
else:
raise ValidationError(_("Invalid formatting: {} - should be AS-SET@SOURCE or SOURCE::AS-SET").format(item))
sourceless_match = re.match("^([\w\d\-:]+)$", item)
as_set = sourceless_match.group(1)
if not sourceless_match:
raise ValidationError(_("Invalid formatting: {} - should be AS-SET, ASx, AS-SET@SOURCE or SOURCE::AS-SET").format(item))
if source not in IRR_SOURCE:
if source and source not in IRR_SOURCE:
raise ValidationError(_("Unknown IRR source: {}").format(source))

View File

@@ -170,15 +170,20 @@ def test_validate_prefix_overlap():
("RIPE::AS12345", "RIPE::AS12345"),
("AS12345@RIPE", "AS12345@RIPE"),
("RIPE::AS123456:RS-FOO", "RIPE::AS123456:RS-FOO"),
("as-foo", "AS-FOO"),
("rs-foo", "RS-FOO"),
("as-foo as-bar", "AS-FOO AS-BAR"),
("rs-foo as-bar", "RS-FOO AS-BAR"),
("rs-foo rs-bar", "RS-FOO RS-BAR"),
("AS15562", "AS15562"),
("AS15562 AS33333", "AS15562 AS33333"),
# fail validation
("AS-FOO", False),
("UNKNOWN::AS-FOO", False),
("AS-FOO@UNKNOWN", False),
("ASFOO@UNKNOWN", False),
("UNKNOWN::ASFOO", False),
("AS-FOO RIPE:AS-FOO", False),
("AS-FOO AS-FOO@RIPE", False),
("RIPE:AS-FOO", False),
("RIPE::RS15562:RS-FOO", False),
("RIPE::AS123456:RS-FOO:AS-FOO", False),