quantumsafe-scan 0.3.3__tar.gz → 0.4.0__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.3/quantumsafe_scan.egg-info → quantumsafe_scan-0.4.0}/PKG-INFO +6 -6
  2. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/README.md +5 -5
  3. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/__init__.py +1 -1
  4. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/cli.py +8 -2
  5. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/dependencies.py +19 -0
  6. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/recommender.py +11 -0
  7. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/remediation.py +10 -0
  8. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/reporter.py +121 -3
  9. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/scanner.py +39 -7
  10. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/pyproject.toml +1 -1
  11. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0/quantumsafe_scan.egg-info}/PKG-INFO +6 -6
  12. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_remediation.py +9 -1
  13. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_scanner.py +50 -0
  14. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/LICENSE +0 -0
  15. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/callgraph.py +0 -0
  16. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/certchain.py +0 -0
  17. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/diff.py +0 -0
  18. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/horizon.py +0 -0
  19. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/origins.py +0 -0
  20. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/reachability.py +0 -0
  21. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/scorer.py +0 -0
  22. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/taint.py +0 -0
  23. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/cli/tlsscan.py +0 -0
  24. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/quantumsafe_scan.egg-info/SOURCES.txt +0 -0
  25. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/quantumsafe_scan.egg-info/dependency_links.txt +0 -0
  26. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/quantumsafe_scan.egg-info/entry_points.txt +0 -0
  27. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/quantumsafe_scan.egg-info/requires.txt +0 -0
  28. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/quantumsafe_scan.egg-info/top_level.txt +0 -0
  29. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/setup.cfg +0 -0
  30. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_api.py +0 -0
  31. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_benchmark.py +0 -0
  32. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_callgraph.py +0 -0
  33. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_certchain.py +0 -0
  34. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_conformance.py +0 -0
  35. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_cors.py +0 -0
  36. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_diff.py +0 -0
  37. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_features.py +0 -0
  38. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_horizon.py +0 -0
  39. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_origins.py +0 -0
  40. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_pqc.py +0 -0
  41. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_quantum.py +0 -0
  42. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_schema.py +0 -0
  43. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_scorer.py +0 -0
  44. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_security_hardening.py +0 -0
  45. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_seeded.py +0 -0
  46. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/tests/test_taint.py +0 -0
  47. {quantumsafe_scan-0.3.3 → quantumsafe_scan-0.4.0}/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.3
3
+ Version: 0.4.0
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
@@ -42,7 +42,7 @@ Dynamic: license-file
42
42
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
43
43
  <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>
44
44
  <br>
45
- <img src="https://img.shields.io/badge/tests-587%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="587 tests passing">
45
+ <img src="https://img.shields.io/badge/tests-600%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="600 tests passing">
46
46
  <a href="benchmark/RESULTS-precision-current.md"><img src="https://img.shields.io/badge/real--code%20precision-95%25-3fb950?style=flat-square" alt="95% precision on a random sample of real-code findings"></a>
47
47
  <a href="benchmark/README.md#recall-on-real-code-recall_samplepy"><img src="https://img.shields.io/badge/held--out%20recall-88%25-3fb950?style=flat-square" alt="88% recall on held-out real code"></a>
48
48
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
@@ -718,7 +718,7 @@ jobs:
718
718
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
719
719
  | `exclude` | *(none)* | Comma-separated globs to skip |
720
720
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
721
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
721
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.3` |
722
722
 
723
723
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
724
724
  you, which is the same class of problem as an unpinned linter.
@@ -851,7 +851,7 @@ docker compose up --build
851
851
 
852
852
  ```bash
853
853
  pip install -r requirements-dev.txt
854
- pytest -q # 587 tests; in-memory DB, no setup
854
+ pytest -q # 600 tests; in-memory DB, no setup
855
855
  ```
856
856
 
857
857
  Seed a demo account so the dashboard is populated:
@@ -970,8 +970,8 @@ not gates on the core detection, which is the part that should always be open.
970
970
 
971
971
  Every release is archived on Zenodo. To cite QuantumSafe, use
972
972
  [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
973
- resolves to the newest version; v0.3.2 on its own is
974
- [10.5281/zenodo.24267519](https://doi.org/10.5281/zenodo.24267519). GitHub's
973
+ resolves to the newest version; v0.3.3 on its own is
974
+ [10.5281/zenodo.24410766](https://doi.org/10.5281/zenodo.24410766). GitHub's
975
975
  "Cite this repository" button reads the same details from
976
976
  [CITATION.cff](CITATION.cff).
977
977
 
@@ -10,7 +10,7 @@
10
10
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
11
11
  <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>
12
12
  <br>
13
- <img src="https://img.shields.io/badge/tests-587%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="587 tests passing">
13
+ <img src="https://img.shields.io/badge/tests-600%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="600 tests passing">
14
14
  <a href="benchmark/RESULTS-precision-current.md"><img src="https://img.shields.io/badge/real--code%20precision-95%25-3fb950?style=flat-square" alt="95% precision on a random sample of real-code findings"></a>
15
15
  <a href="benchmark/README.md#recall-on-real-code-recall_samplepy"><img src="https://img.shields.io/badge/held--out%20recall-88%25-3fb950?style=flat-square" alt="88% recall on held-out real code"></a>
16
16
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
@@ -686,7 +686,7 @@ jobs:
686
686
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
687
687
  | `exclude` | *(none)* | Comma-separated globs to skip |
688
688
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
689
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
689
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.3` |
690
690
 
