Repository navigation
Commit 6cbc8ad
committed
Scanner: the licence, the files a public repo needs, and the holes publishing invites
Splitting the scanner out gave it a repository. It did not make it publishable.
Six of the eight prerequisites written down in the feasibility pass were still
missing, and two of the things a reviewer looks for first were real.
**Licence.** `pyproject.toml` claimed MIT and no LICENSE existed, so neither the
wheel nor the repository carried any terms at all. It is now **AGPL-3.0-or-later**
with the canonical text, declared as PEP 639 metadata — the built wheel reports
`License-Expression: AGPL-3.0-or-later` and ships LICENSE and NOTICE in
`dist-info/licenses`. This is the recommendation from the analysis, not a
decision anyone signed off: the network clause is what stops a competitor
running a rival service off this engine without publishing their changes, and a
commercial exception is what keeps that from costing revenue. Switching to BSL
or back to MIT is three lines.
**NOTICE.** `data/jurisdiction_places.json` is built from GeoNames dumps, which
are CC BY 4.0 and require attribution and a statement that the data was
modified. Neither existed. Shipping it under a bare MIT claim misdescribed the
artifact; shipping it publicly would have been an attribution failure.
**CONTRIBUTING, SECURITY, CODE_OF_CONDUCT, CLA.** CONTRIBUTING says the thing
that is not visible from outside — that this repository is published from a
private workspace, so a merged change returns with a different hash. The CLA is
a licence grant with a sublicense right, not an assignment: contributors keep
their copyright, and the project keeps the ability to sell the commercial
exception. It is a draft and says so.
**The gazetteer script wrote outside the repository.** `parents[2]` resolved to
the workspace root, which in the split repository is its *parent*: a rebuild
would have written `../scanner/src/...`. Re-anchored on the project root, which
is the same directory in both layouts.
Workspace-Commit: 62fb4a61008b588cabcd305166716f6a808e5a76
---
Then the security work, because publishing invites it and because two of these
were genuinely wrong. Each was reproduced before it was fixed.
**Redirects left the public internet.** `is_public_url` guarded the entry URL,
then `follow_redirects=True` handed the chain to httpx and only the *landing*
URL was re-checked. That discards the body but does not prevent the request:
against a local pair of servers, a public entry URL redirecting to 127.0.0.1
reached the private endpoint every time, and the response was read in full. A
repository declaring such a homepage could have the scanner probe the network it
runs in and read the answers off the timings. `icon.public_stream` now walks the
chain by hand and vets every hop before requesting it; `llms_txt` uses it too.
**The Go vanity lookup was not guarded at all.** `go_module_repository_url`
fetches `https://{module}?go-get=1`, where `module` comes from the scanned
repository's own `go.mod` — the one fetch in that module whose host the audited
project picks. It had no host check and no size limit. That HTTPS-only happened
to block the plain-HTTP metadata endpoints is luck, not a control. It now goes
through the same guard and a 512 kB cap.
**Manifests were read unbounded.** Every other fetch in `ecosystems` addresses a
registry; manifests come from raw.githubusercontent, where GitHub serves single
files up to 100 MB, a scan reads up to twenty of them, and every text is
retained for classification. Committing a padded `package.json` was a way to
take a worker's memory. `_get_manifest_text` streams against a 2 MB cap and
keeps `_get`'s retry shape, because dropping a manifest on a 429 would file
"slow down" under "no package here".
**XML entity expansion.** Measured rather than assumed: on CPython 3.13 the
stdlib parser already refuses external entities — no file disclosure, no request
smuggled through a DOCTYPE — but *internal* expansion works, and four nesting
levels turn under a kilobyte into 30,000 characters. `xmlsafe` refuses entity
declarations outright; nothing here has a legitimate reason to declare one.
**The test doubles were the reason none of this was caught.** `test_icon`,
`test_llms_txt` and `test_ecosystems` used hand-written clients with only a
`.stream()` method, which cannot express a redirect at all — so the redirect
handling was unexercised for as long as it was wrong. They are real
`httpx.Client`s over `MockTransport` now, and six tests assert on what reached
the transport, which is the only assertion that means anything for a guard whose
job is to stop a request being made.
1102 tests pass. METRICS_VERSION, SCHEMA_VERSION and the calibration snapshot
are untouched: no score moves and no rescore is triggered.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 6a4ebef commit 6cbc8ad
19 files changed
Lines changed: 1490 additions & 129 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments