fix(import-document): prevent IP addresses being classified as phone numbers (#6677)#7065
Open
steadytao wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a misclassification bug in the import-document connector where dotted IPv4 addresses could be matched by the phone-number regex and incorrectly emitted as Phone-Number observables. It adds a post-processing guard to drop “phone number” matches that are valid IPs, while keeping the existing IP whitelist/filter behavior intact.
Changes:
- Discard
Phone-Number.valuematches that parse as valid IP addresses (so IPv4s won’t be reclassified as phone numbers). - Preserve existing IP filtering/whitelisting behavior (e.g., filtered IPs remain omitted rather than reappearing as phone numbers).
- Add regression tests covering valid IPv4s, filtered IPv4s, and real phone-number matches.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal-import-file/import-document/src/reportimporter/report_parser.py | Adds an ipaddress.ip_address() check to drop phone-number matches that are actually IP addresses. |
| internal-import-file/import-document/tests/test_report_parser_observables.py | New regression tests ensuring IPv4s aren’t classified as phone numbers, filtered IPs stay filtered, and phone numbers still match. |
Author
|
Bit of a band-aid fix but phone number handling does have to be fairly broad for its intended use-case. Perhaps aligning against E.164 may be worth considering. |
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.
Proposed changes
Related issues
Checklist