Skip to content

Commit 7ea3831

Browse files
committed
🐛 detect label names in dangerous workflows
Signed-off-by: Adam Korczynski <[email protected]>
1 parent c29a04d commit 7ea3831

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+
`pull_request\.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
@@ -76,6 +76,16 @@ func TestUntrustedContextVariables(t *testing.T) {
7676
variable: "github.event.commits[0].id",
7777
expected: false,
7878
},
79+
{
80+
name: "PR label name",
81+
variable: "github.event.pull_request.labels.foo.name",
82+
expected: true,
83+
},
84+
{
85+
name: "PR label wildcard name",
86+
variable: "github.event.pull_request.labels.*.name",
87+
expected: true,
88+
},
7989
}
8090
for _, tt := range tests {
8191
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)