quantumsafe-scan 0.3.0__tar.gz → 0.3.1__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.
- {quantumsafe_scan-0.3.0/quantumsafe_scan.egg-info → quantumsafe_scan-0.3.1}/PKG-INFO +5 -5
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/README.md +4 -4
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/__init__.py +1 -1
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/scanner.py +8 -2
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/pyproject.toml +1 -1
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1/quantumsafe_scan.egg-info}/PKG-INFO +5 -5
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/SOURCES.txt +1 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_scanner.py +27 -0
- quantumsafe_scan-0.3.1/tests/test_security_hardening.py +115 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/LICENSE +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/callgraph.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/certchain.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/cli.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/dependencies.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/diff.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/horizon.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/origins.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/reachability.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/recommender.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/remediation.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/reporter.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/scorer.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/taint.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/cli/tlsscan.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/dependency_links.txt +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/entry_points.txt +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/requires.txt +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/top_level.txt +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/setup.cfg +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_api.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_benchmark.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_callgraph.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_certchain.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_conformance.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_cors.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_diff.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_features.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_horizon.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_origins.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_pqc.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_quantum.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_remediation.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_schema.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_scorer.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_seeded.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/tests/test_taint.py +0 -0
- {quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/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
|
+
Version: 0.3.1
|
|
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
|
|
@@ -43,7 +43,7 @@ Dynamic: license-file
|
|
|
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
45
|
<br>
|
|
46
|
-
<img src="https://img.shields.io/badge/tests-
|
|
46
|
+
<img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
|
|
47
47
|
<img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
|
|
48
48
|
<img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
|
|
49
49
|
<img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
|
|
@@ -91,7 +91,7 @@ solution:
|
|
|
91
91
|
| Layer | Module | What it does |
|
|
92
92
|
|-------|--------|--------------|
|
|
93
93
|
| **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)
|
|
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
95
|
| **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
96
|
|
|
97
97
|
The detection layer ships through three surfaces that share **one** engine:
|
|
@@ -710,7 +710,7 @@ jobs:
|
|
|
710
710
|
| `output` | `quantumsafe.sarif` | Where to write the SARIF report |
|
|
711
711
|
| `exclude` | *(none)* | Comma-separated globs to skip |
|
|
712
712
|
| `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
|
|
713
|
-
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.
|
|
713
|
+
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
|
|
714
714
|
|
|
715
715
|
Pin to a released tag rather than `@main` once one exists — `@main` moves under
|
|
716
716
|
you, which is the same class of problem as an unpinned linter.
|
|
@@ -843,7 +843,7 @@ docker compose up --build
|
|
|
843
843
|
|
|
844
844
|
```bash
|
|
845
845
|
pip install -r requirements-dev.txt
|
|
846
|
-
pytest -q #
|
|
846
|
+
pytest -q # 559 tests; in-memory DB, no setup
|
|
847
847
|
```
|
|
848
848
|
|
|
849
849
|
Seed a demo account so the dashboard is populated:
|
|
@@ -11,7 +11,7 @@
|
|
|
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
13
|
<br>
|
|
14
|
-
<img src="https://img.shields.io/badge/tests-
|
|
14
|
+
<img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
|
|
15
15
|
<img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
|
|
16
16
|
<img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
|
|
17
17
|
<img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
|
|
@@ -59,7 +59,7 @@ solution:
|
|
|
59
59
|
| Layer | Module | What it does |
|
|
60
60
|
|-------|--------|--------------|
|
|
61
61
|
| **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)
|
|
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
63
|
| **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
64
|
|
|
65
65
|
The detection layer ships through three surfaces that share **one** engine:
|
|
@@ -678,7 +678,7 @@ jobs:
|
|
|
678
678
|
| `output` | `quantumsafe.sarif` | Where to write the SARIF report |
|
|
679
679
|
| `exclude` | *(none)* | Comma-separated globs to skip |
|
|
680
680
|
| `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
|
|
681
|
-
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.
|
|
681
|
+
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
|
|
682
682
|
|
|
683
683
|
Pin to a released tag rather than `@main` once one exists — `@main` moves under
|
|
684
684
|
you, which is the same class of problem as an unpinned linter.
|
|
@@ -811,7 +811,7 @@ docker compose up --build
|
|
|
811
811
|
|
|
812
812
|
```bash
|
|
813
813
|
pip install -r requirements-dev.txt
|
|
814
|
-
pytest -q #
|
|
814
|
+
pytest -q # 559 tests; in-memory DB, no setup
|
|
815
815
|
```
|
|
816
816
|
|
|
817
817
|
Seed a demo account so the dashboard is populated:
|
|
@@ -160,12 +160,18 @@ RULES: list[Rule] = [
|
|
|
160
160
|
r"\bSHA[\s\-_]?1\b|hashlib\.sha1|sha1\(|sha1_file|crypto\.createHash\(\s*['\"]sha1['\"]|MessageDigest\.getInstance\(\s*['\"]SHA-?1['\"]|Digest::SHA1"),
|
|
161
161
|
|
|
162
162
|
# ---- MEDIUM ----
|
|
163
|
+
# The bare protocol names must start their own token: inside an identifier
|
|
164
|
+
# they are almost always a flag that turns the protocol OFF (OP_NO_SSLv3,
|
|
165
|
+
# OP_NO_TLSv1, _OP_NO_SSLv2_OR_SSLv3), which is the mitigation, not exposure.
|
|
166
|
+
# A random sample of real-world findings showed every such hit was a false
|
|
167
|
+
# positive (benchmark/RESULTS-precision.md). Selectors keep explicit forms.
|
|
163
168
|
_r("tls_old", "TLS 1.0", RISK_MEDIUM,
|
|
164
169
|
"TLS 1.0 is deprecated and uses quantum-vulnerable key exchange.",
|
|
165
|
-
r"TLSv1(?:\.0)
|
|
170
|
+
r"(?<!\w)(?:TLSv1(?:\.0)?|SSLv3)\b|PROTOCOL_(?:TLSv1|SSLv3)\b|(?<!NO_)TLS1_0\b"
|
|
171
|
+
r"|(?:TLSv1|SSLv3)_method\b"),
|
|
166
172
|
_r("tls_old", "TLS 1.1", RISK_MEDIUM,
|
|
167
173
|
"TLS 1.1 is deprecated and uses quantum-vulnerable key exchange.",
|
|
168
|
-
r"TLSv1
|
|
174
|
+
r"(?<!\w)TLSv1(?:\.1|_1)\b|PROTOCOL_TLSv1_1\b|(?<!NO_)TLS1_1\b|TLSv1_1_method\b"),
|
|
169
175
|
_r("3des", "3DES / Triple DES", RISK_MEDIUM,
|
|
170
176
|
"3DES is deprecated; Grover's algorithm halves its effective strength.",
|
|
171
177
|
r"\b3DES\b|Triple[\s_\-]?DES\b|DESede|DES3|TripleDES|des_ede3"),
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantumsafe-scan"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.1"
|
|
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
|
+
Version: 0.3.1
|
|
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
|
|
@@ -43,7 +43,7 @@ Dynamic: license-file
|
|
|
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
45
|
<br>
|
|
46
|
-
<img src="https://img.shields.io/badge/tests-
|
|
46
|
+
<img src="https://img.shields.io/badge/tests-559%20passing-3fb950?style=flat-square&logo=pytest&logoColor=white" alt="559 tests passing">
|
|
47
47
|
<img src="https://img.shields.io/badge/benchmark-100%25%20precision-3fb950?style=flat-square" alt="100% precision on benchmark">
|
|
48
48
|
<img src="https://img.shields.io/badge/SARIF%202.1.0-schema--validated-3fb950?style=flat-square" alt="SARIF schema-validated">
|
|
49
49
|
<img src="https://img.shields.io/badge/NIST-FIPS%20203%2F204%2F205-5b73e8?style=flat-square" alt="NIST FIPS 203/204/205">
|
|
@@ -91,7 +91,7 @@ solution:
|
|
|
91
91
|
| Layer | Module | What it does |
|
|
92
92
|
|-------|--------|--------------|
|
|
93
93
|
| **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)
|
|
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
95
|
| **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
96
|
|
|
97
97
|
The detection layer ships through three surfaces that share **one** engine:
|
|
@@ -710,7 +710,7 @@ jobs:
|
|
|
710
710
|
| `output` | `quantumsafe.sarif` | Where to write the SARIF report |
|
|
711
711
|
| `exclude` | *(none)* | Comma-separated globs to skip |
|
|
712
712
|
| `fail-on-high` | `"false"` | Exit non-zero if any HIGH finding is present |
|
|
713
|
-
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.
|
|
713
|
+
| `version` | *(latest)* | Pin `quantumsafe-scan`, e.g. `0.3.1` |
|
|
714
714
|
|
|
715
715
|
Pin to a released tag rather than `@main` once one exists — `@main` moves under
|
|
716
716
|
you, which is the same class of problem as an unpinned linter.
|
|
@@ -843,7 +843,7 @@ docker compose up --build
|
|
|
843
843
|
|
|
844
844
|
```bash
|
|
845
845
|
pip install -r requirements-dev.txt
|
|
846
|
-
pytest -q #
|
|
846
|
+
pytest -q # 559 tests; in-memory DB, no setup
|
|
847
847
|
```
|
|
848
848
|
|
|
849
849
|
Seed a demo account so the dashboard is populated:
|
|
@@ -282,3 +282,30 @@ def test_repo_url_validation_rejects_bad_urls(bad_url):
|
|
|
282
282
|
|
|
283
283
|
def test_repo_url_validation_accepts_good_url():
|
|
284
284
|
assert _validate_repo_url("https://github.com/org/app") == "https://github.com/org/app"
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# ---- TLS: disable flags are the mitigation, not exposure -------------------
|
|
288
|
+
# Every tls_old finding in a random sample of real-world findings was one of
|
|
289
|
+
# these (benchmark/RESULTS-precision.md): OP_NO_* flags that turn the old
|
|
290
|
+
# protocol off. They must stay silent, and real selections must still fire.
|
|
291
|
+
|
|
292
|
+
@pytest.mark.parametrize("line", [
|
|
293
|
+
"ctx.options |= ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1\n",
|
|
294
|
+
'OP_NO_SSLv3 = getattr(_ssl, "OP_NO_SSLv3", 0)\n',
|
|
295
|
+
" ssl.TLSVersion.TLSv1_2: _OP_NO_SSLv2_OR_SSLv3 | _OP_NO_TLSv1_3,\n",
|
|
296
|
+
])
|
|
297
|
+
def test_tls_disable_flags_are_not_findings(tmp_path, line):
|
|
298
|
+
_write(tmp_path, "tls.py", "import ssl\n" + line)
|
|
299
|
+
assert not [f for f in scan_path(str(tmp_path)) if f.family == "tls_old"]
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@pytest.mark.parametrize("line, label", [
|
|
303
|
+
("ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)\n", "TLS 1.0"),
|
|
304
|
+
("ctx = SSL.Context(SSL.SSLv3_METHOD)\n", "TLS 1.0"),
|
|
305
|
+
("ctx.minimum_version = ssl.TLSVersion.TLSv1\n", "TLS 1.0"),
|
|
306
|
+
("ctx.minimum_version = ssl.TLSVersion.TLSv1_1\n", "TLS 1.1"),
|
|
307
|
+
])
|
|
308
|
+
def test_tls_old_selections_are_still_found(tmp_path, line, label):
|
|
309
|
+
_write(tmp_path, "tls.py", "import ssl\n" + line)
|
|
310
|
+
algos = {f.algorithm for f in scan_path(str(tmp_path)) if f.family == "tls_old"}
|
|
311
|
+
assert label in algos
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Regression tests for the 2026-10-26 security review of the backend.
|
|
2
|
+
|
|
3
|
+
Each test pins one fix:
|
|
4
|
+
* reset links are single-use (they were valid for their full hour, reusable);
|
|
5
|
+
* a zip that would expand past the caps is refused before anything is written;
|
|
6
|
+
* oversized uploads are rejected at the door with a JSON 413;
|
|
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.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import io
|
|
12
|
+
import re
|
|
13
|
+
import uuid
|
|
14
|
+
import zipfile
|
|
15
|
+
|
|
16
|
+
import auth
|
|
17
|
+
import pytest
|
|
18
|
+
import scanner_service
|
|
19
|
+
from app import create_app
|
|
20
|
+
from config import DEV_SECRET, Config
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _register(client, password="password123"):
|
|
24
|
+
email = f"user-{uuid.uuid4().hex[:8]}@test.com"
|
|
25
|
+
client.post("/api/v1/auth/register",
|
|
26
|
+
json={"email": email, "password": password, "accept_terms": True})
|
|
27
|
+
return email
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _reset_token(client, monkeypatch, email):
|
|
31
|
+
sent = []
|
|
32
|
+
monkeypatch.setattr(auth, "send_email", lambda subject, to, body: sent.append(body))
|
|
33
|
+
client.post("/api/v1/auth/forgot", json={"email": email})
|
|
34
|
+
return re.search(r"reset=(\S+)", sent[0]).group(1)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_reset_link_works_once(client, monkeypatch):
|
|
38
|
+
email = _register(client)
|
|
39
|
+
token = _reset_token(client, monkeypatch, email)
|
|
40
|
+
|
|
41
|
+
first = client.post("/api/v1/auth/reset", json={"token": token, "password": "new-password-1"})
|
|
42
|
+
assert first.status_code == 200
|
|
43
|
+
again = client.post("/api/v1/auth/reset", json={"token": token, "password": "new-password-2"})
|
|
44
|
+
assert again.status_code == 400
|
|
45
|
+
|
|
46
|
+
login = client.post("/api/v1/auth/login", json={"email": email, "password": "new-password-1"})
|
|
47
|
+
assert login.status_code == 200
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_old_style_reset_token_is_rejected(client, app):
|
|
51
|
+
"""A token carrying only the user id (the old format) must not verify."""
|
|
52
|
+
_register(client)
|
|
53
|
+
with app.app_context():
|
|
54
|
+
legacy = auth._serializer().dumps(1, salt=auth.RESET_SALT)
|
|
55
|
+
resp = client.post("/api/v1/auth/reset", json={"token": legacy, "password": "new-password-1"})
|
|
56
|
+
assert resp.status_code == 400
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _zip(files):
|
|
60
|
+
buf = io.BytesIO()
|
|
61
|
+
with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
62
|
+
for name, data in files.items():
|
|
63
|
+
zf.writestr(name, data)
|
|
64
|
+
return buf.getvalue()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_zip_that_expands_past_the_cap_is_refused(tmp_path, monkeypatch):
|
|
68
|
+
monkeypatch.setattr(scanner_service, "_MAX_EXTRACTED_BYTES", 1_000)
|
|
69
|
+
path = tmp_path / "bomb.zip"
|
|
70
|
+
path.write_bytes(_zip({"a.py": b"0" * 5_000})) # compresses to ~30 bytes
|
|
71
|
+
with pytest.raises(ValueError, match="expands past"):
|
|
72
|
+
scanner_service._safe_extract(str(path), str(tmp_path / "out"))
|
|
73
|
+
assert not (tmp_path / "out" / "a.py").exists()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_zip_with_too_many_files_is_refused(tmp_path, monkeypatch):
|
|
77
|
+
monkeypatch.setattr(scanner_service, "_MAX_ARCHIVE_FILES", 2)
|
|
78
|
+
path = tmp_path / "many.zip"
|
|
79
|
+
path.write_bytes(_zip({f"f{i}.py": b"x = 1\n" for i in range(3)}))
|
|
80
|
+
with pytest.raises(ValueError, match="more than"):
|
|
81
|
+
scanner_service._safe_extract(str(path), str(tmp_path / "out"))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_oversized_upload_gets_json_413(app):
|
|
85
|
+
app.config["MAX_CONTENT_LENGTH"] = 1_000
|
|
86
|
+
resp = app.test_client().post(
|
|
87
|
+
"/api/v1/scan", data={"file": (io.BytesIO(b"0" * 5_000), "big.zip")},
|
|
88
|
+
content_type="multipart/form-data")
|
|
89
|
+
assert resp.status_code == 413
|
|
90
|
+
assert "25 MB" in resp.get_json()["error"]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_rate_limits_are_per_visitor():
|
|
94
|
+
application = create_app(Config)
|
|
95
|
+
application.config["RATELIMIT_ENABLED"] = True
|
|
96
|
+
client = application.test_client()
|
|
97
|
+
a = {"CF-Connecting-IP": f"198.51.100.{uuid.uuid4().int % 250 + 1}"}
|
|
98
|
+
b = {"CF-Connecting-IP": "203.0.113.77"}
|
|
99
|
+
body = {"email": "nobody@test.com", "password": "wrong-password"}
|
|
100
|
+
|
|
101
|
+
codes = [client.post("/api/v1/auth/login", json=body, headers=a).status_code
|
|
102
|
+
for _ in range(21)]
|
|
103
|
+
assert codes[-1] == 429, "the 21st login from one visitor should be limited"
|
|
104
|
+
assert client.post("/api/v1/auth/login", json=body, headers=b).status_code == 401, (
|
|
105
|
+
"a different visitor must not inherit the first one's limit")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_refuses_to_start_on_render_with_the_default_secret(monkeypatch):
|
|
109
|
+
class Default(Config):
|
|
110
|
+
SECRET_KEY = DEV_SECRET
|
|
111
|
+
JWT_SECRET_KEY = DEV_SECRET
|
|
112
|
+
|
|
113
|
+
monkeypatch.setenv("RENDER", "true")
|
|
114
|
+
with pytest.raises(RuntimeError, match="must be set in production"):
|
|
115
|
+
create_app(Default)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{quantumsafe_scan-0.3.0 → quantumsafe_scan-0.3.1}/quantumsafe_scan.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|