691
691
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
692
692
  you, which is the same class of problem as an unpinned linter.
@@ -819,7 +819,7 @@ docker compose up --build
819
819
 
820
820
  ```bash
821
821
  pip install -r requirements-dev.txt
822
- pytest -q # 587 tests; in-memory DB, no setup
822
+ pytest -q # 600 tests; in-memory DB, no setup
823
823
  ```
824
824
 
825
825
  Seed a demo account so the dashboard is populated:
@@ -938,8 +938,8 @@ not gates on the core detection, which is the part that should always be open.
938
938
 
939
939
  Every release is archived on Zenodo. To cite QuantumSafe, use
940
940
  [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
941
- resolves to the newest version; v0.3.2 on its own is
942
- [10.5281/zenodo.24267519](https://doi.org/10.5281/zenodo.24267519). GitHub's
941
+ resolves to the newest version; v0.3.3 on its own is
942
+ [10.5281/zenodo.24410766](https://doi.org/10.5281/zenodo.24410766). GitHub's
943
943
  "Cite this repository" button reads the same details from
944
944
  [CITATION.cff](CITATION.cff).
945
945
 
@@ -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.3"
8
+ __version__ = "0.4.0"
@@ -87,6 +87,7 @@ def cmd_scan(args: argparse.Namespace) -> int:
87
87
  scan_deps = not args.no_deps
88
88
  reachability = not args.no_rank
89
89
  endpoint = None
90
+ coverage = None
90
91
  try:
91
92
  if args.url:
92
93
  from .tlsscan import scan_url
@@ -99,12 +100,16 @@ def cmd_scan(args: argparse.Namespace) -> int:
99
100
  endpoint["third_party"] = origin_summary
100
101
  elif args.repo:
101
102
  target = args.repo
103
+ coverage = {}
102
104
  findings = scan_repo(args.repo, exclude=exclude, taint=args.taint,
103
- scan_deps=scan_deps, reachability=reachability)
105
+ scan_deps=scan_deps, reachability=reachability,
106
+ coverage=coverage)
104
107
  else:
105
108
  target = os.path.abspath(args.path)
109
+ coverage = {}
106
110
  findings = scan_path(args.path, exclude=exclude, taint=args.taint,
107
- scan_deps=scan_deps, reachability=reachability)
111
+ scan_deps=scan_deps, reachability=reachability,
112
+ coverage=coverage)
108
113
  except (FileNotFoundError, ValueError, RuntimeError, OSError) as exc:
109
114
  print(f"Error: {exc}", file=sys.stderr)
110
115
  return 1
@@ -114,6 +119,7 @@ def cmd_scan(args: argparse.Namespace) -> int:
114
119
  endpoint=endpoint,
115
120
  secrecy_years=getattr(args, "secrecy_years", None),
116
121
  crqc_years=getattr(args, "crqc_years", None),
122
+ coverage=coverage,
117
123
  )
118
124
 
119
125
  if args.output:
@@ -55,6 +55,14 @@ KNOWN_CRYPTO_PACKAGES: dict[str, dict[str, dict]] = {
55
55
  "python-jose": {_PKG: ["rsa", "ecc"]},
56
56
  "jwcrypto": {_PKG: ["rsa", "ecc"]},
57
57
  "oscrypto": {_PKG: ["rsa", "ecc", "dsa"]},
58
+ # Bitcoin / Ethereum wallet libraries: secp256k1 keys.
59
+ "coincurve": {_PKG: ["wallet"]},
60
+ "bitcoinlib": {_PKG: ["wallet"]},
61
+ "python-bitcoinlib": {_PKG: ["wallet"]},
62
+ "bit": {_PKG: ["wallet"]},
63
+ "eth-account": {_PKG: ["wallet"]},
64
+ "eth-keys": {_PKG: ["wallet"]},
65
+ "web3": {_PKG: ["wallet"]},
58
66
  },
