Skip to content

Go: fix tests with non-empty testFailures#22064

Merged
owen-mc merged 2 commits into
github:mainfrom
owen-mc:go/fix-test-failures
Jun 26, 2026
Merged

Go: fix tests with non-empty testFailures#22064
owen-mc merged 2 commits into
github:mainfrom
owen-mc:go/fix-test-failures

Conversation

@owen-mc

@owen-mc owen-mc commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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 (FileInfo vs DirEntry), 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 included FileInfo.Name(). In this PR I update that list to include DirEntry.Name(), which makes the test pass again.

@owen-mc owen-mc requested a review from a team June 25, 2026 21:53
@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Jun 25, 2026
@owen-mc owen-mc requested a review from a team as a code owner June 25, 2026 21:53
Copilot AI review requested due to automatic review settings June 25, 2026 21:53
@github-actions github-actions Bot added the Go label Jun 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in websocketXss.go onto the read/receive call lines so they match the emitted source locations.
  • Update StoredXss.expected and ReflectedXss.expected to remove testFailures blocks and reflect the now-matching results.
  • Extend stored-XSS file-name source modeling to include results from DirEntry/FileInfo.Name() and os.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

@geoffw0 geoffw0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@owen-mc owen-mc merged commit 37ce885 into github:main Jun 26, 2026
19 checks passed
@owen-mc owen-mc deleted the go/fix-test-failures branch June 26, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Go no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants