feat(ml): structured indicator extraction (Item C)#208
Open
kurtpayne wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
==========================================
+ Coverage 75.87% 76.38% +0.51%
==========================================
Files 41 42 +1
Lines 5994 6175 +181
==========================================
+ Hits 4548 4717 +169
- Misses 1446 1458 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4 tasks
Item C of the post-v4.7 pivot. Replaces "look at line 12" with
"look at the curl to evil.example.com on line 12" by post-processing
the model's output (no retraining required).
Adds:
- skillscan.models.Indicator — pydantic model with type/value/line/evidence
- skillscan.models.Finding.indicators — new optional list field
(default [], backward-compatible with all existing consumers)
- skillscan.indicators — extractor module with regex-based extractors
for 6 indicator types:
url — http(s) URLs (terminator-aware: shell substitution
$(...) and backticks don't get absorbed)
cve — CVE-YYYY-NNNN[NNN], also extracted from `reasoning`
text (model often cites CVEs not in skill body)
ip — IPv4 dotted-quad with octet validation; localhost
noise floor (127.x, 0.0.0.0)
domain — bare hostnames not already surfaced by URL extractor;
lookbehind blocks parent-domain dupes (`nist.gov`
inside `nvd.nist.gov`); 30-entry common-domain noise
floor (github, npm, pypi, anthropic, ...)
package — npm scoped (@scope/name) anywhere; pip/npm/yarn/pnpm
install command line capture (multi-package)
file_path — /etc, /var, /tmp, /usr, /root system paths;
../../traversal; ~/.dotfiles; Windows C:\
- 25 unit tests covering each extractor and a realistic-skill integration
- Wiring in ml_detector.py: extract_indicators() runs once per file
and the same list is attached to each label-specific Finding produced.
Wrapped in try/except — extractor failure never breaks the scanner.
Conservative posture: when in doubt, drop. False indicators are worse
than missing ones because they give downstream tooling bad targets to
act on. Cap is 50 indicators per finding.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
05625f8 to
b80716e
Compare
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
Item C of the post-v4.7 pivot. Replaces `affected_lines: [12]` with `indicators: [{type, value, line}]` so output goes from "look at line 12" to "look at the curl-to-evil.example.com on line 12."
Adds:
No model retraining needed. Pure post-process at inference time.
Indicator types
Conservative posture
Test plan
Compatibility
Strictly additive: `Finding.indicators` defaults to `[]`. Existing JSON / SARIF / JUnit consumers see an empty list (or the field omitted depending on serialization) and behave unchanged. Older clients that don't know about the field will simply ignore it.
🤖 Generated with Claude Code