File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ func containsUntrustedContextPattern(variable string) bool {
5252 if strings .Contains (variable , "github.head_ref" ) {
5353 return true
5454 }
55- return strings .Contains (variable , "github.event." ) && untrustedContextPattern .MatchString (variable )
55+ return strings .Contains (variable , "github.event." ) &&
56+ (untrustedContextPattern .MatchString (variable ) ||
57+ untrustedContextPattern .MatchString (fmt .Sprintf ("toJSON(%s)" , variable )))
5658}
5759
5860type triggerName string
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package raw
1717import (
1818 "context"
1919 "errors"
20+ "fmt"
2021 "io"
2122 "os"
2223 "testing"
@@ -83,6 +84,9 @@ func TestUntrustedContextVariables(t *testing.T) {
8384 if r := containsUntrustedContextPattern (tt .variable ); ! r == tt .expected {
8485 t .Fail ()
8586 }
87+ if r := containsUntrustedContextPattern (fmt .Sprintf ("toJSON(%s)" , tt .variable )); ! r == tt .expected {
88+ t .Fail ()
89+ }
8690 })
8791 }
8892}
You can’t perform that action at this time.
0 commit comments