Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9953504
Use new packaging mechanism for internal queries
henrymercer May 11, 2023
abb267d
Add query to identify env vars that may not work with default setup
henrymercer May 11, 2023
8065746
Add query to find context variables that may not work with default setup
henrymercer May 12, 2023
eac5e24
Downgrade query severity to warning
henrymercer May 16, 2023
292bb7c
Parameterize check scripts over requests version
henrymercer May 23, 2023
6e92b19
Bump requests to 2.31.0
henrymercer May 23, 2023
4f41ff7
Update default bundle to codeql-bundle-20230524
invalid-email-address May 24, 2023
34e8e09
Add changelog note
invalid-email-address May 24, 2023
143b5fb
Merge branch 'main' into henrymercer/update-requests
henrymercer May 24, 2023
60f5c59
Merge branch 'main' into update-bundle/codeql-bundle-20230524
henrymercer May 24, 2023
65920dd
Unconditionally set up Swift in debug artifacts PR check
henrymercer May 24, 2023
339e0d5
Update changelog and version after v2.3.5
github-actions[bot] May 25, 2023
1ba7713
Update checked-in dependencies
github-actions[bot] May 25, 2023
2d031a3
Merge pull request #1707 from github/mergeback/v2.3.5-to-main-0225834c
aeisenberg May 25, 2023
f8b1cb6
Merge pull request #1695 from github/henrymercer/update-requests
henrymercer May 26, 2023
2408985
Only print lines of code information once
henrymercer May 26, 2023
6bd8101
Merge pull request #1709 from github/henrymercer/print-baseline-once
henrymercer May 26, 2023
eb1c7a3
Use `getRefFromEnv()` so ref is present on default setup
henrymercer May 30, 2023
86ead5e
Only flag up the deepest properties
henrymercer May 30, 2023
125ff55
Fix deprecation warnings
henrymercer May 30, 2023
d427c89
Ignore internal Actions
henrymercer May 30, 2023
9d2dd7c
Merge pull request #1698 from github/update-bundle/codeql-bundle-2023…
May 31, 2023
9632771
Address review comments
henrymercer May 31, 2023
07e43a2
Open PR with gh CLI
henrymercer May 31, 2023
afdba76
Wait a week before dropping support for end of life GHES versions
henrymercer May 31, 2023
e7cff66
Fix push
henrymercer May 31, 2023
955f859
Fix sign error
henrymercer May 31, 2023
26f16a5
Rephrase the still supported calculation to make it clearer
henrymercer May 31, 2023
89c4c9e
Merge pull request #1678 from github/henrymercer/default-setup-safegu…
henrymercer May 31, 2023
96f2840
Merge pull request #1711 from github/henrymercer/improve-supported-ve…
henrymercer May 31, 2023
5c8f4be
Update changelog for v2.3.6
github-actions[bot] Jun 1, 2023
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
2 changes: 1 addition & 1 deletion lib/actions-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions queries/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
lockVersion: 1.0.0
dependencies:
codeql-javascript:
version: 0.6.1
codeql/regex:
version: 0.0.12
codeql/tutorial:
version: 0.0.9
codeql/util:
version: 0.0.9
codeql/yaml:
version: 0.0.1
compiled: false
4 changes: 2 additions & 2 deletions queries/qlpack.yml → queries/codeql-pack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: codeql-action-custom-queries-javascript
version: 0.0.0
libraryPathDependencies: codeql-javascript

dependencies:
codeql/javascript-all: 0.6.1
52 changes: 52 additions & 0 deletions queries/default-setup-environment-variables.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @name Some environment variables may not exist in default setup workflows
* @id javascript/codeql-action/default-setup-env-vars
* @kind problem
* @severity warning
*/

import javascript

bindingset[envVar]
predicate isSafeForDefaultSetup(string envVar) {
// Ignore internal Code Scanning environment variables
envVar.matches("CODE_SCANNING_%") or
envVar.matches("CODEQL_%") or
envVar.matches("CODESCANNING_%") or
envVar.matches("LGTM_%") or
// We flag up usage of potentially unsafe parts of the GitHub event in `default-setup-event-context.ql`.
envVar = "GITHUB_EVENT_PATH" or
// The following environment variables are known to be safe for use with default setup
envVar =
[
"GITHUB_ACTION_REF", "GITHUB_ACTION_REPOSITORY", "GITHUB_ACTOR", "GITHUB_API_URL",
"GITHUB_BASE_REF", "GITHUB_EVENT_NAME", "GITHUB_JOB", "GITHUB_RUN_ATTEMPT", "GITHUB_RUN_ID",
"GITHUB_SHA", "GITHUB_REPOSITORY", "GITHUB_SERVER_URL", "GITHUB_TOKEN", "GITHUB_WORKFLOW",
"GITHUB_WORKSPACE", "GOFLAGS", "JAVA_TOOL_OPTIONS", "RUNNER_ARCH", "RUNNER_NAME", "RUNNER_OS",
"RUNNER_TEMP", "RUNNER_TOOL_CACHE"
]
}

