fix(contract): constrain deferred coverage paths - #558
Open
sylvesterkaczmarek wants to merge 2 commits into
Open
fix(contract): constrain deferred coverage paths#558sylvesterkaczmarek wants to merge 2 commits into
sylvesterkaczmarek wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Require canonical
coverage.deferred[].pathsvalues to remain safe repository-relative POSIX paths.Fixes #557.
Reproduction / evidence
Current upstream
mainat37bf87a692fc72d41f7312cc48808d699d204fbadocuments deferred coverage units with optional source paths, but the shared coverage schema constrains each path only to a non-empty string.A sealed partial-coverage bundle can therefore contain a deferred path such as
../../outside.ts,/etc/passwd,C:/outside.ts, orsrc\\outside.tsand still passloadContract()after the coverage artifact is correctly resealed.This differs from manifest scope paths, finding locations, code-evidence paths and artifact/receipt paths, which already enforce the repository-relative path model.
Root cause
coverage.schema.jsonadded the optional deferredpathsfield without the safe-path constraint used by the other canonical source-path fields._validate_coverage()does not independently normalize those paths before shared schema validation.Fix
Apply the canonical repository-relative safe-path pattern to every deferred path, rejecting:
..traversal segments;.;Because the same schema is consumed by finalization and the TypeScript contract loader, the invariant is enforced at both producer and consumer boundaries.
Tests / validation
Added
deferred-coverage-paths.test.ts. It copies the real bundled completed-scan example, switches it to partial coverage, inserts a deferred path, reseals thecoverage.jsondigest in the manifest, and calls the realloadContract().The regression covers traversal, absolute, Windows-style, dot, colon and NUL-bearing paths, plus a valid
src/extract.pycontrol.The branch is based directly on current upstream
mainat37bf87a692fc72d41f7312cc48808d699d204fbaand is not behind it. Production diff: 2 additions, 1 deletion.Full repository tests cannot be run in this execution environment because the repository cannot be cloned here. Pushed-head CI remains the authoritative full-suite validation.
Risk
Low. The change only narrows a documented canonical path field to the repository-relative format already required by the rest of the contract.