Skip to content

fix(catalog): publish cache assets without overwriting entries - #3739

Open
jrusso1020 wants to merge 1 commit into
mainfrom
fix/security-catalog-cache-writes
Open

fix(catalog): publish cache assets without overwriting entries#3739
jrusso1020 wants to merge 1 commit into
mainfrom
fix/security-catalog-cache-writes

Conversation

@jrusso1020

Copy link
Copy Markdown
Collaborator

Catalog asset references and large embedded data URIs checked for an existing hashed output and then wrote by pathname. A competing file or symlink could appear between those operations and be overwritten. Both callers now share cache publication that stages complete bytes in a private sibling directory, then atomically links them into place only if the destination is still absent. This addresses CodeQL #851 and #852.

Existing cache entries remain untouched, including dangling links, and cache hits require no staging or writable directory. Hashes, URLs, MIME handling, externalization thresholds and result counts are preserved. Cache misses reject a symlinked cache directory. Cleanup is best effort so it cannot mask a write/publication failure or turn a successful publication into an error. The output directory's ancestors remain trusted against hostile concurrent parent renames; cleanup failure may leave private staging residue. Directory-copy overwrite behavior is unchanged.

Validation: all 274 script/catalog tests (188 Node + 86 Vitest), script types, dependency builds, lint/format and signed hooks pass. Twenty new cases cover both callers: competing files/live or dangling links, existing dangling entries, external directory links, complete publication, cache reuse, partial-write cleanup and publication/cleanup failures. The competing-entry, dangling-link, directory-link and partial-write witnesses fail against main. The new suite joins the existing catalog source-read suite in the Windows lane.

Optional Fallow remains red locally: eight complexity findings, seven classified as inherited, and no duplication groups. The new cache helper has cyclomatic complexity 8; its branches enforce cache-hit preservation, directory type, competing-entry handling and cleanup. No suppressions were added. Fresh CI, Windows, CodeQL and Magi's review of the current commit remain merge gates.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Fallow audit report

Found 8 findings.

Details
Severity Rule Location Description
major fallow/high-crap-score scripts/catalog-payload-assets.ts:95 'localReferences' has CRAP score 56.0 (threshold: 30.0, cyclomatic 7)
minor fallow/high-crap-score scripts/catalog-payload-assets.ts:124 'probableReferences' has CRAP score 42.0 (threshold: 30.0, cyclomatic 6)
critical fallow/high-crap-score scripts/catalog-payload-assets.ts:174 'readProjectFile' has CRAP score 110.0 (threshold: 30.0, cyclomatic 10)
major fallow/high-crap-score scripts/catalog-payload-assets.ts:213 'cacheAsset' has CRAP score 72.0 (threshold: 30.0, cyclomatic 8)
minor fallow/high-crap-score scripts/catalog-payload-assets.ts:251 'processAssets' has CRAP score 42.0 (threshold: 30.0, cyclomatic 6)
minor fallow/high-crap-score scripts/catalog-payload-assets.ts:342 'hostedPaths' has CRAP score 42.0 (threshold: 30.0, cyclomatic 6)
minor fallow/high-crap-score scripts/catalog-payload-assets.ts:355 'downloadMirrorPrefix' has CRAP score 42.0 (threshold: 30.0, cyclomatic 6)
major fallow/high-crap-score scripts/catalog-payload-assets.ts:390 'hostItemDirectory' has CRAP score 90.0 (threshold: 30.0, cyclomatic 9)

Generated by fallow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant