55import actions
66private import codeql.util.Unit
77private import codeql.actions.DataFlow
8+ import codeql.actions.dataflow.ExternalFlow
89
910/**
1011 * A unit class for adding additional taint steps.
@@ -20,16 +21,23 @@ class AdditionalTaintStep extends Unit {
2021 abstract predicate step ( DataFlow:: Node node1 , DataFlow:: Node node2 ) ;
2122}
2223
23- /**
24- * Holds if actions-find-and-replace-string step is used.
25- */
26- private class ActionsFindAndReplaceStringStep extends AdditionalTaintStep {
24+ predicate externallyDefinedSummary ( DataFlow:: Node pred , DataFlow:: Node succ ) {
25+ exists ( UsesExpr uses , string action , string version , string input |
26+ /*, string output */ summaryModel ( action , version , input , _, "taint" ) and
27+ uses .getCallee ( ) = action and
28+ (
29+ if version .trim ( ) = "*"
30+ then uses .getVersion ( ) = any ( string v )
31+ else uses .getVersion ( ) = version .splitAt ( "," ) .trim ( )
32+ ) and
33+ pred .asExpr ( ) = uses .getArgumentExpr ( input .splitAt ( "," ) .trim ( ) ) and
34+ succ .asExpr ( ) = uses
35+ )
36+ }
37+
38+ private class ExternallyDefinedSummary extends AdditionalTaintStep {
2739 override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
28- exists ( UsesExpr u |
29- u .getCallee ( ) = "mad9000/actions-find-and-replace-string" and
30- pred .asExpr ( ) = u .getArgumentExpr ( [ "source" , "replace" ] ) and
31- succ .asExpr ( ) = u
32- )
40+ externallyDefinedSummary ( pred , succ )
3341 }
3442}
3543
@@ -46,10 +54,12 @@ private class ActionsFindAndReplaceStringStep extends AdditionalTaintStep {
4654 * echo "::set-output name=initial_url::$INITIAL_URL"
4755 */
4856private class RunEnvToScriptStep extends AdditionalTaintStep {
49- override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) { test ( pred , succ ) }
57+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
58+ runEnvToScriptstep ( pred , succ )
59+ }
5060}
5161
52- predicate test ( DataFlow:: Node pred , DataFlow:: Node succ ) {
62+ predicate runEnvToScriptstep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
5363 exists ( RunExpr r , string varName |
5464 r .getEnvExpr ( varName ) = pred .asExpr ( ) and
5565 exists ( string script , string line |
0 commit comments