Require AS prefix for high-confidence ASN detection - #36
Open
elhoim wants to merge 1 commit into
Open
Conversation
looks_like_asn's regex made the 'AS' prefix optional, so any bare 1-10 digit string (e.g. '12345', or a pasted port number like '443') scored 90 and was guessed as an ASN attribute type. Now the prefix is required for the 90-score match, and a bare-digit string is still offered as a low-confidence ASN guess (score 20) rather than a near-certain one.
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.
Finding 22 (Medium) —
bin/cli.py:182Problem
looks_like_asn's ^(AS)?\d{1,10}$ makes the prefix optional, so any bare 1-10 digit string scores 90 as an ASN - verified for '12345' and '443' (a pasted port number).
Fix
looks_like_asn used the regex ^(AS)?\d{1,10}$, making the "AS" prefix optional, so any bare 1-10 digit string (e.g. "12345", or a pasted port number like "443") scored 90 and was confidently guessed as an ASN attribute. Fixed by requiring the "AS" prefix for the 90-score match (regex now ^AS\d{1,10}$), and adding a separate low-confidence path (score 20) for bare digit strings via a new looks_like_bare_asn_digits helper, so the guess is still offered but ranked appropriately low rather than near-certain.
Verification
Reproduced against the unmodified code at
9b8c605, then re-checked after the change.Before
After
python bin/cli.py --helpexits 0 and the module still imports cleanly. Verification was performed offline against the pure functions — no runningmisp-modulesinstance is required.Branched from
9b8c605. This PR addresses only this finding; the other findings from the same review are in separate PRs, so they will need rebasing against each other as they merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYX4TKA5inzByJ4qGWKjqh