Skip to content

Commit 6b11506

Browse files
author
Alvaro Muñoz
committed
test: Add tests
1 parent cbe43bf commit 6b11506

File tree

76 files changed

+833
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+833
-216
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
**/*.testproj
33
ql/lib/.codeql/
44
ql/src/.codeql/
5+
ql/test/.codeql/

build-test-dbs.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

codeql-workspace.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
provide:
22
- "**/ql/src/qlpack.yml"
3-
- "**/ql/lib/qlpack.yml"
3+
- "**/ql/lib/qlpack.yml"
4+
- "**/ql/test/qlpack.yml"

ql/lib/codeql/actions/Ast.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,12 @@ class StepUsesExpr extends StepStmt, UsesExpr {
270270

271271
override string getCallee() { result = uses.getGitHubRepository() }
272272

273-
override string getVersion() { result = uses.getVersion() }
273+
override string getVersion() {
274+
result = uses.getVersion()
275+
or
276+
not exists(uses.getVersion()) and
277+
result = "main"
278+
}
274279

275280
override Expression getArgumentExpr(string key) {
276281
exists(Actions::With with |

ql/lib/codeql/actions/ast/internal/Actions.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import codeql.actions.ast.internal.Yaml
77
import codeql.files.FileSystem
88

9-
// ALVARO: Make it private
109
/**
1110
* Libraries for modeling GitHub Actions workflow files written in YAML.
1211
* See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions.
@@ -376,7 +375,6 @@ module Actions {
376375
}
377376

378377
/**
379-
* ALVARO
380378
* https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds
381379
*/
382380
class Needs extends YamlNode {

ql/lib/qlpack.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies:
1010
codeql/dataflow: ^0.1.7
1111
dbscheme: yaml.dbscheme
1212
extractor: yaml
13-
tests: test
1413
groups:
1514
- yaml
1615
dataExtensions:

ql/src/Security/CWE-829/UnpinnedActionsTag.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ private predicate isTrustedOrg(string repo) {
2424
from StepUsesExpr uses, string repo, string version, WorkflowStmt workflow, string name
2525
where
2626
uses.getCallee() = repo and
27-
uses.getVersion() = version and
2827
uses.getEnclosingWorkflowStmt() = workflow and
2928
(
3029
workflow.getName() = name
3130
or
3231
not exists(workflow.getName()) and workflow.getLocation().getFile().getBaseName() = name
3332
) and
34-
not isPinnedCommit(version) and
35-
not isTrustedOrg(repo)
33+
uses.getVersion() = version and
34+
not isTrustedOrg(repo) and
35+
not isPinnedCommit(version)
3636
select uses,
3737
"Unpinned 3rd party Action '" + name + "' step $@ uses '" + repo + "' with ref '" + version +
3838
"', not a pinned commit hash", uses, uses.toString()

ql/src/Security/CWE-094/UntrustedCheckout.ql renamed to ql/src/Security/CWE-829/UntrustedCheckout.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @id actions/untrusted-checkout
1111
* @tags actions
1212
* security
13-
* external/cwe/cwe-094
13+
* external/cwe/cwe-829
1414
*/
1515

1616
import actions

0 commit comments

Comments
 (0)