fix: RPKI validation returns Invalid for max_length exceeded#28
Merged
fix: RPKI validation returns Invalid for max_length exceeded#28
Conversation
Fixed a bug where validate() and validate_check_expiry() incorrectly returned Unknown when a prefix was covered by an ROA but exceeded the max_length restriction. Now returns Invalid instead. Changes: - Added lookup_covering_roas() helper to find all covering ROAs - Modified validate() to check coverage first before filtering - Modified validate_check_expiry() with same fix - Added tests for max_length exceeded scenarios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a bug where RPKI validation incorrectly returned
Unknownwhen a prefix was covered by an ROA but exceeded themax_lengthrestriction. Now correctly returnsInvalid.Root Cause
In
lookup_by_prefix(), ROAs were filtered bymax_length >= prefix.prefix_len(). When validating a more specific prefix (e.g., /24 covered by a /23 ROA with max_length 23), the ROA was filtered out, causingvalidate()to see empty matches and returnUnknowninstead ofInvalid.Changes
lookup_covering_roas()helper method to find all covering ROAs without max_length filtervalidate()to check coverage first before filtering by max_lengthvalidate_check_expiry()with the same fixValidation Logic
UnknownInvalidValidTests
test_validate_max_length_exceeded- Core bug scenariotest_validate_check_expiry_max_length_exceeded- Expiry-aware validationtest_lookup_covering_roas- Helper methodAll RPKI tests pass.