Repository navigation
Commit 9b9d33f
fix(supply-chain): require relative edit distance for SC6 typosquat detection
Absolute edit-distance <= 2 produces false positives on short, legitimate
package names: "task" is a real package and is edit-distance 2 from "flask",
yet was flagged as a possible typosquat (one of the cases reported in #103).
Add a relative-distance guard (dist/shorter_len <= 1/3) so short names need an
all-but-one-character match while longer names may still differ by two
characters. Existing behaviour is preserved:
- "reqeusts" -> "requests" (len 8, dist 2) still flagged
- "expreess" -> "express" (dist 1) still flagged
- "task" -> "flask" (len 4, dist 2) no longer flagged
Adds a regression test; all existing SC4/SC5/SC6 unit tests still pass and
ruff is clean.
Refs #103
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yonatan Gross <[email protected]>1 parent a5092dd commit 9b9d33f
2 files changed
Lines changed: 21 additions & 2 deletions
File tree
- src/skillspector/nodes/analyzers
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
299 | 310 | | |
300 | 311 | | |
301 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1012 | 1012 | | |
1013 | 1013 | | |
1014 | 1014 | | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1015 | 1023 | | |
1016 | 1024 | | |
1017 | 1025 | | |
| |||
0 commit comments