Repository navigation
Conversation
…ddresses Reorder the octet alternation longest-first so a full IPv4 address is matched, and guard both ends against digit/dot continuation so the pattern no longer reports a fragment of a longer dotted token (e.g. 172.31.2.51 was reported as 172.31.2.5). Fixes dwisiswant0#80
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.
Fixes #80
The
IP_Addresspattern lists the single-digit alternative[0-9]first in each octet. Python's
realternation is first-match, so thelast octet always stops after one digit: a source line containing
http://172.31.2.51:600is reported as172.31.2.5, and172.31.2.54collapses into the same wrong result.
This reorders the octet alternation longest-first
(
25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9]) and guards both endsagainst digit/dot continuation, so the pattern matches a complete IPv4
address and no longer returns a fragment of a longer dotted token.
Tokens with an invalid octet now report nothing instead of a
fabricated fragment: previously
999.1.2.3was reported as99.1.2.3,256.1.1.1as56.1.1.1, and1.2.3.456as1.2.3.4.The same applies to octets with leading zeros (
010.1.2.3,1.2.3.04), which the old pattern reported as fragments and the newone does not report. Addresses followed by a port or by sentence
punctuation still match.
Verified with a line battery run through the same compile+search
semantics as
util.finder(), plus an end-to-endutil.finder()runover a sample decompiled tree: before, it returned
['172.31.2.5'];after, it returns
['172.31.2.51', '172.31.2.54']. All 53 patterns inregexes.json still compile.