Skip to content

Commit 5d9fe37

Browse files
committed
🐛 detect label names in dangerous workflows
Signed-off-by: Adam Korczynski <adam@adalogics.com>
1 parent ddedf1e commit 5d9fe37

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

checks/raw/dangerous_workflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func containsUntrustedContextPattern(variable string) bool {
3535
`issue\.body|` +
3636
`pull_request\.title|` +
3737
`pull_request\.body|` +
38+
`labels\.[^.]+\.name|` +
3839
`comment\.body|` +
3940
`review\.body|` +
4041
`review_comment\.body|` +

checks/raw/dangerous_workflow_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ func TestUntrustedContextVariables(t *testing.T) {
8686
variable: "github.event.commits[2].author.email",
8787
expected: true,
8888
},
89+
{
90+
name: "PR label name",
91+
variable: "github.event.pull_request.labels.foo.name",
92+
expected: true,
93+
},
94+
{
95+
name: "PR label wildcard name",
96+
variable: "github.event.pull_request.labels.*.name",
97+
expected: true,
98+
},
8999
}
90100
for _, tt := range tests {
91101
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)