Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions actions/ql/src/Security/CWE-094/CodeInjectionMedium.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ import actions
import codeql.actions.security.CodeInjectionQuery
import CodeInjectionFlow::PathGraph

/**
* A data flow source of user input from github context.
* eg: github.head_ref
* Usually only considered for pull_request_target where access to secrets
* and tokens is more available.
* However this query already finds all context events as sources regardless
Comment on lines +22 to +26
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The new doc comment has a few wording/capitalization issues: "github" should be capitalized as "GitHub", and "eg" should be "e.g.". Consider also backticking event/context identifiers (for example github.head_ref, pull_request_target) to improve readability.

Suggested change
* A data flow source of user input from github context.
* eg: github.head_ref
* Usually only considered for pull_request_target where access to secrets
* and tokens is more available.
* However this query already finds all context events as sources regardless
* A data flow source of user input from GitHub context.
* e.g.: `github.head_ref`
* Usually only considered for `pull_request_target` where access to secrets
* and tokens is more available.
* However this query already finds all context events as sources regardless,

Copilot uses AI. Check for mistakes.
* so this should be similar.
*/
class GitHubCtxSourceMediumLikely extends RemoteFlowSource {
string flag;
string event;

GitHubCtxSourceMediumLikely() {
exists(GitHubExpression e |
this.asExpr() = e and
// github.head_ref
e.getFieldName() = "head_ref" and
flag = "branch"
|
event = e.getATriggerEvent().getName() and
event = "pull_request"
or
not exists(e.getATriggerEvent()) and
event = "unknown"
)
}

override string getSourceType() { result = flag }

override string getEventName() { result = event }
}

from CodeInjectionFlow::PathNode source, CodeInjectionFlow::PathNode sink
where mediumSeverityCodeInjection(source, sink)
select sink.getNode(), source, sink,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added source type to `actions/code-injection/medium` such that now `github.head_ref` is found as source even on event `pull_request` (not just `pull_request_target`). This will result in the query finding more results.
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The change note sentence is a bit ungrammatical/awkward ("such that now", "found as source", "on event"). Consider rephrasing to something like "...so github.head_ref is now treated as a source on the pull_request event (not just pull_request_target)" for clarity.

Suggested change
* Added source type to `actions/code-injection/medium` such that now `github.head_ref` is found as source even on event `pull_request` (not just `pull_request_target`). This will result in the query finding more results.
* Added a source type to `actions/code-injection/medium` so `github.head_ref` is now treated as a source on the `pull_request` event (not just `pull_request_target`). This will result in the query finding more results.

Copilot uses AI. Check for mistakes.
Loading