Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update Go Path Injection Sanitizer and Sink#20064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Kwstubbs wants to merge2 commits intogithub:main
base:main
Choose a base branch
Loading
fromKwstubbs:go-path-separator

Conversation

Kwstubbs
Copy link
Contributor

Account for os.PathSeparator in Go sanitizer and remove CreateTemp from valid sinks

@CopilotCopilotAI review requested due to automatic review settingsJuly 16, 2025 06:16
@KwstubbsKwstubbs requested a review froma team as acode ownerJuly 16, 2025 06:16
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Go path injection query to improve sanitization detection and removes a false positive. The changes account foros.PathSeparator as a valid path sanitizer alongside hardcoded "/" and removeCreateTemp from path injection sinks due to proper built-in sanitization.

  • Updates path injection sanitizers to recognizeos.PathSeparator usage
  • RemovesCreateTemp from path injection sinks in theos package model
  • Adds test coverage for the new sanitizer pattern

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
go/ql/test/query-tests/Security/CWE-022/TaintedPath.goAdds test case foros.PathSeparator sanitization pattern
go/ql/test/query-tests/Security/CWE-022/TaintedPath.expectedUpdates expected test results for line number changes
go/ql/lib/ext/os.model.ymlRemovesCreateTemp from path injection sinks
go/ql/lib/change-notes/2025-07-15-path-injection-sanitizers.mdDocuments the changes in release notes

@github-actionsGitHub Actions
Copy link
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in theartifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

go

Generated file changes for go

  • Changes to framework-coverage-go.rst:
-    `Standard library <https://pkg.go.dev/std>`_,"````, ``archive/*``, ``bufio``, ``bytes``, ``cmp``, ``compress/*``, ``container/*``, ``context``, ``crypto``, ``crypto/*``, ``database/*``, ``debug/*``, ``embed``, ``encoding``, ``encoding/*``, ``errors``, ``expvar``, ``flag``, ``fmt``, ``go/*``, ``hash``, ``hash/*``, ``html``, ``html/*``, ``image``, ``image/*``, ``index/*``, ``io``, ``io/*``, ``log``, ``log/*``, ``maps``, ``math``, ``math/*``, ``mime``, ``mime/*``, ``net``, ``net/*``, ``os``, ``os/*``, ``path``, ``path/*``, ``plugin``, ``reflect``, ``reflect/*``, ``regexp``, ``regexp/*``, ``slices``, ``sort``, ``strconv``, ``strings``, ``sync``, ``sync/*``, ``syscall``, ``syscall/*``, ``testing``, ``testing/*``, ``text/*``, ``time``, ``time/*``, ``unicode``, ``unicode/*``, ``unsafe``, ``weak``",52,609,104+    `Standard library <https://pkg.go.dev/std>`_,"````, ``archive/*``, ``bufio``, ``bytes``, ``cmp``, ``compress/*``, ``container/*``, ``context``, ``crypto``, ``crypto/*``, ``database/*``, ``debug/*``, ``embed``, ``encoding``, ``encoding/*``, ``errors``, ``expvar``, ``flag``, ``fmt``, ``go/*``, ``hash``, ``hash/*``, ``html``, ``html/*``, ``image``, ``image/*``, ``index/*``, ``io``, ``io/*``, ``log``, ``log/*``, ``maps``, ``math``, ``math/*``, ``mime``, ``mime/*``, ``net``, ``net/*``, ``os``, ``os/*``, ``path``, ``path/*``, ``plugin``, ``reflect``, ``reflect/*``, ``regexp``, ``regexp/*``, ``slices``, ``sort``, ``strconv``, ``strings``, ``sync``, ``sync/*``, ``syscall``, ``syscall/*``, ``testing``, ``testing/*``, ``text/*``, ``time``, ``time/*``, ``unicode``, ``unicode/*``, ``unsafe``, ``weak``",52,609,103-    Totals,,688,1069,1557+    Totals,,688,1069,1556
  • Changes to framework-coverage-go.csv:
- os,29,12,6,3,,,,,26,,,,,,,,,,,1,,7,3,,1,6,+ os,28,12,6,3,,,,,25,,,,,,,,,,,1,,7,3,,1,6,

@KwstubbsKwstubbs requested a review fromowen-mcJuly 16, 2025 21:33
@Kwstubbs
Copy link
ContributorAuthor

Sorry, I somehow forgot to add the actual CodeQL change.

Copy link
Contributor

@owen-mcowen-mc left a comment

Choose a reason for hiding this comment

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

You'll also have to update the test expectationhere sinceCreateTemp is no longer a sink.

Comment on lines +91 to +96
concatNode.getOperand(0).asExpr().(StringLit).getValue() = "/"
or
exists(DeclaredConstant dc |
dc.hasQualifiedName("os", "PathSeparator") and
dc.getAReference() = concatNode.getOperand(0).asExpr().getAChildExpr*()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we usegetStringValue on any reference ofos.PathSeparator then we'll get its actual string value (the compiler knows what value a constant has). On Windows of course this is"\". So we can simplify this to:

Suggested change
concatNode.getOperand(0).asExpr().(StringLit).getValue()="/"
or
exists(DeclaredConstantdc|
dc.hasQualifiedName("os","PathSeparator")and
dc.getAReference()=concatNode.getOperand(0).asExpr().getAChildExpr*()
)
concatNode.getOperand(0).getStringValue()=["/", "\"]

The above code allows using the string literal"\" as well, which seems sensible for any code which is written to only be run on Windows. What do you think?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@owen-mcowen-mcowen-mc requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Kwstubbs@owen-mc

[8]ページ先頭

©2009-2025 Movatter.jp