1
0
Fork 1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-06-02 08:38:17 -04:00
pkg-proxy/internal
Andrew Nesbitt 61741123bf
Verify cached artifacts on read (#111)
checkCache opened the storage reader and streamed it to the client
without checking that the bytes still matched what was originally
stored, or what the upstream registry declared. Disk corruption,
accidental overwrites, or local tampering would go unnoticed.

Wrap the storage reader in a verifyingReader that computes SHA256
(against artifact.content_hash) and, when version.integrity holds an
SRI string, the corresponding sha256/384/512 digest as bytes flow
through. At EOF the digests are compared; on mismatch we log at
error level, bump proxy_integrity_failures_total, and clear the
artifact's cache entry so the next request refetches from upstream.

Verification is skipped when the stream was not fully consumed
(client disconnect) to avoid evicting good artifacts on partial
reads. The DirectServe presigned-URL path is unverified since the
proxy never sees those bytes.

Refs #42 (part 1)
2026-05-03 10:36:28 +01:00
..
config Merge pull request #102 from git-pkgs/enforce-max-size-eviction 2026-04-30 23:26:16 +01:00
cooldown Fix all golangci-lint issues across the codebase (#32) 2026-03-18 10:59:29 +00:00
database Apply 'go fmt' as suggested in CONTRIBUTING.md. 2026-04-18 07:43:22 -04:00
enrichment Use shared github.com/git-pkgs/enrichment module 2026-02-06 10:37:00 +00:00
handler Verify cached artifacts on read (#111) 2026-05-03 10:36:28 +01:00
metrics Verify cached artifacts on read (#111) 2026-05-03 10:36:28 +01:00
mirror Apply 'go fmt' as suggested in CONTRIBUTING.md. 2026-04-18 07:43:22 -04:00
server Structured JSON error responses for API endpoints (#110) 2026-05-03 09:42:03 +01:00
storage Reject path traversal in filesystem storage (#106) 2026-05-02 18:00:28 +01:00