@@ -18,8 +18,8 @@ private string dangerousCommands() {
18
18
[
19
19
"npm install" , "npm run " , "yarn " , "npm ci(\\b|$)" , "make " , "terraform plan" ,
20
20
"terraform apply" , "gomplate " , "pre-commit run" , "pre-commit install" , "go generate" ,
21
- "msbuild " , "mvn " , "./mvnw " , "gradle " , "./gradlew " , "bundle install " , "bundle exec " ,
22
- "^ant " , "mkdocs build " , "pytest "
21
+ "msbuild " , "mvn " , "gradle " , "bundle install " , "bundle exec " , "^ant " , "mkdocs build " ,
22
+ "pytest" , "pip install -r " , "pip install --requirement " , "java -jar "
23
23
]
24
24
}
25
25
@@ -31,21 +31,33 @@ class BuildRunStep extends PoisonableStep, Run {
31
31
}
32
32
}
33
33
34
+ bindingset [ cmdRegexp]
35
+ string wrapLocalCmd ( string cmdRegexp ) { result = "(^|;\\s*|\\s+)" + cmdRegexp + "(\\s+|;|$)" }
36
+
34
37
class LocalCommandExecutionRunStep extends PoisonableStep , Run {
35
38
string cmd ;
36
39
37
40
LocalCommandExecutionRunStep ( ) {
38
41
// Heuristic:
39
- // Run step with a command starting with `./xxxx`, `sh xxxx`, ...
40
42
exists ( string line | line = this .getScript ( ) .splitAt ( "\n" ) .trim ( ) |
41
43
// ./xxxx
42
- cmd = line .regexpCapture ( "(^|\\s+)\\.\\/(.*)" , 2 )
44
+ // TODO: It could also be in the form of `dir/cmd`
45
+ cmd = line .regexpCapture ( wrapLocalCmd ( "\\.\\/(.*)" ) , 2 )
43
46
or
44
47
// sh xxxx
45
- cmd = line .regexpCapture ( "(^|\\s+)(ba|z|fi)?sh\\s+(.*)" , 3 )
48
+ cmd = line .regexpCapture ( wrapLocalCmd ( "(ba|z|fi)?sh\\s+(.*)" ) , 3 )
49
+ or
50
+ // node xxxx.js
51
+ cmd = line .regexpCapture ( wrapLocalCmd ( "node\\s+(.*)(\\.js|\\.ts)" ) , 2 )
52
+ or
53
+ // python xxxx.py
54
+ cmd = line .regexpCapture ( wrapLocalCmd ( "python\\s+(.*)\\.py" ) , 2 )
55
+ or
56
+ // ruby xxxx.rb
57
+ cmd = line .regexpCapture ( wrapLocalCmd ( "ruby\\s+(.*)\\.rb" ) , 2 )
46
58
or
47
- // node xxxx
48
- cmd = line .regexpCapture ( "(^|\\s+)(node|python|ruby|go) \\s+(.*)" , 3 )
59
+ // go xxxx.go
60
+ cmd = line .regexpCapture ( wrapLocalCmd ( "go \\s+(.*)\\.go" ) , 2 )
49
61
)
50
62
}
51
63
0 commit comments