Fix out-of-scope elements inheriting other elements' findings in resolve()#338
Open
NoodlesNZ wants to merge 1 commit into
Open
Fix out-of-scope elements inheriting other elements' findings in resolve()#338NoodlesNZ wants to merge 1 commit into
NoodlesNZ wants to merge 1 commit 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.
TM.resolve()was assigning the in-progress findings list to out-of-scope elements instead of skipping them:Since findings accumulates as the element loop runs, any element with inScope=False ended up with a copy of every finding generated for elements processed before it. Reports then showed findings against the exact elements that were declared out of scope, targeting completely different parts of the model.
The existing
test_resolvedidn't catch this because its out-of-scope actor happened to be created before any finding-producing elements, so the leaked list was still empty at that point. Element creation order determines iteration order inresolve(), so the bug only shows up when an out-of-scope element is defined after in-scope ones.Changes:
resolve()now sets findings to an empty list for out-of-scope elements. This also clears stale findings if a model is resolved again after flipping an element out of scope.test_resolveto cover both creation orders (out-of-scope element defined first and last), so the leaking variant stays covered.