59
67
  "npm": {
60
68
  "node-forge": {_PKG: ["rsa", "ecc", "dsa"]},
@@ -63,9 +71,20 @@ KNOWN_CRYPTO_PACKAGES: dict[str, dict[str, dict]] = {
63
71
  "jsrsasign": {_PKG: ["rsa", "ecc"]},
64
72
  "jsonwebtoken": {_PKG: ["rsa", "ecc"]},
65
73
  "sshpk": {_PKG: ["rsa", "ecc", "dsa"]},
74
+ "bitcoinjs-lib": {_PKG: ["wallet"]},
75
+ "ecpair": {_PKG: ["wallet"]},
76
+ "tiny-secp256k1": {_PKG: ["wallet"]},
77
+ "secp256k1": {_PKG: ["wallet"]},
78
+ "@noble/secp256k1": {_PKG: ["wallet"]},
79
+ "@noble/curves": {_PKG: ["wallet"]},
80
+ "ethers": {_PKG: ["wallet"]},
81
+ "web3": {_PKG: ["wallet"]},
82
+ "viem": {_PKG: ["wallet"]},
66
83
  },
67
84
  "golang": {
68
85
  "golang.org/x/crypto": {_PKG: ["ecc"]},
86
+ "github.com/btcsuite/btcd/btcec/v2": {_PKG: ["wallet"]},
87
+ "github.com/ethereum/go-ethereum": {_PKG: ["wallet"]},
69
88
  },
70
89
  "maven": {
71
90
  "bcprov-jdk18on": {_PKG: ["rsa", "ecc", "dsa", "dh"], "group": "org.bouncycastle"},
@@ -42,6 +42,17 @@ RECOMMENDATIONS: dict[str, Recommendation] = {
42
42
  "signatures with ML-DSA (Dilithium)."
43
43
  ),
44
44
  ),
45
+ "wallet": Recommendation(
46
+ replacement="A post-quantum output type once Bitcoin / Ethereum adopt one (BIP-360 is a draft); until then, never reuse an address",
47
+ nist_reference="FIPS 204 (ML-DSA), FIPS 205 (SLH-DSA): candidates, not yet in either protocol",
48
+ complexity="High",
49
+ detail=(
50
+ "Wallet keys are secp256k1 elliptic-curve keys, which Shor's algorithm "
51
+ "breaks once the public key is visible: on-chain after the first spend "
52
+ "(Taproot and pay-to-public-key show it immediately). The signature "
53
+ "scheme is fixed by the protocol, so a wallet cannot switch on its own."
54
+ ),
55
+ ),
45
56
  "dsa": Recommendation(
46
57
  replacement="CRYSTALS-Dilithium (ML-DSA)",
47
58
  nist_reference="FIPS 204 (ML-DSA), FIPS 205 (SLH-DSA / SPHINCS+)",
@@ -168,6 +168,16 @@ def remediate(family: str, language: str = "", snippet: str = "") -> Fix:
168
168
  guidance="ML-DSA (FIPS 204) is not broken by Shor's algorithm, so "
169
169
  "the signature cannot be forged by a quantum attacker.",
170
170
  )
171
+ if family == "wallet":
172
+ return Fix(
173
+ action="Keep public keys off-chain: a fresh address for every receive, "
174
+ "change to a new address, never reuse one that has spent.",
175
+ drop_in=False,
176
+ guidance="The signature scheme is set by the Bitcoin / Ethereum protocol, "
177
+ "so wallet code cannot swap in ML-DSA by itself. Track BIP-360 "
178
+ "(post-quantum Bitcoin outputs, draft) and move funds once a "
179
+ "post-quantum output type is active.",
180
+ )
171
181
  if family in _ASYM:
172
182
  target, role = _ASYM[family]
173
183
  return Fix(
@@ -27,6 +27,7 @@ def build_report(
27
27
  endpoint: dict | None = None,
28
28
  secrecy_years: float | None = None,
29
29
  crqc_years: float | None = None,
30
+ coverage: dict | None = None,
30
31
  ) -> dict:
31
32
  """Assemble the canonical report structure from real findings.
32
33
 
@@ -64,12 +65,88 @@ def build_report(
64
65
  }
65
66
  if endpoint:
66
67
  report["endpoint"] = endpoint
68
+ report["cnsa2"] = _cnsa2_section(findings)
69
+ if coverage is not None:
70
+ report["coverage"] = _coverage_section(coverage)
67
71
  if secrecy_years is not None:
68
72
  from .horizon import assess
69
73
  report["horizon"] = assess(findings, secrecy_years, crqc_years).to_dict()
70
74
  return report
71
75
 
72
76
 
77
+ _NO_FINDINGS_NOTE = (
78
+ "No findings does not mean quantum-safe. Static scanning sees the code in "
79
+ "this target, not the services it talks to or crypto chosen at runtime."
80
+ )
81
+
82
+
83
+ def _coverage_section(cov: dict) -> dict:
84
+ """What the scan inspected, what it skipped, and what it cannot see.
85
+
86
+ A clean report is easy to misread as "certified quantum-safe"; this states
87
+ the limits beside the result, built from what the scan actually did.
88
+ """
89
+ passes = cov.get("passes", {})
90
+ not_inspected = [
91
+ "Compiled binaries, and files in languages the scanner does not support",
92
+ "Crypto chosen at runtime (config-selected algorithms, plugins, reflection)",
93
+ "Live services: the TLS, SSH and VPN settings actually negotiated "
94
+ "(run --url for a live TLS check)",
95
+ "Key management: cloud KMS, HSMs, TPMs and stored keys",
96
+ ]
97
+ if passes.get("dependencies"):
98
+ not_inspected.append("Indirect dependencies that no lockfile pins")
99
+ else:
100
+ not_inspected.append("Dependencies (dependency scanning was off)")
101
+ if not passes.get("taint"):
102
+ not_inspected.append("Crypto reached through wrapper functions "
103
+ "(--taint, Python only, was off)")
104
+ languages = cov.get("languages", {})
105
+ return {
106
+ "files_scanned": sum(languages.values()),
107
+ "languages": dict(sorted(languages.items(), key=lambda kv: -kv[1])),
108
+ "skipped": cov.get("skipped", {}),
109
+ "passes": passes,
110
+ "not_inspected": not_inspected,
111
+ "note": _NO_FINDINGS_NOTE,
112
+ }
113
+
114
+
115
+ # CNSA 2.0 allows only ML-KEM-1024, ML-DSA-87, LMS/XMSS, AES-256 and SHA-384/512.
116
+ # Every family the scanner flags is outside that list; the PQC families pass only
117
+ # at the largest parameter sets, which the scanner does not tell apart.
118
+ _CNSA2_CHECK = frozenset({"pqc_hybrid", "pqc_signature"})
119
+ CNSA2_NOTE = (
120
+ "NSA's CNSA 2.0 suite allows only ML-KEM-1024, ML-DSA-87, LMS/XMSS, AES-256 and "
121
+ "SHA-384/512. New US national security system purchases must use it from "
122
+ "1 January 2027 (NSA advisory, December 2026)."
123
+ )
124
+
125
+
126
+ def _cnsa2_section(findings: list[Finding]) -> dict:
127
+ """Which findings fall outside NSA's CNSA 2.0 algorithm suite."""
128
+ out = [f for f in findings if f.family not in _CNSA2_CHECK]
129
+ check = [f for f in findings if f.family in _CNSA2_CHECK]
130
+ return {
131
+ "not_allowed": len(out),
132
+ "algorithms": sorted({f.algorithm for f in out}),
133
+ "check_parameters": len(check),
134
+ "note": CNSA2_NOTE,
135
+ }
136
+
137
+
138
+ def _cnsa2_text(c: dict) -> str:
139
+ text = (f"CNSA 2.0: {c['not_allowed']} finding(s) use algorithms it does not allow"
140
+ + (f" ({', '.join(c['algorithms'])})" if c["algorithms"] else ""))
141
+ if c["check_parameters"]:
142
+ text += f"; {c['check_parameters']} post-quantum finding(s) pass only at ML-KEM-1024 / ML-DSA-87"
143
+ return text + "."
144
+
145
+
146
+ def _skipped_text(skipped: dict) -> str:
147
+ return ", ".join(f"{n} {k.replace('_', ' ')}" for k, n in skipped.items()) or "none"
148
+
149
+
73
150
  # --------------------------------------------------------------------------- #
74
151
  # Terminal
75
152
  # --------------------------------------------------------------------------- #
@@ -107,6 +184,7 @@ def print_terminal(report: dict) -> None:
107
184
 
108
185
  if not report["findings"]:
109
186
  console.print("[green]No quantum-vulnerable cryptography detected.[/green]")
187
+ _print_coverage(console, report.get("coverage"))
110
188
  return
111
189
 
112
190
  table = Table(show_lines=False, header_style="bold")
@@ -126,7 +204,22 @@ def print_terminal(report: dict) -> None:
126
204
  f["recommendation"],
127
205
  )
128
206
  console.print(table)
207
+ if report.get("cnsa2"):
208
+ console.print(f"\n[bold]{_cnsa2_text(report['cnsa2'])}[/bold]\n[dim]{report['cnsa2']['note']}[/dim]")
129
209
  _print_horizon(console, report.get("horizon"))
210
+ _print_coverage(console, report.get("coverage"))
211
+
212
+
213
+ def _print_coverage(console, c: dict | None) -> None:
214
+ if not c:
215
+ return
216
+ langs = ", ".join(f"{k} {n}" for k, n in c["languages"].items()) or "none"
217
+ console.print(f"\n[bold]Coverage[/bold]: {c['files_scanned']} files scanned ({langs}); "
218
+ f"skipped: {_skipped_text(c['skipped'])}")
219
+ console.print("Not inspected:")
220
+ for item in c["not_inspected"]:
221
+ console.print(f" - {item}")
222
+ console.print(f"[dim]{c['note']}[/dim]")
130
223
 
131
224
 
132
225
  def _sarif_location(f: dict) -> dict:
@@ -346,6 +439,14 @@ def _print_plain(report: dict) -> None:
346
439
  for f in report["findings"]:
347
440
  print(f"{f['risk_level']:<6} {_location(f)}:{f['line_number']} "
348
441
  f"{f['algorithm']} -> {f['recommendation']}")
442
+ if report["findings"] and report.get("cnsa2"):
443
+ print(_cnsa2_text(report["cnsa2"]))
444
+ c = report.get("coverage")
445
+ if c:
446
+ print(f"Coverage: {c['files_scanned']} files scanned; skipped: {_skipped_text(c['skipped'])}")
447
+ for item in c["not_inspected"]:
448
+ print(f" not inspected: {item}")
449
+ print(c["note"])
349
450
 
350
451
 
351
452
  # --------------------------------------------------------------------------- #
@@ -363,7 +464,7 @@ def to_json(report: dict) -> str:
363
464
 
364
465
 
365
466
  _CBOM_PRIMITIVE = {
366
- "rsa": "pke", "ecc": "signature", "dsa": "signature", "dh": "key-agree",
467
+ "rsa": "pke", "ecc": "signature", "wallet": "signature", "dsa": "signature", "dh": "key-agree",
367
468
  "md5": "hash", "sha1": "hash", "sha256": "hash",
368
469
  "3des": "block-cipher", "rc4": "stream-cipher", "aes128": "block-cipher",
369
470
  "tls_old": "other", "tls12": "other",
@@ -600,6 +701,22 @@ def to_html(report: dict) -> str:
600
701
  rows_html = "".join(rows) or '<tr><td colspan="6" class="muted">No quantum-vulnerable cryptography detected.</td></tr>'
601
702
 
602
703
  s = report["summary"]
704
+ n = report.get("cnsa2")
705
+ cnsa2_html = (f'<p>{e(_cnsa2_text(n))}<br><span class="muted">{e(n["note"])}</span></p>'
706
+ if n and report["findings"] else "")
707
+ c = report.get("coverage")
708
+ coverage_html = ""
709
+ if c:
710
+ langs = ", ".join(f"{e(k)} {n}" for k, n in c["languages"].items()) or "none"
711
+ items = "".join(f"<li>{e(i)}</li>" for i in c["not_inspected"])
712
+ coverage_html = f"""
713
+ <div class="card">
714
+ <h2>Coverage</h2>
715
+ <p>{c['files_scanned']} files scanned ({langs}). Skipped: {e(_skipped_text(c['skipped']))}.</p>
716
+ <p class="muted">Not inspected:</p>
717
+ <ul>{items}</ul>
718
+ <p class="muted">{e(c['note'])}</p>
719
+ </div>"""
603
720
  return f"""<!DOCTYPE html>
604
721
  <html lang="en">
605
722
  <head>
@@ -613,6 +730,7 @@ def to_html(report: dict) -> str:
613
730
  .num {{ text-align:right; }}
614
731
  .muted {{ color:#7a7a8c; font-size:12px; }}
615
732
  h1 {{ font-size:20px; margin:0 0 4px; }}
733
+ h2 {{ font-size:16px; margin:0 0 8px; }}
616
734
  .score {{ font-size:56px; font-weight:700; color:{accent}; font-family:"SFMono-Regular",ui-monospace,Consolas,monospace; }}
617
735
  .card {{ background:#12121a; border:1px solid #23232f; border-radius:10px; padding:24px; margin-bottom:24px; }}
618
736
  .pills span {{ display:inline-block; margin-right:16px; font-family:ui-monospace,monospace; }}
@@ -647,8 +765,8 @@ def to_html(report: dict) -> str:
647
765
  <tr><th>File</th><th>Line</th><th>Algorithm</th><th>Risk</th><th>Why</th><th>Recommendation</th></tr>
648
766
  </thead>
649
767
  <tbody>{rows_html}</tbody>
650
- </table>
651
- </div>
768
+ </table>{cnsa2_html}
769
+ </div>{coverage_html}
652
770
  <div class="footer">
653
771
  Based on NIST Post-Quantum Cryptography Standards (FIPS 203, 204, 205).
654
772
  This report is for awareness and is not a substitute for a professional cryptographic audit.
@@ -153,6 +153,16 @@ RULES: list[Rule] = [
153
153
  # import_x25519_private_key, ssh-ed25519. Not preceded by a letter or
154
154
  # digit, so an underscore-joined name still counts.
155
155
  r"|(?<![a-z0-9])(?:x|ed)(?:25519|448)(?![0-9])|\bEC(?:Private|Public)Key"),
156
+ # Bitcoin / Ethereum wallet keys (secp256k1). Library identifiers, since a
157
+ # wallet rarely names the curve: coincurve, eth_account, bitcoinlib,
158
+ # python-bitcoinlib, bitcoinjs ECPair, ethers / web3 accounts, noble, btcec.
159
+ _r("wallet", "secp256k1 (wallet keys)", RISK_HIGH,
160
+ "Bitcoin and Ethereum keys are secp256k1 elliptic-curve keys; Shor's algorithm "
161
+ "recovers the private key from a public key that has appeared on-chain.",
162
+ r"\bcoincurve\b|\beth_account\b|\beth_keys\b|\bbitcoinlib\b|\bbitcoin\.(?:wallet|core\.key)\b"
163
+ r"|\bECPair(?:Factory)?\b|\bethers\.Wallet\b|\bWallet\.(?:createRandom|fromMnemonic|fromPhrase)\b"
164
+ r"|\bweb3\.eth\.accounts?\.(?:create|sign\w*|privateKeyToAccount)\b|\bAccount\.(?:create|from_key|sign_\w+)\b"
165
+ r"|\bprivateKeyToAccount\b|\bsecp\.(?:getPublicKey|sign|utils)\b|\bbtcec\b|go-ethereum/crypto"),
156
166
  _r("dsa", "DSA", RISK_HIGH,
157
167
  "DSA signatures are broken by Shor's algorithm.",
158
168
  r"\bDSA\b|dsa\.generate_private_key|crypto/dsa|\bDSA(?:Private|Public)?Key|\bDSSKey\b"),
@@ -541,6 +551,8 @@ _ALGO_INFO: dict[str, tuple[str, str, str]] = {
541
551
  "rsa": ("RSA", RISK_HIGH, "RSA public-key cryptography is broken by Shor's algorithm."),
542
552
  "ecc": ("ECC", RISK_HIGH, "Elliptic-curve cryptography is broken by Shor's algorithm."),
543
553
  "dsa": ("DSA", RISK_HIGH, "DSA signatures are broken by Shor's algorithm."),
554
+ "wallet": ("secp256k1 (wallet keys)", RISK_HIGH,
555
+ "Bitcoin and Ethereum keys are secp256k1 elliptic-curve keys, broken by Shor's algorithm."),
544
556
  "dh": ("Diffie-Hellman", RISK_HIGH, "Classic Diffie-Hellman key exchange is broken by Shor's algorithm."),
545
557
  "md5": ("MD5", RISK_HIGH, "MD5 is collision-broken and weakened by Grover's algorithm."),
546
558
  "sha1": ("SHA-1", RISK_HIGH, "SHA-1 is collision-broken and weakened by Grover's algorithm."),
@@ -772,23 +784,36 @@ def _dedupe(findings: list[Finding]) -> list[Finding]:
772
784
  # --------------------------------------------------------------------------- #
773
785
 
774
786
 
787
+ def _count(stats: dict | None, group: str, key: str) -> None:
788
+ if stats is not None:
789
+ bucket = stats.setdefault(group, {})
790
+ bucket[key] = bucket.get(key, 0) + 1
791
+
792
+
775
793
  def scan_file(abs_path: str, rel_path: str, mask_strings: bool = True,
776
- taint: bool = False) -> list[Finding]:
794
+ taint: bool = False, stats: dict | None = None) -> list[Finding]:
795
+ """Scan one file. ``stats``, when given, records whether the file was
796
+ scanned (per language) or skipped (per reason) for the report's coverage."""
777
797
  ext = os.path.splitext(abs_path)[1].lower()
778
798
  lang = EXT_TO_LANG.get(ext)
779
799
  if lang is None:
800
+ _count(stats, "skipped", "unsupported_type")
780
801
  return []
781
802
  try:
782
803
  if os.path.getsize(abs_path) > _MAX_FILE_BYTES:
804
+ _count(stats, "skipped", "too_large")
783
805
  return []
784
806
  with open(abs_path, "r", encoding="utf-8", errors="ignore") as fh:
785
807
  source = fh.read()
786
808
  except (OSError, UnicodeError):
809
+ _count(stats, "skipped", "unreadable")
787
810
  return []
788
811
 
789
812
  lines = source.splitlines()
790
813
  if _looks_minified(os.path.basename(abs_path), lines):
814
+ _count(stats, "skipped", "minified")
791
815
  return []
816
+ _count(stats, "languages", lang)
792
817
 
793
818
  # Usage-awareness: mask string/comment *content* so the regex engine ignores
794
819
  # crypto keywords that live in prose. Python uses precise tokenizer masking
@@ -862,7 +887,8 @@ def _is_excluded(rel_path: str, patterns: list[str] | None) -> bool:
862
887
 
863
888
  def scan_path(path: str, exclude: list[str] | None = None,
864
889
  mask_strings: bool = True, taint: bool = False,
865
- scan_deps: bool = False, reachability: bool = False) -> list[Finding]:
890
+ scan_deps: bool = False, reachability: bool = False,
891
+ coverage: dict | None = None) -> list[Finding]:
866
892
  """Recursively scan a local directory (or single file) for vulnerabilities.
867
893
 
868
894
  ``exclude`` is an optional list of glob patterns (matched against the path
@@ -876,15 +902,19 @@ def scan_path(path: str, exclude: list[str] | None = None,
876
902
  quantum-vulnerable crypto libraries, producing dependency-origin findings for
877
903
  the CBOM. ``reachability`` (default off) labels each source finding as
878
904
  ``reachable`` / ``test/example`` / ``unreferenced`` so reports can rank
879
- exploitable findings above noise.
905
+ exploitable findings above noise. ``coverage``, when given, is filled with
906
+ what was scanned, skipped and run (see ``reporter.build_report``).
880
907
  """
881
908
  path = os.path.abspath(path)
909
+ if coverage is not None:
910
+ coverage.update(languages={}, skipped={}, passes={
911
+ "dependencies": scan_deps, "taint": taint, "reachability": reachability})
882
912
  if not os.path.exists(path):
883
913
  raise FileNotFoundError(f"Path does not exist: {path}")
884
914
 
885
915
  findings: list[Finding] = []
886
916
  if os.path.isfile(path):
887
- findings = scan_file(path, os.path.basename(path), mask_strings, taint)
917
+ findings = scan_file(path, os.path.basename(path), mask_strings, taint, coverage)
888
918
  else:
889
919
  for root, dirs, files in os.walk(path):
890
920
  dirs[:] = [d for d in dirs if d not in _SKIP_DIRS]
@@ -892,8 +922,9 @@ def scan_path(path: str, exclude: list[str] | None = None,
892
922
  abs_path = os.path.join(root, name)
893
923
  rel_path = os.path.relpath(abs_path, path).replace(os.sep, "/")
894
924
  if _is_excluded(rel_path, exclude):
925
+ _count(coverage, "skipped", "excluded")
895
926
  continue
896
- findings.extend(scan_file(abs_path, rel_path, mask_strings, taint))
927
+ findings.extend(scan_file(abs_path, rel_path, mask_strings, taint, coverage))
897
928
 
898
929
  if taint and os.path.isdir(path):
899
930
  # Whole-program pass: crypto reached through a wrapper in *another* file.
@@ -931,7 +962,8 @@ def _validate_repo_url(url: str) -> str:
931
962
 
932
963
 
933
964
  def scan_repo(url: str, exclude: list[str] | None = None, taint: bool = False,
934
- scan_deps: bool = False, reachability: bool = False) -> list[Finding]:
965
+ scan_deps: bool = False, reachability: bool = False,
966
+ coverage: dict | None = None) -> list[Finding]:
935
967
  """Shallow-clone a public GitHub repo to a temp dir, scan it, then clean up."""
936
968
  url = _validate_repo_url(url)
937
969
  if shutil.which("git") is None:
@@ -946,6 +978,6 @@ def scan_repo(url: str, exclude: list[str] | None = None, taint: bool = False,
946
978
  if result.returncode != 0:
947
979
  raise RuntimeError(f"Failed to clone repository: {result.stderr.strip()}")
948
980
  return scan_path(tmp, exclude=exclude, taint=taint, scan_deps=scan_deps,
949
- reachability=reachability)
981
+ reachability=reachability, coverage=coverage)
950
982
  finally:
951
983
  shutil.rmtree(tmp, ignore_errors=True)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quantumsafe-scan"
7
- version = "0.3.3"
7
+ version = "0.4.0"
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.3
3
+ Version: 0.4.0
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
@@ -42,7 +42,7 @@ Dynamic: license-file
42
42
  <img src="https://img.shields.io/github/license/Danny-397/Quantum-Safe-Scan?style=flat-square&color=3fb950" alt="License: MIT">
43
43
  <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>
44
44
  <br>
45
- <img src="https://img.shields.io/badge/tests-587%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="587 tests passing">
45
+ <img src="https://img.shields.io/badge/tests-600%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="600 tests passing">
46
46
  <a href="benchmark/RESULTS-precision-current.md"><img src="https://img.shields.io/badge/real--code%20precision-95%25-3fb950?style=flat-square" alt="95% precision on a random sample of real-code findings"></a>
47
47
  <a href="benchmark/README.md#recall-on-real-code-recall_samplepy"><img src="https://img.shields.io/badge/held--out%20recall-88%25-3fb950?style=flat-square" alt="88% recall on held-out real code"></a>
48
48
  <img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
@@ -718,7 +718,7 @@ jobs:
718
718
  | `output` | `quantumsafe.sarif` | Where to write the SARIF report |
719
719
  | `exclude` | *(none)* | Comma-separated globs to skip |
720
720
  | `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
721
- | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.2` |
721
+ | `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.3` |
722
722
 
723
723
  Pin to a released tag rather than `@main` once one exists — `@main` moves under
724
724
  you, which is the same class of problem as an unpinned linter.
@@ -851,7 +851,7 @@ docker compose up --build
851
851
 
852
852
  ```bash
853
853
  pip install -r requirements-dev.txt
854
- pytest -q # 587 tests; in-memory DB, no setup
854
+ pytest -q # 600 tests; in-memory DB, no setup
855
855
  ```
856
856
 
857
857
  Seed a demo account so the dashboard is populated:
@@ -970,8 +970,8 @@ not gates on the core detection, which is the part that should always be open.
970
970
 
971
971
  Every release is archived on Zenodo. To cite QuantumSafe, use
972
972
  [10.5281/zenodo.23843488](https://doi.org/10.5281/zenodo.23843488), which always
973
- resolves to the newest version; v0.3.2 on its own is
974
- [10.5281/zenodo.24267519](https://doi.org/10.5281/zenodo.24267519). GitHub's
973
+ resolves to the newest version; v0.3.3 on its own is
974
+ [10.5281/zenodo.24410766](https://doi.org/10.5281/zenodo.24410766). GitHub's
975
975
  "Cite this repository" button reads the same details from
976
976
  [CITATION.cff](CITATION.cff).
977
977
 
@@ -20,7 +20,9 @@ from quantumsafe.remediation import Fix, remediate
20
20
  # Families with no like-for-like replacement: these need a PQC migration.
21
21
  ASYMMETRIC = {"rsa", "ecc", "dsa", "dh"}
22
22
  # Families where a direct swap exists.
23
- DROP_IN = set(RECOMMENDATIONS) - ASYMMETRIC
23
+ # Wallet keys can't migrate in code: the protocol fixes the signature scheme.
24
+ PROTOCOL_BOUND = {"wallet"}
25
+ DROP_IN = set(RECOMMENDATIONS) - ASYMMETRIC - PROTOCOL_BOUND
24
26
 
25
27
  LANGUAGES = ["python", "javascript", "java", "go", "", "cobol"]
26
28
 
@@ -147,3 +149,9 @@ def test_to_dict_round_trips_every_field():
147
149
  assert set(d) == {"action", "drop_in", "before", "after", "guidance", "library"}
148
150
  assert d["drop_in"] is False
149
151
  assert d["action"] == fix.action
152
+
153
+
154
+ def test_wallet_fix_is_not_drop_in_and_names_the_protocol():
155
+ fix = remediate("wallet", "javascript")
156
+ assert fix.drop_in is False
157
+ assert "protocol" in fix.guidance and "BIP-360" in fix.guidance
@@ -385,3 +385,53 @@ def test_test_names_are_not_findings(tmp_path):
385
385
  "def test_sign_ed25519_key():\n pass\n"
386
386
  "class TestMD5Digest:\n pass\n")
387
387
  assert not lines
388
+
389
+
390
+ def test_coverage_counts_scanned_and_skipped(tmp_path):
391
+ from cli.reporter import build_report, to_html
392
+ from cli.scanner import scan_path
393
+ (tmp_path / "a.py").write_text("from cryptography.hazmat.primitives.asymmetric import rsa\n")
394
+ (tmp_path / "b.js").write_text("const x = 1;\n")
395
+ (tmp_path / "notes.txt").write_text("RSA\n")
396
+ (tmp_path / "skip.py").write_text("import hashlib\n")
397
+ cov = {}
398
+ findings = scan_path(str(tmp_path), exclude=["skip.py"], coverage=cov)
399
+ c = build_report(findings, "t", coverage=cov)["coverage"]
400
+ assert c["files_scanned"] == 2
401
+ assert c["languages"] == {"python": 1, "javascript": 1}
402
+ assert c["skipped"] == {"unsupported_type": 1, "excluded": 1}
403
+ assert any("Dependencies" in i for i in c["not_inspected"]) # deps off by default
404
+ assert "does not mean quantum-safe" in c["note"]
405
+ assert "Coverage" in to_html(build_report(findings, "t", coverage=cov))
406
+ assert "coverage" not in build_report(findings, "t") # opt-in, API unchanged
407
+
408
+
409
+ def test_cnsa2_section_counts_disallowed_algorithms(tmp_path):
410
+ from cli.reporter import build_report, to_html
411
+ from cli.scanner import scan_path
412
+ (tmp_path / "a.py").write_text("from cryptography.hazmat.primitives.asymmetric import rsa\n"
413
+ "import hashlib; hashlib.md5(b'')\n")
414
+ findings = scan_path(str(tmp_path))
415
+ n = build_report(findings, "t")["cnsa2"]
416
+ assert n["not_allowed"] == len(findings) > 0
417
+ assert any("RSA" in a for a in n["algorithms"]) and "MD5" in n["algorithms"]
418
+ assert n["check_parameters"] == 0
419
+ assert "ML-KEM-1024" in n["note"]
420
+ assert "CNSA 2.0:" in to_html(build_report(findings, "t"))
421
+ assert build_report([], "t")["cnsa2"]["not_allowed"] == 0
422
+
423
+
424
+ def test_wallet_libraries_are_flagged(tmp_path):
425
+ from cli.scanner import scan_path
426
+ (tmp_path / "w.py").write_text("from coincurve import PrivateKey\nfrom eth_account import Account\nacct = Account.create()\n")
427
+ (tmp_path / "w.js").write_text("const { ECPairFactory } = require('ecpair');\nconst w = ethers.Wallet.createRandom();\n")
428
+ (tmp_path / "plain.py").write_text("wallet = {'balance': 0}\naccount = load()\n")
429
+ found = {(f.file_path, f.line_number) for f in scan_path(str(tmp_path)) if f.family == "wallet"}
430
+ assert found == {("w.py", 1), ("w.py", 2), ("w.py", 3), ("w.js", 1), ("w.js", 2)}
431
+
432
+
433
+ def test_wallet_dependencies_are_flagged(tmp_path):
434
+ from cli.scanner import scan_path
435
+ (tmp_path / "package.json").write_text('{"dependencies": {"bitcoinjs-lib": "^6.1.0", "left-pad": "1.0.0"}}')
436
+ deps = [f for f in scan_path(str(tmp_path), scan_deps=True) if f.origin == "dependency"]
437
+ assert [(f.component, f.family) for f in deps] == [("bitcoinjs-lib", "wallet")]