Go: fix tests with non-empty testFailures#22064
Open
owen-mc wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Go security query tests that accidentally committed non-empty testFailures output by aligning inline expectation markers with the actual result locations and updating expected results after a small stored-XSS source modeling adjustment.
Changes:
- Move
$ Source[go/reflected-xss]inline expectations inwebsocketXss.goonto the read/receive call lines so they match the emitted source locations. - Update
StoredXss.expectedandReflectedXss.expectedto removetestFailuresblocks and reflect the now-matching results. - Extend stored-XSS file-name source modeling to include results from
DirEntry/FileInfo.Name()andos.File.ReadDirNames()calls.
Show a summary per file
| File | Description |
|---|---|
| go/ql/test/query-tests/Security/CWE-079/websocketXss.go | Adjusts inline expectation marker placement so reflected-XSS sources match result end lines. |
| go/ql/test/query-tests/Security/CWE-079/StoredXss.expected | Removes testFailures and adds the newly produced result/graph entries. |
| go/ql/test/query-tests/Security/CWE-079/ReflectedXss.expected | Removes testFailures now that inline expectations align with produced sources. |
| go/ql/lib/semmle/go/security/StoredXssCustomizations.qll | Updates stored-XSS source customization to cover additional filename-returning APIs. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
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.
These were committed by mistake, and should have been fixed before being committed.
First commit: We just need to move the inline expectation test comments because moving to the shared SSA library changes the locations of various data flow nodes.
Second commit: In this PR to promote an experimental query I included this commit, in which I changed
ioutil.ReadDir, which has been deprecated for a long time, to its replacement,os.ReadDir. I didn't realise that they have different return types (FileInfovsDirEntry), and the stored XSS query uses a list of functions that can return the name of a real file on the file system which only includedFileInfo.Name(). In this PR I update that list to includeDirEntry.Name(), which makes the test pass again.