Skip to content

Commit

Permalink
Fix #232 -- Always silently ignore object classes starting with *xx
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Jun 24, 2019
1 parent e9e6e64 commit 224593e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/admins/object-validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The parser/validator has two modes:
* Strict: validates presence, count, and correct syntax of all fields.
Validation fails on attributes that are not known, or object classes
that are not known. Values of all fields are validated.
Unknown object classes that start with ``*xx`` are silently ignored,
as these are harmless artifacts from certain legacy IRRd versions.

In addition, the following validation changes to primary/lookup keys apply
in non-strict mode:
Expand Down
2 changes: 2 additions & 0 deletions docs/users/mirroring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ Manual loading uses the ``irrd_load_database`` command:
:doc:`non-strict object validation </admins/object-validation>`,
an object with an unknown object class, or an object for which
the `source` attribute is inconsistent with the `--source` argument.
Unknown object classes that start with ``*xx`` are silently ignored,
as these are harmless artifacts from certain legacy IRRd versions.
* The object class filter configured, if any, is followed.

On serials:
Expand Down
5 changes: 5 additions & 0 deletions irrd/mirroring/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def _parse_object(self, rpsl_text: str) -> Optional[str]:
self.database_handler.upsert_rpsl_object(obj, forced_serial=self.serial)

except UnknownRPSLObjectClassException as e:
# Ignore legacy IRRd artifacts
# https://github.com/irrdnet/irrd4/issues/232
if e.rpsl_object_class.startswith('*xx'):
self.obj_parsed -= 1 # This object does not exist to us
return None
if self.direct_error_return:
return f'Unknown object class: {e.rpsl_object_class}'
self.obj_unknown += 1
Expand Down
3 changes: 2 additions & 1 deletion irrd/mirroring/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from irrd.rpsl.rpsl_objects import rpsl_object_from_text
from irrd.utils.rpsl_samples import SAMPLE_ROUTE, SAMPLE_UNKNOWN_CLASS, SAMPLE_UNKNOWN_ATTRIBUTE, SAMPLE_MALFORMED_PK, \
SAMPLE_ROUTE6, SAMPLE_KEY_CERT, KEY_CERT_SIGNED_MESSAGE_VALID
SAMPLE_ROUTE6, SAMPLE_KEY_CERT, KEY_CERT_SIGNED_MESSAGE_VALID, SAMPLE_LEGACY_IRRD_ARTIFACT
from irrd.utils.test_utils import flatten_mock_calls
from .nrtm_samples import (SAMPLE_NRTM_V3, SAMPLE_NRTM_V1, SAMPLE_NRTM_V1_TOO_MANY_ITEMS, SAMPLE_NRTM_INVALID_VERSION,
SAMPLE_NRTM_V3_SERIAL_GAP, SAMPLE_NRTM_V3_INVALID_MULTIPLE_START_LINES,
Expand Down Expand Up @@ -33,6 +33,7 @@ def test_parse(self, monkeypatch, caplog, tmp_gpg_dir, config_override):
SAMPLE_ROUTE.replace('TEST', 'BADSOURCE'),
SAMPLE_UNKNOWN_CLASS,
SAMPLE_MALFORMED_PK,
SAMPLE_LEGACY_IRRD_ARTIFACT,
]
test_input = '\n\n'.join(test_data)

Expand Down
8 changes: 8 additions & 0 deletions irrd/utils/rpsl_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,14 @@
source: TEST
"""

# https://github.com/irrdnet/irrd4/issues/232
SAMPLE_LEGACY_IRRD_ARTIFACT = """*xxte: 192.0.2.0/24
origin: AS65537
mnt-by: TEST-MNT
changed: 2009-10-15T09:32:17Z
source: TEST
"""

SAMPLE_MALFORMED_ATTRIBUTE_NAME = """route: 192.0.2.0/24
origin: AS65537
$$$-by: TEST-MNT
Expand Down

0 comments on commit 224593e

Please sign in to comment.