Skip to content

Commit 6eef51e

Browse files
author
Alvaro Muñoz
committed
fix: add path checks
1 parent fefeae4 commit 6eef51e

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

ql/src/Security/CWE-312/SecretsInArtifacts.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ where
3535
"v4.2.0", "694cdabd8bdb0f10b2cea11669e1bf5453eed0a6", //
3636
"v4.1.0", "1eb3cb2b3e0f29609092a73eb033bb759a334595", //
3737
"v4.0.0", "c7d193f32edcb7bfad88892161225aeda64e9392", //
38-
]
38+
] and
39+
(
40+
not exists(checkout.getArgument("path")) and
41+
upload.getArgument("path") = [".", "*"]
42+
or
43+
checkout.getArgument("path") + ["", "/*"] = upload.getArgument("path")
44+
)
3945
select upload, "A secret is exposed in a public artifact uploaded by $@", upload,
4046
"actions/upload-artifact"

ql/test/query-tests/Security/CWE-312/.github/workflows/secrets-in-artifacts.yml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,63 @@ name: secrets-in-artifacts
22
on:
33
pull_request:
44
jobs:
5-
test1:
5+
test1: # VULNERABLE
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
99
- name: "Upload artifact"
1010
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
1111
with:
1212
name: file
13-
path: results
14-
test2:
13+
path: .
14+
test2: # NOT VULNERABLE
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: "Upload artifact"
1919
uses: actions/upload-artifact@v4
2020
with:
2121
name: file
22-
path: results
23-
22+
path: .
23+
test3: # VULNERABLE
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: "Upload artifact"
28+
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
29+
with:
30+
name: file
31+
path: "*"
32+
test4: # VULNERABLE
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
path: foo
38+
- name: "Upload artifact"
39+
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
40+
with:
41+
name: file
42+
path: foo
43+
test5: # VULNERABLE
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
path: foo
49+
- name: "Upload artifact"
50+
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
51+
with:
52+
name: file
53+
path: foo/*
54+
test6: # NOT VULNERABLE
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
path: pr
60+
- name: "Upload artifact"
61+
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
62+
with:
63+
name: file
64+
path: foo
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
| .github/workflows/secrets-in-artifacts.yml:9:9:14:2 | Uses Step | A secret is exposed in a public artifact uploaded by $@ | .github/workflows/secrets-in-artifacts.yml:9:9:14:2 | Uses Step | actions/upload-artifact |
2+
| .github/workflows/secrets-in-artifacts.yml:27:9:32:2 | Uses Step | A secret is exposed in a public artifact uploaded by $@ | .github/workflows/secrets-in-artifacts.yml:27:9:32:2 | Uses Step | actions/upload-artifact |
3+
| .github/workflows/secrets-in-artifacts.yml:38:9:43:2 | Uses Step | A secret is exposed in a public artifact uploaded by $@ | .github/workflows/secrets-in-artifacts.yml:38:9:43:2 | Uses Step | actions/upload-artifact |
4+
| .github/workflows/secrets-in-artifacts.yml:49:9:54:2 | Uses Step | A secret is exposed in a public artifact uploaded by $@ | .github/workflows/secrets-in-artifacts.yml:49:9:54:2 | Uses Step | actions/upload-artifact |

0 commit comments

Comments
 (0)