Add include_spans option to find_iocs (#291)#367
Open
fhightower wants to merge 1 commit into
Open
Conversation
Returns dict[ioc_type, dict[value, list[(start, end)]]] with offsets into the original (pre-fanging) input. Spans are recovered through a SequenceMatcher-based offset map, so e.g. example[.]com surfaces as example.com pointing at the original bracketed substring. Limited to DEFAULT_IOC_TYPES in this PR; non-default types passed alongside include_spans=True raise ValueError. Percent-decoding inside URL paths is skipped in span mode (would shift downstream offsets). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
include_spans=Trueflag onfind_iocsreturnsdict[ioc_type, dict[value, list[(start, end)]]]with offsets into the original input text (pre-fanging).SequenceMatcher-based offset map, soexample[.]comsurfaces asexample.comwith a span covering the bracketed original substring.DEFAULT_IOC_TYPESfor this PR; passing any other type withinclude_spans=TrueraisesValueError.Notes
Test plan
make lint(ruff + mypy) cleantests/test_find_iocs_spans.pycovers each default IOC type, fanged input ([.],hxxp), multi-occurrence dedup-with-spans, URL trim via_clean_url, every non-default boolean branch, and the validation error path🤖 Generated with Claude Code