quantumsafe-scan 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {quantumsafe_scan-0.3.1/quantumsafe_scan.egg-info → quantumsafe_scan-0.3.2}/PKG-INFO +28 -11
  2. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/README.md +27 -10
  3. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/__init__.py +1 -1
  4. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/scanner.py +119 -4
  5. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/pyproject.toml +1 -1
  6. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2/quantumsafe_scan.egg-info}/PKG-INFO +28 -11
  7. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_scanner.py +76 -0
  8. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_security_hardening.py +10 -1
  9. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/LICENSE +0 -0
  10. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/callgraph.py +0 -0
  11. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/certchain.py +0 -0
  12. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/cli.py +0 -0
  13. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/dependencies.py +0 -0
  14. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/diff.py +0 -0
  15. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/horizon.py +0 -0
  16. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/origins.py +0 -0
  17. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/reachability.py +0 -0
  18. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/recommender.py +0 -0
  19. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/remediation.py +0 -0
  20. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/reporter.py +0 -0
  21. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/scorer.py +0 -0
  22. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/taint.py +0 -0
  23. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/cli/tlsscan.py +0 -0
  24. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/quantumsafe_scan.egg-info/SOURCES.txt +0 -0
  25. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/quantumsafe_scan.egg-info/dependency_links.txt +0 -0
  26. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/quantumsafe_scan.egg-info/entry_points.txt +0 -0
  27. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/quantumsafe_scan.egg-info/requires.txt +0 -0
  28. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/quantumsafe_scan.egg-info/top_level.txt +0 -0
  29. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/setup.cfg +0 -0
  30. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_api.py +0 -0
  31. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_benchmark.py +0 -0
  32. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_callgraph.py +0 -0
  33. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_certchain.py +0 -0
  34. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_conformance.py +0 -0
  35. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_cors.py +0 -0
  36. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_diff.py +0 -0
  37. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_features.py +0 -0
  38. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_horizon.py +0 -0
  39. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_origins.py +0 -0
  40. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_pqc.py +0 -0
  41. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_quantum.py +0 -0
  42. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_remediation.py +0 -0
  43. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_schema.py +0 -0
  44. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_scorer.py +0 -0
  45. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_seeded.py +0 -0
  46. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_taint.py +0 -0
  47. {quantumsafe_scan-0.3.1 → quantumsafe_scan-0.3.2}/tests/test_tlsscan.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantumsafe-scan
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Scan codebases and dependencies for quantum-vulnerable cryptography and generate a NIST-aligned migration plan (SARIF + CycloneDX CBOM).
5
5
  Author: QuantumSafe
6
6
  License: MIT
@@ -39,11 +39,12 @@ Dynamic: license-file
39
39
  <img src="https://img.shields.io/pypi/pyversions/quantumsafe-scan?style=flat-square&logo=python&logoColor=white" alt="Python versions">
40
40
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Danny-397/Quantum-Safe-Scan/ci.yml?branch=main&style=flat-square&logo=githubactions&logoColor=white&label=CI" alt="CI status"></a>
41
41
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/tags"><img src="https://img.shields.io/github/v/tag/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github&label=version&color=5b73e8" alt="Latest version"></a>
42
- <a href="https://github.com/Danny-397/Quantum-Safe-Scan/stargazers"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
42
+ <a href="https://github.com/Danny-397/Quantum-Safe-Scan"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
43
43
  <img src="https://img.shields.io/github/last-commit/Danny-397/Quantum-Safe-Scan?style=flat-square&color=555" alt="Last commit">
44
44
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
45
+ <a href="https://doi.org/10.5281/zenodo.23843488"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23843488-5b73e8?style=flat-square" alt="DOI 10.5281/zenodo.23843488"></a>
45
46
  <br>
46
- <img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
47
+ <img src="https://img.shields.io/badge/tests-584%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="584 tests passing">
47
48
  <img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
48
49
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
49
50
  <img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
@@ -91,7 +92,7 @@ solution:
91
92
  | Layer | Module | What it does |
92
93
  |-------|--------|--------------|
93
94
  | **1. Attack** | [`quantum/`](quantum/) | Shor's and Grover's algorithms in **Qiskit**, run on a quantum simulator. At simulator scale Shor factors a small number and reconstructs a toy RSA key — an educational demonstration of *why* RSA/ECC are rated HIGH (not a break of real key sizes). |
