@@ -49,8 +49,15 @@ predicate envToEnvStoreStep(DataFlow::Node pred, DataFlow::Node succ, DataFlow::
4949 * echo "bar=${foo}" >> "$GITHUB_OUTPUT"
5050 */
5151predicate commandToOutputStoreStep ( DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: ContentSet c ) {
52- exists ( CommandSource source , Run run , string key , string cmd |
53- source .getCommand ( ) = cmd and
52+ exists ( Run run , string key , string cmd |
53+ (
54+ exists ( CommandSource source | source .getCommand ( ) = cmd )
55+ or
56+ exists ( FileSource source |
57+ source .asExpr ( ) .( Step ) .getAFollowingStep ( ) = run and
58+ Bash:: outputsPartialFileContent ( run , cmd )
59+ )
60+ ) and
5461 Bash:: cmdReachingGitHubFileWrite ( run , cmd , "GITHUB_OUTPUT" , key ) and
5562 c = any ( DataFlow:: FieldContent ct | ct .getName ( ) = key ) and
5663 pred .asExpr ( ) = run .getScriptScalar ( ) and
@@ -67,50 +74,19 @@ predicate commandToOutputStoreStep(DataFlow::Node pred, DataFlow::Node succ, Dat
6774 * echo "bar=${foo}" >> "$GITHUB_ENV"
6875 */
6976predicate commandToEnvStoreStep ( DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: ContentSet c ) {
70- exists ( CommandSource source , Run run , string key , string cmd |
71- source .getCommand ( ) = cmd and
77+ exists ( Run run , string key , string cmd |
78+ (
79+ exists ( CommandSource source | source .getCommand ( ) = cmd )
80+ or
81+ exists ( FileSource source |
82+ source .asExpr ( ) .( Step ) .getAFollowingStep ( ) = run and
83+ Bash:: outputsPartialFileContent ( run , cmd )
84+ )
85+ ) and
7286 Bash:: cmdReachingGitHubFileWrite ( run , cmd , "GITHUB_ENV" , key ) and
7387 c = any ( DataFlow:: FieldContent ct | ct .getName ( ) = key ) and
7488 pred .asExpr ( ) = run .getScriptScalar ( ) and
7589 // we store the taint on the enclosing job since there may not be an implicit env attribute
7690 succ .asExpr ( ) = run .getEnclosingJob ( )
7791 )
7892}
79-
80- /**
81- * A downloaded artifact that gets assigned to a Run step output.
82- * - uses: actions/download-artifact@v2
83- * - run: echo "::set-output name=id::$(<pr-id.txt)"
84- * - run: |
85- * foo=$(<pr-id.txt)"
86- * echo "::set-output name=id::$foo
87- */
88- predicate fileToOutputStoreStep ( DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: ContentSet c ) {
89- exists ( FileSource source , Run run , string key , string cmd |
90- source .asExpr ( ) .( Step ) .getAFollowingStep ( ) = run and
91- Bash:: cmdReachingGitHubFileWrite ( run , cmd , "GITHUB_OUTPUT" , key ) and
92- Bash:: outputsPartialFileContent ( run , cmd ) and
93- c = any ( DataFlow:: FieldContent ct | ct .getName ( ) = key ) and
94- pred .asExpr ( ) = run .getScriptScalar ( ) and
95- succ .asExpr ( ) = run
96- )
97- }
98-
99- /**
100- * A downloaded artifact that gets assigned to an environment variable.
101- * - run: echo "foo=$(<pr-id.txt)" >> "$GITHUB_ENV"
102- * - run: |
103- * foo=$(<pr-id.txt)"
104- * echo "bar=${foo}" >> "$GITHUB_ENV"
105- */
106- predicate fileToEnvStoreStep ( DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: ContentSet c ) {
107- exists ( FileSource source , Run run , string key , string cmd |
108- source .asExpr ( ) .( Step ) .getAFollowingStep ( ) = run and
109- Bash:: cmdReachingGitHubFileWrite ( run , cmd , "GITHUB_ENV" , key ) and
110- Bash:: outputsPartialFileContent ( run , cmd ) and
111- c = any ( DataFlow:: FieldContent ct | ct .getName ( ) = key ) and
112- pred .asExpr ( ) = run .getScriptScalar ( ) and
113- // we store the taint on the enclosing job since there may not be an implicit env attribute
114- succ .asExpr ( ) = run .getEnclosingJob ( )
115- )
116- }
0 commit comments