fix(contract): reject reversed finding line ranges - #561
Open
sylvesterkaczmarek wants to merge 2 commits into
Open
fix(contract): reject reversed finding line ranges#561sylvesterkaczmarek 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 finding locations loaded by the TypeScript SDK to satisfy
endLine >= startLine, matching the existing Python finalizer invariant.Fixes #560.
Reproduction / evidence
Current upstream
mainat37bf87a692fc72d41f7312cc48808d699d204fbahas asymmetric canonical validation:endLineis beforestartLine;validateCanonicalContract()in the TypeScript loader validates the location path but does not compare the line numbers.A copy of the real bundled completed-scan fixture can therefore be changed to
startLine: 41, endLine: 40, resealed by updating thefindings.jsondigest inscan-manifest.json, and still load throughloadContract()on current main.Root cause
The relational line-range invariant is enforced during Python finalization but was not mirrored in the TypeScript canonical-validation pass. The existing JSON Schema cannot express this sibling-value comparison by itself.
Fix
After validating each ordinary finding location path, reject a defined
endLinethat is less than itsstartLine.The check is intentionally limited to the existing producer invariant and does not alter valid single-line or forward multi-line locations.
Tests / validation
Added
contract-location-line-ranges.test.ts. It copies the real bundledexamples/completed-scanfixture, mutates the first location, rewritesfindings.json, recomputes the sealed artifact digest, and calls the realloadContract().The regression verifies:
startLine: 41, endLine: 40is rejected;startLine: 41, endLine: 44remains valid.The branch is based directly on current upstream
mainat37bf87a692fc72d41f7312cc48808d699d204fbaand is not behind it. Production diff: 8 additions, 0 deletions.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. This only makes the TypeScript loader reject a canonical location that the bundled producer already rejects.