Skip to content

Commit db69b78

Browse files
committed
Actions tests: add lockfile inline expectations
1 parent 75cbb24 commit db69b78

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

actions/ql/test/query-tests/Security/CWE-829-Lockfile/.github/workflows/rust-ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
steps:
88
- uses: dtolnay/rust-toolchain@v1
99
- uses: DToLnAy/RuSt-ToOlChAiN/save@v1
10-
- uses: dtolnay/rust-toolchain@V1
11-
- uses: other-workflow/action@v1
12-
- uses: mismatched/action@v1
13-
- uses: malformed/action@v1
14-
- uses: missing/action@v1
10+
- uses: dtolnay/rust-toolchain@V1 # $ Alert
11+
- uses: other-workflow/action@v1 # $ Alert
12+
- uses: mismatched/action@v1 # $ Alert
13+
- uses: malformed/action@v1 # $ Alert
14+
- uses: missing/action@v1 # $ Alert
1515
reusable:
16-
uses: dtolnay/rust-toolchain/.github/workflows/reusable.yml@v1
16+
uses: dtolnay/rust-toolchain/.github/workflows/reusable.yml@v1 # $ Alert
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @kind test-postprocess
3+
*/
4+
5+
private import codeql.Locations as Locations
6+
private import codeql.actions.ast.internal.Yaml as Yaml
7+
private import codeql.util.test.InlineExpectationsTest as T
8+
import T::TestPostProcessing
9+
10+
private module Impl implements T::InlineExpectationsTestSig {
11+
class Location = Locations::Location;
12+
13+
class ExpectationComment extends Yaml::YamlComment {
14+
string getContents() { result = this.getText() }
15+
}
16+
}
17+
18+
private module Input implements T::TestPostProcessing::InputSig<Impl> {
19+
string getRelativeUrl(Locations::Location location) {
20+
exists(int startLine, int startColumn, int endLine, int endColumn |
21+
location.hasLocationInfo(_, startLine, startColumn, endLine, endColumn)
22+
|
23+
result =
24+
location.getFile().getRelativePath() + ":" + startLine + ":" + startColumn + ":" + endLine +
25+
":" + endColumn
26+
)
27+
}
28+
}
29+
30+
import T::TestPostProcessing::Make<Impl, Input>

actions/ql/test/query-tests/Security/CWE-829-Lockfile/UnpinnedActionsTag.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
| .github/workflows/rust-ci.yml:12:13:12:32 | mismatched/action@v1 | Unpinned 3rd party Action 'rust-ci.yml' step $@ uses 'mismatched/action' with ref 'v1', not a pinned commit hash | .github/workflows/rust-ci.yml:12:7:13:4 | Uses Step | Uses Step |
44
| .github/workflows/rust-ci.yml:13:13:13:31 | malformed/action@v1 | Unpinned 3rd party Action 'rust-ci.yml' step $@ uses 'malformed/action' with ref 'v1', not a pinned commit hash | .github/workflows/rust-ci.yml:13:7:14:4 | Uses Step | Uses Step |
55
| .github/workflows/rust-ci.yml:14:13:14:29 | missing/action@v1 | Unpinned 3rd party Action 'rust-ci.yml' step $@ uses 'missing/action' with ref 'v1', not a pinned commit hash | .github/workflows/rust-ci.yml:14:7:15:2 | Uses Step | Uses Step |
6-
| .github/workflows/rust-ci.yml:16:11:16:66 | dtolnay/rust-toolchain/.github/workflows/reusable.yml@v1 | Job $@ in 'rust-ci.yml' uses reusable workflow 'dtolnay/rust-toolchain/.github/workflows/reusable.yml' with ref 'v1', not a pinned commit hash | .github/workflows/rust-ci.yml:16:5:16:67 | Job: reusable | Job: reusable |
6+
| .github/workflows/rust-ci.yml:16:11:16:66 | dtolnay/rust-toolchain/.github/workflows/reusable.yml@v1 | Job $@ in 'rust-ci.yml' uses reusable workflow 'dtolnay/rust-toolchain/.github/workflows/reusable.yml' with ref 'v1', not a pinned commit hash | .github/workflows/rust-ci.yml:16:5:16:77 | Job: reusable | Job: reusable |
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Security/CWE-829/UnpinnedActionsTag.ql
1+
query: Security/CWE-829/UnpinnedActionsTag.ql
2+
postprocess: InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)