# PQ Shift test results

## Fixture

```
Planted 103 | found 103 | missed 0
Decoys 17 | false alarms 0
Already post-quantum 7 | recognised 7
Not checked 2 | reported 2

Ship gate: PASS (found >= 95%, 0 false alarms, all positives, all not-checked)
```

## Notes

- The fixture is a fictional company monorepo (`fixture/harbor`, 103 planted items, 17 decoys, 7 post-quantum positives) written by a
  separate agent from the rule table alone, before it saw the scanner. Its answer key was not edited after the first run.
- The first blind run found 98 of 103. The 5 misses were 3 scanner bugs (files with `.mod`, `.csproj`, `.ovpn` extensions were not read; a
  Maven version on the same line as its artifact was missed; a list of only hybrid groups was reported as hybrid instead of "no classic
  fallback"). The scanner was fixed, not the key; the line above is the run after those fixes.
- Run it yourself: `python tests/run_fixture.py` (from `pqshift-fixture.zip` plus `pqshift.py`).

## Real code

Checked 2026-12-03 on 9 published packages, downloaded from their registries: jose 5.9.6 (JavaScript, npm), jsonwebtoken 9.0.2 (JavaScript, npm), node-forge 1.3.1 (JavaScript, npm), ssh2 1.16.0 (JavaScript, npm), paramiko 3.5.0 (Python, PyPI), PyJWT 2.10.1 (Python, PyPI), python-jose 3.3.0 (Python, PyPI), nimbus-jose-jwt (sources jar) (Java, Maven Central), golang.org/x/crypto 0.31.0 (Go, the Go module proxy).
Command: `python pqshift.py scan PACKAGE --include-vendored --include-build`. A seeded random sample of the findings above `info` was read by hand, line by line.

| Run | Files | Findings | Sample (seed) | Correct |
|---|---|---|---|---|
| First run, before any fix | 1,136 | 562 | 70 (20261203) | **68 of 70** |
| Second run, after the fixes below | 1,420 | 954 | 80 (7919) | **78 of 80** |

First run, before any fix, the 2 wrong:

- SIG-SSH-ALGS on a Go struct field named `HostKey` (a server-config reader was run on source code)
- DEP-RUNTIME-OLD on `"node": ">=12"` (an open-ended range says nothing about the version in use)

Second run, after the fixes below, the 2 wrong:

- KEX-SSH-PINNED on a test line asserting a key exchange is absent (`assert "..." not in kexen`). Fixed afterwards for this rule.
- SIG-JWT on a test line asserting `"ES512" not in` a list. Not fixed: a name inside a negative assertion is still reported for token rules.

What reading the full output showed, beyond the samples. Each was fixed in the scanner, and each has a test:

- All 16 SIG-SSH-ALGS findings were wrong: SSH and web-server config readers ran on Python and Go source. They no longer run on programming-language files.
- `{ bits: 256 }` next to `ecdsa` was read as a small RSA key. A size on a line that names another algorithm is no longer an RSA size.
- `fmt.Errorf("ecdsa.GenerateKey: %v")` matched key generation. The rule now needs the call, not the text.
- `jws.createSign(` matched Node's `crypto.createSign(`. Method calls on other objects no longer match.
- Mentions inside Python docstrings were reported as code. They are now treated as comments.
- Missed: `rsa.GenerateKey(rand.Reader, 1024)` in Go, SSH key-exchange names written into code, and Java algorithm names passed through a helper (`"SHA256withRSA"`, `"RSA/ECB/..."`). All three are now reported.
- `dist/` and `build/` were skipped without a word, so the first run saw 3 of jose's 284 files. Skipped folders are now listed under `not checked`, and `--include-build` scans them.

What this does not show:

- Nine open-source crypto libraries are not your application. These packages name algorithms on almost every line, which flatters the precision figure.
- This measures precision (is a reported line really about the algorithm named). It does not measure recall: nobody listed everything these packages contain.
- One person checked the samples, once. Findings in test folders count the same as findings in shipped code: 297 of the 953 left after the last fix (one fewer than the second run in the table).

Speed: 1,420 files in 3.1 s on the test PC (Windows 11, Python 3.12, files already in the disk cache). Before this pass the same scanner took about 25 ms per file; skipping rules whose literal text is not in a file brought that to about 2 ms, and a test checks the findings are identical with the shortcut on and off.

## Standard formats

- CycloneDX 1.6 CBOM: validated with jsonschema 4 against https://cyclonedx.org/schema/bom-1.6.schema.json (SHA-256 1ebcb88a...7e098f) for the fixture, the example probe and six of the packages above: 0 schema errors. A deliberately broken file was rejected.
- SARIF 2.1.0: validated against https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json (SHA-256 c3b4bb2d...2a2682e) for the fixture and golang.org/x/crypto: 0 schema errors. Not uploaded to GitHub code scanning here.
- pre-commit framework: the `repo: local` setup in `guard/pre-commit-config.example.yaml` blocked a classic-only TLS pin and passed the hybrid. `.pre-commit-hooks.yaml` needs a `python3` command and failed on Windows without one; not run on macOS or Linux here.
- Python 3.8: the test repository check (103 of 103) and the tool tests (47 of 47, run without the live probe) pass on CPython 3.8.10 on Windows. The file also parses with the 3.8 grammar, and the `vermin` checker reports 3.7 as the minimum version its syntax and library calls need.

## Independent audit

After the work above, a second AI model that had not seen this pass audited the kit in a fresh session on 2026-12-03 and fixed what it found. That is still this project checking itself, not an outside review.

Misses it found by reading three PyPI packages by hand:

- ecdsa 0.19.1: 2 findings in 83 files. The scanner misses the package's own signing and key-exchange code (for example `keys.py` line 1315 and `ecdh.py` line 302). Not fixed: code that implements an algorithm itself, instead of calling a library the rules know, is not recognised.
- PyJWT 2.10.1: type references in `jwt/algorithms.py` (lines 41, 45 and 78) are counted as signing findings. Not fixed: read such lines before you count uses.
- rsa 4.9.1: the scan found encrypt and sign but missed decrypt and verify in the same file. Fixed: all four are reported.

What it changed in the tool, with new tests for the probe, guard, proof check, redaction and MCP changes: the probe connects only to the address it checked, and an unclear answer is listed as not checked instead of as a negative; the guard reads the staged or committed content, not the working copy; `--expect-closed` needs `--diff` and an after-scan made the same way as the before-scan; more credential shapes are blanked in evidence lines; the MCP server answers the current handshake and returns failures as errors.

Recipes: it ran the nginx recipe on this PC (nginx 1.30.8 with OpenSSL 3.5.9: config test and a hybrid-only handshake) and compiled the Go examples on Go 1.27.4. The Apache, HAProxy, Caddy, strongSwan and OpenVPN recipes were checked against vendor documentation only.

With the final scanner the nine packages above give the same 953 findings, at the same files and lines, as before the audit, so the sampled figures above stand.

## Agent run-through

On 2026-12-03 the agent doing this quality pass followed `agent.md` step by step on a copy of the test repository (`fixture/harbor`), with made-up triage answers, as if it had not seen the tool before. It is the same agent that then fixed what it tripped over, so this is a walk-through, not an independent test.

- **Inventory, triage, plan (phases 1 to 3):** worked after four fixes. With the tool inside the project, the first scan reported 323 findings, 185 of them in the tool's own source. A second scan also read the first scan's JSON and reported 1,268. The scanner now leaves its own file and its own output out and names them under `not checked`. `agent.md` did not show the shape of a `manual_findings` entry; it does now, and one line is enough. A mistyped `data_lifetime` was silently treated as unknown; the report now stops and prints the allowed values.
- **Migrate (phase 4):** part of wave 1 on a branch, nine findings in the nginx, HAProxy, Go gateway and SSH configs. The hybrid went in front of the classic entries; nothing was removed.
- **Prove (phase 5):** `report --diff --expect-closed` with the nine ids printed `closed 10 | remaining 128 | new 0 | post-quantum added 3`, PASS, exit 0 (the tenth closed with the same edit). Before the fix the three new hybrids were counted as `new`, which read like a regression. A local Node server (Node 24.11.1, OpenSSL 3.5.4) with the same group list was probed: `X25519MLKEM768` (0x11EC) selected through a HelloRetryRequest, a hybrid-only handshake completed, and a classic-only client still got `x25519`.
- **Also fixed on the way:** the `Next:` hint after a scan pointed at the wrong folder; `prove.md` had no steps for a local test server; the exit-code line in `agent.md` did not say what to do with each code.

Not done: no real nginx, HAProxy or sshd was started and the Go code was not compiled (none is installed on the test PC), so those rows stay `CHANGED, NOT PROVEN HERE`. Phases 6 and 7 were read, not carried out, apart from the guard tests listed under Tools. No other agent or person has followed the protocol yet.

## Tools

Checked 2026-12-03 on Windows 11, Python 3.12, Node 24.11.1 (OpenSSL 3.5.4). `python tests/test_tools.py --live`:

```
PASS  probe: refuses a public address without --authorized pqshift: Probe only systems you own or are authorized to test. 203.0.113.10 is outside loopback and RFC 1918: 
PASS  probe: refuses a public or unresolvable name without --authorized pqshift: example.com does not resolve to an address from this computer, so it ca
PASS  probe: hybrid server selects X25519MLKEM768 {'selected_for_pq_client': 'X25519MLKEM768', 'code': '0x11EC', 'method': 'HelloRetryRequest', 'supported_hybrids': ['X25519MLKEM768'], 'preferred': True}
PASS  probe: hybrid-only handshake confirmed node 24.11.1 / OpenSSL 3.5.4, hybrid-only offer (X25519MLKEM768)
PASS  probe: classic server -> KEX-ENDPOINT-NO-PQ {'selected_for_pq_client': 'x25519', 'code': '0x001D', 'method': 'HelloRetryRequest', 'supported_hybrids': [], 'preferred': False}
PASS  probe: classic server hybrid handshake fails hybrid-only handshake failed: ERR ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE
PASS  probe: cert parsed {'subject': 'localhost', 'issuer': 'localhost', 'sig_alg': 'ecdsa-with-SHA256', 'key': 'EC P-256', 'not_after': '2027-01-02T11:17:30Z', 'sha256': '72cc7880ab69ab499953602d91a7153bb07f16476c3a3fc08d39fbe121026cef'}
PASS  probe ssh: pq -> OK-PQ-KEX 
PASS  probe ssh: classic -> KEX-ENDPOINT-SSH-NO-PQ 
PASS  report: nginx recipe closes PINNED + NO13 (--expect-closed exits 0)   PASS  all 2 expected findings closed, no new high/critical
PASS  report: --expect-closed fails when the finding is still there 
PASS  report: CBOM has crypto assets 107 components
PASS  report: score arithmetic 70+20+20+10 = 120, wave 1 (120, {'base': 70, 'exposure': 20, 'lifetime': 20, 'reach': 10, 'context': 0}, 1)
PASS  guard: staged classic-only pin fails FAIL  tls.js:1  KEX-TLS-PINNED  high  const o = { ecdhCurve: 'X25519:P-256' };  | fix: Put X25519MLKEM768 first, keep X25519 and P-256 behind it; or delete the pin on a runtime whose default includes the hybrid.
PASS  guard: staged hybrid pin passes pqshift guard: 0 failing, 0 warnings, 0 allowed by policy
PASS  guard: signature-only change warns, exit 0 pqshift guard: 0 failing, 1 warning, 0 allowed by policy
PASS  guard: an unstaged exception cannot allow a staged finding 
PASS  guard: allow entry with a future date passes pqshift guard: 0 failing, 1 warning, 1 allowed by policy
PASS  guard: expired allow entry fails POLICY-EXPIRED 
PASS  mcp: initialize, tools/list, pq_scan 
PASS  mcp: pq_probe refuses without authorized=true 
PASS  parsers: truncated and junk input do not crash 1 errors
PASS  cli: 8 kinds of bad input exit 2 with a plain message, no traceback 
PASS  cli: --help documents the exit codes 
PASS  cli: split_target reads URLs, IPv6 and ssh:// 
PASS  scan: the speed prefilter does not change the result (129 findings either way) 
PASS  scan: LF, CRLF, UTF-8 BOM and UTF-16 files give the same finding on the same line 
PASS  scan: 6 source-code shapes that look like crypto are not reported 
PASS  scan: small RSA in Go, SSH kex names in code, capped Node range and key generation are reported ['KEY-GEN', 'WEAK-RSA-SMALL'] ['KEX-SSH-PINNED'] ['DEP-RUNTIME-OLD'] ['private_key = ec.generate_private_key(<redacted>)']
PASS  scan: --include-comments shows the docstring mention, marked as a comment 
PASS  scan: skipped build and third-party folders are listed under not checked third-party folders: node_modules (1) | build output folders: dist (1) | symmetric ciphers and hash functions
PASS  scan: --include-build and --include-vendored scan them 
PASS  scan: --sarif writes SARIF 2.1.0 (129 results, 37 rules, relative paths) 
PASS  guard: file names with spaces and accents are checked (2 failures, SARIF written) FAIL  clé.js:1  KEX-TLS-PINNED  high  const o = { ecdhCurve: 'X25519:P-256' };  | fix: Put X25519MLKEM768 first, keep X2
PASS  guard: a staged rename is still checked FAIL  clé.js:1  KEX-TLS-PINNED  high  const o = { ecdhCurve: 'X25519:P-256' };  | fix: Put X25519MLKEM768 first, keep X2
PASS  probe: one resolution, one pinned address, eight connection attempts including confirmation 
PASS  mcp: modern discovery, validation and continued service after invalid request 
PASS  scan: quoted credential and function argument are absent from evidence 
PASS  report: proof requires a before/after comparison 
PASS  scan: skips its own file and its own output, and says so 1 findings; PQ Shift's own files (4): pq/before.json, pq/before.sarif, pq/cbom.json, tools/pqshift.py | symmetric ciphers and hash functions
PASS  scan: a different file that happens to be called pqshift.py is still scanned ['KEY-GEN', 'WEAK-RSA-SMALL']
PASS  report: an answer outside the allowed values stops with the list of values pqshift: answers.json: system web has data_lifetime 'forever'. Use one of: 1-5y, 5-10y, <1y, >10y, unknown
PASS  report: a one-line manual item becomes a plan row PQ Shift 1.0.0  report  1 finding from before.json + 1 you reported in answers.json
PASS  report: a false-positive id that is not in the findings is refused pqshift: answers.json: false_positives lists ids that are not in the findings: F-0000000000
PASS  report: a false positive without a reason is refused pqshift: answers.json: every false_positives entry needs an "id" and a "reason"
PASS  report: the diff counts a new hybrid as 'post-quantum added', not as a new finding     closed  F-4d397d23f2 KEX-TLS-PINNED nginx.conf
PASS  report: --expect-closed with an id that was never there fails   FAIL  not in the before file (check the ids): F-0000000000
PASS  probe live: zirkomirko.com selects X25519MLKEM768 {'selected_for_pq_client': 'X25519MLKEM768', 'code': '0x11EC', 'method': 'HelloRetryRequest', 'supported_hybrids': ['X25519MLKEM768'], 'preferred': True}
48 of 48 tool tests passed
```

## What these numbers do not prove

- The fixture was written for this tool by the same project. It shows the tool does what it says on code shaped like the rules; it does
  not show how it does on your code. Expect misses on code that picks algorithms at run time, wraps crypto in its own helpers, or lives
  in languages outside the list.
- Zero false alarms on 17 decoys is not zero false alarms in general. On real packages 2 of 80 sampled findings were wrong
  (see "Real code"). Review findings before acting on them.
- The probe reads what the TLS or SSH endpoint answers. It sees the edge (a CDN or load balancer), not the servers behind it.
- Nothing here was checked by an outside party.