predicate envVarRead(DataFlow::Node node, string envVar) {
node =
any(DataFlow::PropRead read |
read = NodeJSLib::process().getAPropertyRead("env").getAPropertyRead() and
envVar = read.getPropertyName()
) or
node =
any(DataFlow::CallNode call |
call.getCalleeName().matches("get%EnvParam") and
envVar = call.getArgument(0).getStringValue()
)
}

from DataFlow::Node read, string envVar
where
envVarRead(read, envVar) and
not isSafeForDefaultSetup(envVar)
select read,
"The environment variable " + envVar +
" may not exist in default setup workflows. If all uses are safe, add it to the list of " +
"environment variables that are known to be safe in " +
"'queries/default-setup-environment-variables.ql'. If this use is safe but others are not, " +
"dismiss this alert as a false positive."
58 changes: 58 additions & 0 deletions queries/default-setup-event-context.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @name Some context properties may not exist in default setup workflows
* @id javascript/codeql-action/default-setup-context-properties
* @kind path-problem
* @severity warning
*/

import javascript
import DataFlow::PathGraph

class NotParsedLabel extends DataFlow::FlowLabel {
NotParsedLabel() { this = "not-parsed" }
}

class ParsedLabel extends DataFlow::FlowLabel {
ParsedLabel() { this = "parsed" }
}

class EventContextAccessConfiguration extends DataFlow::Configuration {
EventContextAccessConfiguration() { this = "EventContextAccessConfiguration" }

override predicate isSource(DataFlow::Node source, DataFlow::FlowLabel lbl) {
source = NodeJSLib::process().getAPropertyRead("env").getAPropertyRead("GITHUB_EVENT_PATH") and
lbl instanceof NotParsedLabel
}

override predicate isSink(DataFlow::Node sink, DataFlow::FlowLabel lbl) {
sink instanceof DataFlow::PropRead and
lbl instanceof ParsedLabel and
not exists(DataFlow::PropRead n | sink = n.getBase()) and
not sink.asExpr().getFile().getBaseName().matches("%.test.ts")
}

override predicate isAdditionalFlowStep(
DataFlow::Node src, DataFlow::Node trg, DataFlow::FlowLabel inlbl, DataFlow::FlowLabel outlbl
) {
src = trg.(FileSystemReadAccess).getAPathArgument() and inlbl = outlbl
or
exists(JsonParserCall c |
src = c.getInput() and
trg = c.getOutput() and
inlbl instanceof NotParsedLabel and
outlbl instanceof ParsedLabel
)
or
(
TaintTracking::sharedTaintStep(src, trg) or
DataFlow::SharedFlowStep::step(src, trg) or
DataFlow::SharedFlowStep::step(src, trg, _, _)
) and
inlbl = outlbl
}
}

from EventContextAccessConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
where cfg.hasFlowPath(source, sink)
select sink.getNode(), source, sink,
"This event context property may not exist in default setup workflows."
16 changes: 9 additions & 7 deletions queries/inconsistent-action-input.ql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* must be defined in an identical way to avoid confusion for the user.
* This also makes writing queries like required-action-input.ql easier.
* @kind problem
* @problem.severity error
* @severity error
* @id javascript/codeql-action/inconsistent-action-input
*/

Expand All @@ -15,7 +15,9 @@ import javascript
*/
class ActionDeclaration extends File {
ActionDeclaration() {
getRelativePath().matches("%/action.yml")
getRelativePath().matches("%/action.yml") and
// Ignore internal Actions
not getRelativePath().matches(".github/actions/%")
}

/**
Expand All @@ -25,19 +27,19 @@ class ActionDeclaration extends File {
result = getRelativePath().regexpCapture("(.*)/action.yml", 1)
}

YAMLDocument getRootNode() {
YamlDocument getRootNode() {
result.getFile() = this
}

YAMLValue getInput(string inputName) {
result = getRootNode().(YAMLMapping).lookup("inputs").(YAMLMapping).lookup(inputName)
YamlValue getInput(string inputName) {
result = getRootNode().(YamlMapping).lookup("inputs").(YamlMapping).lookup(inputName)
}
}

predicate areNotEquivalent(YAMLValue x, YAMLValue y) {
predicate areNotEquivalent(YamlValue x, YamlValue y) {
x.getTag() != y.getTag()
or
x.(YAMLScalar).getValue() != y.(YAMLScalar).getValue()
x.(YamlScalar).getValue() != y.(YamlScalar).getValue()
or
x.getNumChild() != y.getNumChild()
or
Expand Down
2 changes: 1 addition & 1 deletion src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ export async function isAnalyzingDefaultBranch(): Promise<boolean> {
let defaultBranch = event?.repository?.default_branch;

if (process.env.GITHUB_EVENT_NAME === "schedule") {
defaultBranch = removeRefsHeadsPrefix(getRequiredEnvParam("GITHUB_REF"));
defaultBranch = removeRefsHeadsPrefix(getRefFromEnv());
}

return currentRef === defaultBranch;
Expand Down