94
- | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages** — see [methodology](benchmark/RESULTS.md) and [real-code precision](benchmark/RESULTS-precision.md). |
95
+ | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages**, and **88% recall (95% CI 71–96%) on a held-out random sample of real files with every usage labeled by hand** — see [methodology](benchmark/RESULTS.md), [real-code precision](benchmark/RESULTS-precision.md) and [real-code recall](benchmark/README.md#recall-on-real-code-recall_samplepy). |
95
96
  | **3. Fix** | [`pqc/`](pqc/) | A from-scratch **lattice (LWE) key-encapsulation mechanism** — the math behind CRYSTALS-Kyber / ML-KEM — so the recommended fix is runnable and provable. |
96
97
 
97
98
  The detection layer ships through three surfaces that share **one** engine:
@@ -475,7 +476,13 @@ construction — 50 real quantum-vulnerable API calls (many idiomatic variants
475
476
  per family, 7 languages) that must be detected, plus 50 comment/string decoys
476
477
  that must not be. Latest run: **100% recall, 100% mutation precision**
477
478
  ([RESULTS-seeded.md](benchmark/RESULTS-seeded.md)), enforced by
478
- `tests/test_seeded.py`. Honest limits are documented in
479
+ `tests/test_seeded.py`. Seeded cases only test the patterns someone thought to
480
+ write, so recall is also measured on **real code**: random files from 37 pinned
481
+ PyPI packages, every quantum-vulnerable usage labeled by hand before scanning. The
482
+ first sample found 68%, and its misses drove the fixes; a held-out sample labeled
483
+ afterwards finds **88% (95% CI 71–96%)**
484
+ ([how, and every miss](benchmark/README.md#recall-on-real-code-recall_samplepy)).
485
+ Honest limits are documented in
479
486
  [benchmark/README.md](benchmark/README.md) — these are regression benchmarks, not
480
487
  a claim of perfection on arbitrary code.
481
488
 
@@ -491,7 +498,7 @@ badge from an actual scan — in [docs/EXAMPLES.md](docs/EXAMPLES.md).
491
498
 
492
499
  ### Real-world scan: paramiko (the SSH library)
493
500
 
494
- Run against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
501
+ Run in July 2026 against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
495
502
  — the SSH implementation behind Ansible, Fabric, and much of the Python ecosystem.
496
503
  SSH key exchange leans on RSA, ECDSA, and Diffie-Hellman, all broken by Shor's
497
504
  algorithm, which makes it a textbook "harvest now, decrypt later" target:
@@ -529,9 +536,10 @@ python benchmark/realworld.py
529
536
  |---|---|
530
537
  | Packages scanned | **37** |
531
538
  | Packages with ≥1 finding | **32 (86%)** |
532
- | Python files analyzed | **10,938** |
533
- | Total findings | **5,512** — **4,083 HIGH-risk** |
534
- | Most common families | `ecc` ×1,709, `sha256` ×956, `rsa` ×770, `sha1` ×576, `dsa` ×355, `md5` ×351 |
539
+ | Python files analyzed | **11,275** |
540
+ | Total findings | **5,609** — **4,236 HIGH-risk** |
541
+ | Most common families | `ecc` ×1,831, `sha256` ×1,013, `rsa` ×796, `sha1` ×577, `md5` ×359, `dsa` ×353 |
542
+ | Run | 2026-10-28, scanner 0.3.1 (latest release of each package) |
535
543
 
536
544
  Every finding is a concrete `file:line` an auditor can open — e.g. Diffie-Hellman
537
545
  in `twisted/conch/ssh/transport.py`, MD5 in `requests/auth.py` (HTTP Digest), and
@@ -710,7 +718,7 @@ jobs:
710
718
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
711
719
  | `exclude` | *(none)* | Comma-separated globs to skip |
712
720
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
713
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
721
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
714
722
 
715
723
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
716
724
  you, which is the same class of problem as an unpinned linter.
@@ -843,7 +851,7 @@ docker compose up --build
843
851
 
844
852
  ```bash
845
853
  pip install -r requirements-dev.txt
846
- pytest -q # 559 tests; in-memory DB, no setup
854
+ pytest -q # 584 tests; in-memory DB, no setup
847
855
  ```
848
856
 
849
857
  Seed a demo account so the dashboard is populated:
@@ -958,6 +966,15 @@ organization — scheduled re-scans with drift alerts, multi-repo/org dashboards
958
966
  SSO, and audit-ready CBOM history for compliance. Those are operational features,
959
967
  not gates on the core detection, which is the part that should always be open.
960
968
 
969
+ ## Citing
970
+
971
+ Every release is archived on Zenodo. To cite QuantumSafe, use
972
+ [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
973
+ resolves to the newest version; v0.3.1 on its own is
974
+ [10.5281/zenodo.23843498](https://doi.org/10.5281/zenodo.23843498). GitHub's
975
+ "Cite this repository" button reads the same details from
976
+ [CITATION.cff](CITATION.cff).
977
+
961
978
  ## License
962
979
 
963
980
  MIT — see [LICENSE](LICENSE).
@@ -7,11 +7,12 @@
7
7
  <img src="https://img.shields.io/pypi/pyversions/quantumsafe-scan?style=flat-square&logo=python&logoColor=white" alt="Python versions">
8
8
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Danny-397/Quantum-Safe-Scan/ci.yml?branch=main&style=flat-square&logo=githubactions&logoColor=white&label=CI" alt="CI status"></a>
9
9
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/tags"><img src="https://img.shields.io/github/v/tag/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github&label=version&color=5b73e8" alt="Latest version"></a>
10
- <a href="https://github.com/Danny-397/Quantum-Safe-Scan/stargazers"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
10
+ <a href="https://github.com/Danny-397/Quantum-Safe-Scan"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
11
11
  <img src="https://img.shields.io/github/last-commit/Danny-397/Quantum-Safe-Scan?style=flat-square&color=555" alt="Last commit">
12
12
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
13
+ <a href="https://doi.org/10.5281/zenodo.23843488"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23843488-5b73e8?style=flat-square" alt="DOI 10.5281/zenodo.23843488"></a>
13
14
  <br>
14
- <img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
15
+ <img src="https://img.shields.io/badge/tests-584%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="584 tests passing">
15
16
  <img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
16
17
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
17
18
  <img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
@@ -59,7 +60,7 @@ solution:
59
60
  | Layer | Module | What it does |
60
61
  |-------|--------|--------------|
61
62
  | **1. Attack** | [`quantum/`](quantum/) | Shor's and Grover's algorithms in **Qiskit**, run on a quantum simulator. At simulator scale Shor factors a small number and reconstructs a toy RSA key — an educational demonstration of *why* RSA/ECC are rated HIGH (not a break of real key sizes). |
62
- | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages** — see [methodology](benchmark/RESULTS.md) and [real-code precision](benchmark/RESULTS-precision.md). |
63
+ | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages**, and **88% recall (95% CI 71–96%) on a held-out random sample of real files with every usage labeled by hand** — see [methodology](benchmark/RESULTS.md), [real-code precision](benchmark/RESULTS-precision.md) and [real-code recall](benchmark/README.md#recall-on-real-code-recall_samplepy). |
63
64
  | **3. Fix** | [`pqc/`](pqc/) | A from-scratch **lattice (LWE) key-encapsulation mechanism** — the math behind CRYSTALS-Kyber / ML-KEM — so the recommended fix is runnable and provable. |
64
65
 
65
66
  The detection layer ships through three surfaces that share **one** engine:
@@ -443,7 +444,13 @@ construction — 50 real quantum-vulnerable API calls (many idiomatic variants
443
444
  per family, 7 languages) that must be detected, plus 50 comment/string decoys
444
445
  that must not be. Latest run: **100% recall, 100% mutation precision**
445
446
  ([RESULTS-seeded.md](benchmark/RESULTS-seeded.md)), enforced by
446
- `tests/test_seeded.py`. Honest limits are documented in
447
+ `tests/test_seeded.py`. Seeded cases only test the patterns someone thought to
448
+ write, so recall is also measured on **real code**: random files from 37 pinned
449
+ PyPI packages, every quantum-vulnerable usage labeled by hand before scanning. The
450
+ first sample found 68%, and its misses drove the fixes; a held-out sample labeled
451
+ afterwards finds **88% (95% CI 71–96%)**
452
+ ([how, and every miss](benchmark/README.md#recall-on-real-code-recall_samplepy)).
453
+ Honest limits are documented in
447
454
  [benchmark/README.md](benchmark/README.md) — these are regression benchmarks, not
448
455
  a claim of perfection on arbitrary code.
449
456
 
@@ -459,7 +466,7 @@ badge from an actual scan — in [docs/EXAMPLES.md](docs/EXAMPLES.md).
459
466
 
460
467
  ### Real-world scan: paramiko (the SSH library)
461
468
 
462
- Run against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
469
+ Run in July 2026 against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
463
470
  — the SSH implementation behind Ansible, Fabric, and much of the Python ecosystem.
464
471
  SSH key exchange leans on RSA, ECDSA, and Diffie-Hellman, all broken by Shor's
465
472
  algorithm, which makes it a textbook "harvest now, decrypt later" target:
@@ -497,9 +504,10 @@ python benchmark/realworld.py
497
504
  |---|---|
498
505
  | Packages scanned | **37** |
499
506
  | Packages with ≥1 finding | **32 (86%)** |
500
- | Python files analyzed | **10,938** |
501
- | Total findings | **5,512** — **4,083 HIGH-risk** |
502
- | Most common families | `ecc` ×1,709, `sha256` ×956, `rsa` ×770, `sha1` ×576, `dsa` ×355, `md5` ×351 |
507
+ | Python files analyzed | **11,275** |
508
+ | Total findings | **5,609** — **4,236 HIGH-risk** |
509
+ | Most common families | `ecc` ×1,831, `sha256` ×1,013, `rsa` ×796, `sha1` ×577, `md5` ×359, `dsa` ×353 |
510
+ | Run | 2026-10-28, scanner 0.3.1 (latest release of each package) |
503
511
 
504
512
  Every finding is a concrete `file:line` an auditor can open — e.g. Diffie-Hellman
505
513
  in `twisted/conch/ssh/transport.py`, MD5 in `requests/auth.py` (HTTP Digest), and
@@ -678,7 +686,7 @@ jobs:
678
686
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
679
687
  | `exclude` | *(none)* | Comma-separated globs to skip |
680
688
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
681
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
689
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
682
690
 
683
691
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
684
692
  you, which is the same class of problem as an unpinned linter.
@@ -811,7 +819,7 @@ docker compose up --build
811
819
 
812
820
  ```bash
813
821
  pip install -r requirements-dev.txt
814
- pytest -q # 559 tests; in-memory DB, no setup
822
+ pytest -q # 584 tests; in-memory DB, no setup
815
823
  ```
816
824
 
817
825
  Seed a demo account so the dashboard is populated:
@@ -926,6 +934,15 @@ organization — scheduled re-scans with drift alerts, multi-repo/org dashboards
926
934
  SSO, and audit-ready CBOM history for compliance. Those are operational features,
927
935
  not gates on the core detection, which is the part that should always be open.
928
936
 
937
+ ## Citing
938
+
939
+ Every release is archived on Zenodo. To cite QuantumSafe, use
940
+ [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
941
+ resolves to the newest version; v0.3.1 on its own is
942
+ [10.5281/zenodo.23843498](https://doi.org/10.5281/zenodo.23843498). GitHub's
943
+ "Cite this repository" button reads the same details from
944
+ [CITATION.cff](CITATION.cff).
945
+
929
946
  ## License
930
947
 
931
948
  MIT — see [LICENSE](LICENSE).
@@ -5,4 +5,4 @@ pyproject.toml) so both the standalone CLI and the Flask backend share one copy
5
5
  of the detection logic.
6
6
  """
7
7
 
8
- __version__ = "0.3.1"
8
+ __version__ = "0.3.2"
@@ -136,19 +136,26 @@ RULES: list[Rule] = [
136
136
  r"\brsa[\s_\-]?4096\b|\b4096\b\s*(?:bit)?\s*rsa\b"),
137
137
  _r("rsa", "RSA", RISK_HIGH,
138
138
  "RSA public-key cryptography is broken by Shor's algorithm.",
139
- r"\bRSA\b|generate_private_key.*rsa|crypto\.generateKeyPair(?:Sync)?\(\s*['\"]rsa['\"]|rsa\.GenerateKey|OpenSSL::PKey::RSA|RSACryptoServiceProvider|openssl_pkey_new|RsaKeyParameters"),
139
+ r"\bRSA\b|generate_private_key.*rsa|crypto\.generateKeyPair(?:Sync)?\(\s*['\"]rsa['\"]|rsa\.GenerateKey|OpenSSL::PKey::RSA|RSACryptoServiceProvider|openssl_pkey_new|RsaKeyParameters"
140
+ # Key classes and modules: RSAKey (paramiko), RSAPrivateKey / RSAPublicKey
141
+ # (cryptography), paramiko.rsakey. Found missing by the recall sample.
142
+ r"|\bRSA(?:Private|Public)?Key"),
140
143
  _r("ecc", "ECDSA", RISK_HIGH,
141
144
  "ECDSA signatures are broken by Shor's algorithm.",
142
- r"\bECDSA\b|ecdsa\b"),
145
+ r"\bECDSA\b|ecdsa\b|\bECDSA(?:Private|Public)?Key"),
143
146
  _r("ecc", "ECDH", RISK_HIGH,
144
147
  "ECDH key exchange is broken by Shor's algorithm.",
145
148
  r"\bECDH\b|ecdh\b"),
146
149
  _r("ecc", "ECC", RISK_HIGH,
147
150
  "Elliptic-curve cryptography is broken by Shor's algorithm.",
148
- r"\bECC\b|elliptic[\s_\-]?curve|EllipticCurve|ec\.generate_private_key|crypto/ecdsa|secp256[rk]1|prime256v1|NIST P-256"),
151
+ r"\bECC\b|elliptic[\s_\-]?curve|EllipticCurve|ec\.generate_private_key|crypto/ecdsa|secp256[rk]1|prime256v1|NIST P-256"
152
+ # Curve25519 / Curve448 in any spelling: X25519PrivateKey, Ed25519Key,
153
+ # import_x25519_private_key, ssh-ed25519. Not preceded by a letter or
154
+ # digit, so an underscore-joined name still counts.
155
+ r"|(?<![a-z0-9])(?:x|ed)(?:25519|448)(?![0-9])|\bEC(?:Private|Public)Key"),
149
156
  _r("dsa", "DSA", RISK_HIGH,
150
157
  "DSA signatures are broken by Shor's algorithm.",
151
- r"\bDSA\b|dsa\.generate_private_key|crypto/dsa"),
158
+ r"\bDSA\b|dsa\.generate_private_key|crypto/dsa|\bDSA(?:Private|Public)?Key|\bDSSKey\b"),
152
159
  _r("dh", "Diffie-Hellman", RISK_HIGH,
153
160
  "Classic Diffie-Hellman key exchange is broken by Shor's algorithm.",
154
161
  r"\bDiffie[\s\-]?Hellman\b|\bDH\b|dh\.generate_parameters|DHParameterSpec|crypto/dh"),
@@ -614,6 +621,86 @@ def _string_arg_scan(orig_lines: list[str], masked_lines: list[str],
614
621
  return findings
615
622
 
616
623
 
624
+ # --------------------------------------------------------------------------- #
625
+ # Identifier literals
626
+ # --------------------------------------------------------------------------- #
627
+ #
628
+ # Some string literals are not prose but the algorithm's own wire name: SSH key
629
+ # and kex types ("ssh-rsa", "rsa-sha2-256", "ecdsa-sha2-nistp256"), JOSE values
630
+ # ("kty": "RSA", "alg": "RS256", "crv": "P-256"), curve names. Masking strings
631
+ # hid every one of them (the recall sample on real code missed paramiko's key
632
+ # negotiation and PyJWT's JWKs this way). A literal counts only when its whole
633
+ # content is one of these identifiers, so a sentence that mentions RSA stays out.
634
+
635
+ _ID_LITERALS: list[tuple[re.Pattern, str]] = [
636
+ (re.compile(r"ssh-rsa(?:-cert-v01@openssh\.com)?|rsa-sha2-(?:256|512)(?:-cert-v01@openssh\.com)?"
637
+ r"|(?i:rsa)|RS(?:256|384|512)|PS(?:256|384|512)|RSA-OAEP(?:-256)?|RSA1_5"), "rsa"),
638
+ (re.compile(r"ecdsa-sha2-nistp(?:256|384|521)(?:-cert-v01@openssh\.com)?|ssh-ed(?:25519|448)(?:-cert-v01@openssh\.com)?"
639
+ r"|(?i:ecdsa|ecdh)|EC|ES(?:256K?|384|512)|EdDSA|(?i:ed25519|ed448|x25519|x448)"
640
+ r"|ECDH-ES(?:\+A(?:128|192|256)KW)?|P-(?:256|384|521)|secp(?:256[rk]1|384r1|521r1)|prime256v1"
641
+ r"|ecdh-sha2-nistp(?:256|384|521)|curve25519-sha256(?:@libssh\.org)?|curve448-sha512"), "ecc"),
642
+ (re.compile(r"ssh-dss|(?i:dsa)"), "dsa"),
643
+ (re.compile(r"diffie-hellman-group[\w-]*|DH|ffdhe(?:2048|3072|4096|6144|8192)"), "dh"),
644
+ (re.compile(r"(?i:md5)|MD5-sess|hmac-md5(?:-96)?"), "md5"),
645
+ (re.compile(r"(?i:sha-?1)|SHA1-sess|hmac-sha1(?:-96)?"), "sha1"),
646
+ ]
647
+ _PY_STRING_PREFIX = re.compile(r"^[rRbBuU]{0,2}(['\"])")
648
+ _QUOTED_ID_RE = re.compile(r"(['\"`])([A-Za-z0-9@._+\-]{2,48})\1")
649
+
650
+
651
+ def _id_literal_family(value: str) -> str | None:
652
+ for pattern, family in _ID_LITERALS:
653
+ if pattern.fullmatch(value):
654
+ return family
655
+ return None
656
+
657
+
658
+ def _id_literal_finding(family: str, rel_path: str, lineno: int, snippet: str) -> Finding:
659
+ algo, risk, why = _ALGO_INFO[family]
660
+ return Finding(rel_path, lineno, algo, risk, why, family, snippet=snippet, confidence="high")
661
+
662
+
663
+ def _id_literal_scan_python(source: str, rel_path: str, lines: list[str]) -> list[Finding]:
664
+ findings: list[Finding] = []
665
+ try:
666
+ for tok in tokenize.generate_tokens(io.StringIO(source).readline):
667
+ if tok.type != tokenize.STRING or not _PY_STRING_PREFIX.match(tok.string):
668
+ continue # f-strings and multi-part tokens are never a bare identifier
669
+ try:
670
+ value = ast.literal_eval(tok.string)
671
+ except (ValueError, SyntaxError):
672
+ continue
673
+ if isinstance(value, bytes):
674
+ value = value.decode("latin-1")
675
+ if not isinstance(value, str) or "\n" in value:
676
+ continue
677
+ family = _id_literal_family(value)
678
+ if family:
679
+ row = tok.start[0]
680
+ snippet = lines[row - 1].strip() if 0 < row <= len(lines) else ""
681
+ findings.append(_id_literal_finding(family, rel_path, row, snippet))
682
+ except (tokenize.TokenError, IndentationError, SyntaxError, ValueError):
683
+ pass
684
+ return findings
685
+
686
+
687
+ def _id_literal_scan_generic(orig_lines: list[str], masked_lines: list[str],
688
+ lang: str, rel_path: str) -> list[Finding]:
689
+ findings: list[Finding] = []
690
+ for idx, orig in enumerate(orig_lines):
691
+ masked = masked_lines[idx] if idx < len(masked_lines) else orig
692
+ if not masked.strip():
693
+ continue # the whole line was comment
694
+ cut = _comment_start(orig, lang)
695
+ for m in _QUOTED_ID_RE.finditer(orig):
696
+ if cut is not None and m.start() >= cut:
697
+ break
698
+ family = _id_literal_family(m.group(2))
699
+ if family:
700
+ findings.append(_id_literal_finding(family, rel_path, idx + 1, orig.strip()))
701
+ return findings
702
+
703
+
617
704
  def _comment_start(line: str, lang: str) -> int | None:
618
705
  """Column where a line comment begins, or None. Used to reject trailing-comment
619
706
  matches without a full re-lex (the protocol tokens are the only consumer)."""
@@ -648,6 +735,8 @@ def _regex_scan(match_lines: list[str], orig_lines: list[str],
648
735
  line = raw.rstrip("\n")
649
736
  if not line.strip() or _is_comment_line(line, lang):
650
737
  continue
738
+ if lang == "python" and _PY_TEST_NAME_RE.match(line):
739
+ continue # "def test_md5_digest(...)" names a test; it selects nothing
651
740
  orig = orig_lines[i - 1].strip() if i - 1 < len(orig_lines) else line.strip()
652
741
  for rule in RULES:
653
742
  if rule.languages and lang not in rule.languages:
@@ -716,6 +805,8 @@ def scan_file(abs_path: str, rel_path: str, mask_strings: bool = True,
716
805
  findings = _regex_scan(match_lines, lines, lang, rel_path)
717
806
  if lang == "python":
718
807
  findings += _ast_scan_python(source, rel_path, lines)
808
+ if mask_strings:
809
+ findings += _id_literal_scan_python(source, rel_path, lines)
719
810
  if taint:
720
811
  # Interprocedural data-flow pass: crypto reached through wrappers.
721
812
  from .taint import taint_scan_python
@@ -724,6 +815,26 @@ def scan_file(abs_path: str, rel_path: str, mask_strings: bool = True,
724
815
  # Recover genuine crypto usages whose algorithm was named inside a
725
816
  # (now-masked) string literal — e.g. getInstance("SHA-1").
726
817
  findings += _string_arg_scan(lines, match_lines, lang, rel_path)
818
+ findings += _id_literal_scan_generic(lines, match_lines, lang, rel_path)
819
+
820
+ # A post-quantum hybrid (ML-KEM-768 + X25519, X25519Kyber768) is the
821
+ # migration target, not exposure: its classical half is there on purpose.
822
+ # Flagging it HIGH would tell users to replace the fix. The TLS scanner
823
+ # already treats X25519MLKEM768 as quantum-safe; the code scanner agrees.
824
+ if findings:
825
+ findings = [
826
+ f for f in findings
827
+ if not (f.family == "ecc" and 0 < f.line_number <= len(lines)
828
+ and _PQ_HYBRID_RE.search(lines[f.line_number - 1]))
829
+ ]
830
+ # Identifier literals in an algorithm-disable list name what is turned OFF
831
+ # (paramiko's disabled_algorithms), the same mitigation OP_NO_* flags are.
832
+ if findings:
833
+ findings = [
834
+ f for f in findings
835
+ if not (0 < f.line_number <= len(lines)
836
+ and _DISABLE_RE.search(lines[f.line_number - 1]))
837
+ ]
727
838
 
728
839
  # Honor inline suppressions: a line containing "quantumsafe: ignore".
729
840
  if findings:
@@ -734,6 +845,10 @@ def scan_file(abs_path: str, rel_path: str, mask_strings: bool = True,
734
845
  return _dedupe(findings)
735
846
 
736
847
 
848
+ _PY_TEST_NAME_RE = re.compile(r"\s*(?:async\s+def|def|class)\s+(?:test_?|Test)\w*\s*[(:]")
849
+ _PQ_HYBRID_RE = re.compile(r"ml[-_]?kem|kyber", re.IGNORECASE)
850
+ _DISABLE_RE = re.compile(r"\bdisabled?_(?:algorithms|algos|ciphers|kex|keys|macs)\b", re.IGNORECASE)
851
+
737
852
  # Inline suppression marker, e.g. key = rsa.generate(...) # quantumsafe: ignore
738
853
  _SUPPRESS_RE = re.compile(r"quantumsafe:\s*ignore", re.IGNORECASE)
739
854
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quantumsafe-scan"
7
- version = "0.3.1"
7
+ version = "0.3.2"
8
8
  description = "Scan codebases and dependencies for quantum-vulnerable cryptography and generate a NIST-aligned migration plan (SARIF + CycloneDX CBOM)."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantumsafe-scan
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Scan codebases and dependencies for quantum-vulnerable cryptography and generate a NIST-aligned migration plan (SARIF + CycloneDX CBOM).
5
5
  Author: QuantumSafe
6
6
  License: MIT
@@ -39,11 +39,12 @@ Dynamic: license-file
39
39
  <img src="https://img.shields.io/pypi/pyversions/quantumsafe-scan?style=flat-square&logo=python&logoColor=white" alt="Python versions">
40
40
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Danny-397/Quantum-Safe-Scan/ci.yml?branch=main&style=flat-square&logo=githubactions&logoColor=white&label=CI" alt="CI status"></a>
41
41
  <a href="https://github.com/Danny-397/Quantum-Safe-Scan/tags"><img src="https://img.shields.io/github/v/tag/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github&label=version&color=5b73e8" alt="Latest version"></a>
42
- <a href="https://github.com/Danny-397/Quantum-Safe-Scan/stargazers"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
42
+ <a href="https://github.com/Danny-397/Quantum-Safe-Scan"><img src="https://img.shields.io/github/stars/Danny-397/Quantum-Safe-Scan?style=flat-square&logo=github" alt="Stars"></a>
43
43
  <img src="https://img.shields.io/github/last-commit/Danny-397/Quantum-Safe-Scan?style=flat-square&color=555" alt="Last commit">
44
44
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
45
+ <a href="https://doi.org/10.5281/zenodo.23843488"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23843488-5b73e8?style=flat-square" alt="DOI 10.5281/zenodo.23843488"></a>
45
46
  <br>
46
- <img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
47
+ <img src="https://img.shields.io/badge/tests-584%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="584 tests passing">
47
48
  <img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
48
49
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
49
50
  <img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
@@ -91,7 +92,7 @@ solution:
91
92
  | Layer | Module | What it does |
92
93
  |-------|--------|--------------|
93
94
  | **1. Attack** | [`quantum/`](quantum/) | Shor's and Grover's algorithms in **Qiskit**, run on a quantum simulator. At simulator scale Shor factors a small number and reconstructs a toy RSA key — an educational demonstration of *why* RSA/ECC are rated HIGH (not a break of real key sizes). |
94
- | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages** — see [methodology](benchmark/RESULTS.md) and [real-code precision](benchmark/RESULTS-precision.md). |
95
+ | **2. Detection** | [`cli/`](cli/) | A hybrid **AST + regex** static-analysis engine over 11 languages, with cross-language usage-awareness, **dependency + lockfile scanning**, **reachability ranking**, and **call-site-specific fixes**, that scores risk and produces a NIST-aligned migration plan. **100% precision on the labeled [benchmark](benchmark/)** (18 files), **100% recall on 50 seeded cases**, and **93% precision (95% CI 86–97%) on a random, hand-labeled sample of 100 findings in real PyPI packages**, and **88% recall (95% CI 71–96%) on a held-out random sample of real files with every usage labeled by hand** — see [methodology](benchmark/RESULTS.md), [real-code precision](benchmark/RESULTS-precision.md) and [real-code recall](benchmark/README.md#recall-on-real-code-recall_samplepy). |
95
96
  | **3. Fix** | [`pqc/`](pqc/) | A from-scratch **lattice (LWE) key-encapsulation mechanism** — the math behind CRYSTALS-Kyber / ML-KEM — so the recommended fix is runnable and provable. |
96
97
 
97
98
  The detection layer ships through three surfaces that share **one** engine:
@@ -475,7 +476,13 @@ construction — 50 real quantum-vulnerable API calls (many idiomatic variants
475
476
  per family, 7 languages) that must be detected, plus 50 comment/string decoys
476
477
  that must not be. Latest run: **100% recall, 100% mutation precision**
477
478
  ([RESULTS-seeded.md](benchmark/RESULTS-seeded.md)), enforced by
478
- `tests/test_seeded.py`. Honest limits are documented in
479
+ `tests/test_seeded.py`. Seeded cases only test the patterns someone thought to
480
+ write, so recall is also measured on **real code**: random files from 37 pinned
481
+ PyPI packages, every quantum-vulnerable usage labeled by hand before scanning. The
482
+ first sample found 68%, and its misses drove the fixes; a held-out sample labeled
483
+ afterwards finds **88% (95% CI 71–96%)**
484
+ ([how, and every miss](benchmark/README.md#recall-on-real-code-recall_samplepy)).
485
+ Honest limits are documented in
479
486
  [benchmark/README.md](benchmark/README.md) — these are regression benchmarks, not
480
487
  a claim of perfection on arbitrary code.
481
488
 
@@ -491,7 +498,7 @@ badge from an actual scan — in [docs/EXAMPLES.md](docs/EXAMPLES.md).
491
498
 
492
499
  ### Real-world scan: paramiko (the SSH library)
493
500
 
494
- Run against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
501
+ Run in July 2026 against a shallow clone of [`paramiko/paramiko`](https://github.com/paramiko/paramiko)
495
502
  — the SSH implementation behind Ansible, Fabric, and much of the Python ecosystem.
496
503
  SSH key exchange leans on RSA, ECDSA, and Diffie-Hellman, all broken by Shor's
497
504
  algorithm, which makes it a textbook "harvest now, decrypt later" target:
@@ -529,9 +536,10 @@ python benchmark/realworld.py
529
536
  |---|---|
530
537
  | Packages scanned | **37** |
531
538
  | Packages with ≥1 finding | **32 (86%)** |
532
- | Python files analyzed | **10,938** |
533
- | Total findings | **5,512** — **4,083 HIGH-risk** |
534
- | Most common families | `ecc` ×1,709, `sha256` ×956, `rsa` ×770, `sha1` ×576, `dsa` ×355, `md5` ×351 |
539
+ | Python files analyzed | **11,275** |
540
+ | Total findings | **5,609** — **4,236 HIGH-risk** |
541
+ | Most common families | `ecc` ×1,831, `sha256` ×1,013, `rsa` ×796, `sha1` ×577, `md5` ×359, `dsa` ×353 |
542
+ | Run | 2026-10-28, scanner 0.3.1 (latest release of each package) |
535
543
 
536
544
  Every finding is a concrete `file:line` an auditor can open — e.g. Diffie-Hellman
537
545
  in `twisted/conch/ssh/transport.py`, MD5 in `requests/auth.py` (HTTP Digest), and
@@ -710,7 +718,7 @@ jobs:
710
718
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
711
719
  | `exclude` | *(none)* | Comma-separated globs to skip |
712
720
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
713
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
721
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
714
722
 
715
723
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
716
724
  you, which is the same class of problem as an unpinned linter.
@@ -843,7 +851,7 @@ docker compose up --build
843
851
 
844
852
  ```bash
845
853
  pip install -r requirements-dev.txt
846
- pytest -q # 559 tests; in-memory DB, no setup
854
+ pytest -q # 584 tests; in-memory DB, no setup
847
855
  ```
848
856
 
849
857
  Seed a demo account so the dashboard is populated:
@@ -958,6 +966,15 @@ organization — scheduled re-scans with drift alerts, multi-repo/org dashboards
958
966
  SSO, and audit-ready CBOM history for compliance. Those are operational features,
959
967
  not gates on the core detection, which is the part that should always be open.
960
968
 
969
+ ## Citing
970
+
971
+ Every release is archived on Zenodo. To cite QuantumSafe, use
972
+ [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
973
+ resolves to the newest version; v0.3.1 on its own is
974
+ [10.5281/zenodo.23843498](https://doi.org/10.5281/zenodo.23843498). GitHub's
975
+ "Cite this repository" button reads the same details from
976
+ [CITATION.cff](CITATION.cff).
977
+
961
978
  ## License
962
979
 
963
980
  MIT — see [LICENSE](LICENSE).
@@ -309,3 +309,79 @@ def test_tls_old_selections_are_still_found(tmp_path, line, label):
309
309
  _write(tmp_path, "tls.py", "import ssl\n" + line)
310
310
  algos = {f.algorithm for f in scan_path(str(tmp_path)) if f.family == "tls_old"}
311
311
  assert label in algos
312
+
313
+
314
+ # ---- Recall fixes from the real-code recall sample (benchmark/RESULTS-recall*.md) ----
315
+
316
+ def _families_by_line(tmp_path, name, content):
317
+ _write(tmp_path, name, content)
318
+ out = {}
319
+ for f in scan_path(str(tmp_path)):
320
+ out.setdefault(f.line_number, set()).add(f.family)
321
+ return out
322
+
323
+
324
+ @pytest.mark.parametrize("line, family", [
325
+ ("from paramiko.rsakey import RSAKey", "rsa"),
326
+ ("k = RSAKey.from_private_key_file(path)", "rsa"),
327
+ ("def load(k: RSAPrivateKey): ...", "rsa"),
328
+ ("from paramiko.ecdsakey import ECDSAKey", "ecc"),
329
+ ("k = Ed25519Key.from_private_key_file(path)", "ecc"),
330
+ ("from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey", "ecc"),
331
+ ("k = DH.import_x25519_private_key(data)", "ecc"),
332
+ ("k = DSSKey(filename=path)", "dsa"),
333
+ ])
334
+ def test_key_classes_and_curve25519_are_found(tmp_path, line, family):
335
+ assert family in _families_by_line(tmp_path, "k.py", line + "\n").get(1, set())
336
+
337
+
338
+ @pytest.mark.parametrize("line, family", [
339
+ ('if keytype == "ssh-rsa":', "rsa"),
340
+ ('opts.key_types = ("rsa-sha2-512",)', "rsa"),
341
+ ('jwk = {"kty": "RSA", "n": n}', "rsa"),
342
+ ('token = jwt.encode(payload, key, algorithm="ES256")', "ecc"),
343
+ ('key = ECC.generate(curve="P-256")', "ecc"),
344
+ ('kex = "diffie-hellman-group14-sha1"', "dh"),
345
+ ('opts.digests = ("hmac-md5-96",)', "md5"),
346
+ ])
347
+ def test_identifier_literals_are_found(tmp_path, line, family):
348
+ assert family in _families_by_line(tmp_path, "s.py", line + "\n").get(1, set())
349
+
350
+
351
+ @pytest.mark.parametrize("line", [
352
+ 'log.info("falling back to RSA for this host")', # prose: not a bare identifier
353
+ 'raise ValueError("ECDSA keys are not supported")',
354
+ 'name = "rsa.key"', # a filename, not the algorithm
355
+ ])
356
+ def test_prose_strings_stay_out(tmp_path, line):
357
+ assert not _families_by_line(tmp_path, "p.py", line + "\n")
358
+
359
+
360
+ def test_identifier_literals_in_other_languages(tmp_path):
361
+ lines = _families_by_line(tmp_path, "a.js",
362
+ 'const alg = "RS256";\n// const old = "ssh-rsa";\n')
363
+ assert "rsa" in lines.get(1, set())
364
+ assert 2 not in lines
365
+
366
+
367
+ @pytest.mark.parametrize("line", [
368
+ "suite = HPKE(KEM.MLKEM768_X25519)",
369
+ "sk = MLKEM768X25519PrivateKey(mlkem_sk, x25519_sk)",
370
+ 'group = "X25519MLKEM768"',
371
+ ])
372
+ def test_pq_hybrids_are_not_flagged_as_ecc(tmp_path, line):
373
+ assert "ecc" not in _families_by_line(tmp_path, "h.py", line + "\n").get(1, set())
374
+
375
+
376
+ def test_disabled_algorithm_lists_are_not_findings(tmp_path):
377
+ lines = _families_by_line(
378
+ tmp_path, "t.py",
379
+ 'Transport(sock, disabled_algorithms={"keys": ["rsa-sha2-512"], "macs": ["hmac-md5"]})\n')
380
+ assert not lines
381
+
382
+
383
+ def test_test_names_are_not_findings(tmp_path):
384
+ lines = _families_by_line(tmp_path, "test_x.py",
385
+ "def test_sign_ed25519_key():\n pass\n"
386
+ "class TestMD5Digest:\n pass\n")
387
+ assert not lines
@@ -5,7 +5,9 @@ Each test pins one fix:
5
5
  * a zip that would expand past the caps is refused before anything is written;
6
6
  * oversized uploads are rejected at the door with a JSON 413;
7
7
  * rate limits are per visitor (behind Render's proxy they were site-wide);
8
- * the app refuses to start on Render with the public default secret.
8
+ * the app refuses to start on Render with the public default secret;
9
+ * passwords past bcrypt's 72-byte limit still register and log in (bcrypt 5
10
+ raises on them where bcrypt 4 truncated).
9
11
  """
10
12
 
11
13
  import io
@@ -113,3 +115,10 @@ def test_refuses_to_start_on_render_with_the_default_secret(monkeypatch):
113
115
  monkeypatch.setenv("RENDER", "true")
114
116
  with pytest.raises(RuntimeError, match="must be set in production"):
115
117
  create_app(Default)
118
+
119
+
120
+ def test_password_longer_than_72_bytes_registers_and_logs_in(client):
121
+ password = "é" * 50 # 100 bytes of UTF-8
122
+ email = _register(client, password=password)
123
+ login = client.post("/api/v1/auth/login", json={"email": email, "password": password})
124
+ assert login.status_code == 200