feat(security): block known malware (OSV MAL-*) and detect typosquatting#23
Conversation
…te UNKNOWN severity to ask OSV malware advisories (OpenSSF malicious-packages, MAL-* ids) usually carry no CVSS score. The severity chain collapsed them to UNKNOWN -> NONE -> allow, so packages known to be malware were installed with a reassuring "none are above LOW severity" message. - osv.ts: any advisory with a MAL- prefixed id or alias is CRITICAL - index.ts: UNKNOWN no longer maps to NONE - decision.ts: UNKNOWN severity triggers ask instead of allow Fixes PRO-373. https://claude.ai/code/session_01QTEvxicjPZXdx2hvmvnmzH
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughDie PR ergänzt konsistente Behandlung von UNKNOWN-Schweregrad: OSV-Daten werden korrekt von UNKNOWN (statt NONE) differenziert, Malware-Advisories als CRITICAL erkannt, und die Entscheidungslogik behandelt UNKNOWN als Genehmigungsfall statt Auto-Allow. Zusätzlich wird eine offline Typosquat-Erkennung eingeführt, deren Signale in die Entscheidungsaggregation einfließen. ChangesUNKNOWN-Severity-Klassifizierung und Entscheidungsfluss
Sequence DiagramssequenceDiagram
participant API as OSV API
participant Extract as coerceSeverity
participant Map as mapSeverity
participant Typos as checkTyposquat
participant Decide as makeDecision
API->>Extract: Advisory (id, aliases, cvss, database_specific)
Extract->>Extract: Check MAL- prefix
alt MAL-* detected
Extract->>Extract: Return CRITICAL
else No MAL-
Extract->>Extract: CVSS → severity
Extract->>Extract: Or database_specific.severity
Extract->>Extract: Or UNKNOWN
end
Extract->>Map: OSV severity
Map->>Map: UNKNOWN → UNKNOWN (not NONE)
Typos->>Map: (offline) check popular lists → possible 'typosquat' signal
Map->>Decide: Decision engine severity + signals
Decide->>Decide: CRITICAL/HIGH → deny
Decide->>Decide: MODERATE/UNKNOWN → ask
Decide->>Decide: LOW → allow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Typosquatting is the most common package fraud vector and had no direct detection. New offline check compares installed package names against an embedded curated list of popular npm/PyPI packages using bounded Damerau-Levenshtein distance (transpositions like 'lodahs' count as one edit). Near-misses raise a HIGH supply chain signal, escalating the decision to ask with a 'Did you mean ...?' hint. - distance 1 for names >= 4 chars, distance 2 only for >= 8 chars (keeps short names from false-positiving) - PyPI names are PEP 503-normalized before comparison - exact matches with popular packages are never flagged - runs fully offline: no extra latency, no new failure mode Implements PRO-374. https://claude.ai/code/session_01QTEvxicjPZXdx2hvmvnmzH
…nflict Combined both Limitations additions and brought the supply chain and decision logic tables up to date with main (MAL-* malware blocking, UNKNOWN severity ask, typosquat detection from PR #23). https://claude.ai/code/session_01QTEvxicjPZXdx2hvmvnmzH
Two fraud-protection improvements: a fix for a severity-mapping gap that let known malware through, and a new offline typosquatting check.
1. Known malware (MAL-*) was silently allowed — fixed
The OSV database includes the OpenSSF malicious-packages catalog (
MAL-*ids), but these advisories usually carry no CVSS score. The severity chain collapsed them toUNKNOWN→NONE→ allow, with the message "Vulnerabilities found, but none are above LOW severity".src/osv.ts: any advisory with aMAL-prefixed id or alias is treated asCRITICAL(checked on the raw OSV entry, beforechooseId()resolves CVE aliases)src/index.ts:UNKNOWNseverity no longer collapses toNONEsrc/decision.ts:UNKNOWNseverity triggersaskinstead ofallowNet effect: known malware →
deny; unscored advisories →ask; everything else unchanged.2. Typosquatting detection (new)
Typosquatting (
lodahs,reqeusts,crossenv) is the most common package fraud vector and had no direct detection.src/typosquat.ts: bounded Damerau-Levenshtein comparison against an embedded curated list of popular npm/PyPI packages (src/data/popular-packages.ts). Transpositions count as 1 edit — plain Levenshtein would misslodahs.vue/vie)HIGHsupply chain signal → decision escalates toaskwith aDid you mean "lodash"?hintTests
src/decision.test.ts(UNKNOWN → ask, severity precedence, signal merging)src/typosquat.test.ts(15 tests: transpositions, omissions, scoped packages, PEP 503, short-name guards, homebrew skip)tsc --noEmitcleanCloses Linear issues PRO-373 and PRO-374.
https://claude.ai/code/session_01QTEvxicjPZXdx2hvmvnmzH
Summary by CodeRabbit
Bug Fixes
New Features
Tests