@@ -35,7 +35,9 @@ class GitHubDownloadArtifactActionStep extends UntrustedArtifactDownloadStep, Us
3535 }
3636
3737 override string getPath ( ) {
38- if exists ( this .getArgument ( "path" ) ) then result = this .getArgument ( "path" ) else result = ""
38+ if exists ( this .getArgument ( "path" ) )
39+ then result = normalizePath ( this .getArgument ( "path" ) )
40+ else result = "GITHUB_WORKSPACE/"
3941 }
4042}
4143
@@ -79,11 +81,11 @@ class DownloadArtifactActionStep extends UntrustedArtifactDownloadStep, UsesStep
7981
8082 override string getPath ( ) {
8183 if exists ( this .getArgument ( [ "path" , "download_path" ] ) )
82- then result = this .getArgument ( [ "path" , "download_path" ] )
84+ then result = normalizePath ( this .getArgument ( [ "path" , "download_path" ] ) )
8385 else
8486 if exists ( this .getArgument ( "paths" ) )
85- then result = this .getArgument ( "paths" ) .splitAt ( " " )
86- else result = ""
87+ then result = normalizePath ( this .getArgument ( "paths" ) .splitAt ( " " ) )
88+ else result = "GITHUB_WORKSPACE/ "
8789 }
8890}
8991
@@ -114,8 +116,8 @@ class LegitLabsDownloadArtifactActionStep extends UntrustedArtifactDownloadStep,
114116
115117 override string getPath ( ) {
116118 if exists ( this .getArgument ( "path" ) )
117- then result = this .getArgument ( "path" )
118- else result = ". /artifacts"
119+ then result = normalizePath ( this .getArgument ( "path" ) )
120+ else result = "GITHUB_WORKSPACE /artifacts"
119121 }
120122}
121123
@@ -161,14 +163,14 @@ class ActionsGitHubScriptDownloadStep extends UntrustedArtifactDownloadStep, Use
161163 .regexpMatch ( unzipRegexp ( ) + unzipDirArgRegexp ( ) )
162164 then
163165 result =
164- trimQuotes ( this .getAFollowingStep ( )
165- .( Run )
166- .getScript ( )
167- .splitAt ( "\n" )
168- .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) )
166+ normalizePath ( trimQuotes ( this .getAFollowingStep ( )
167+ .( Run )
168+ .getScript ( )
169+ .splitAt ( "\n" )
170+ .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) )
169171 else
170172 if this .getAFollowingStep ( ) .( Run ) .getScript ( ) .splitAt ( "\n" ) .regexpMatch ( unzipRegexp ( ) )
171- then result = ""
173+ then result = "GITHUB_WORKSPACE/ "
172174 else none ( )
173175 }
174176}
@@ -197,18 +199,20 @@ class GHRunArtifactDownloadStep extends UntrustedArtifactDownloadStep, Run {
197199 script .splitAt ( "\n" ) .regexpMatch ( unzipRegexp ( ) + unzipDirArgRegexp ( ) )
198200 then
199201 result =
200- trimQuotes ( script .splitAt ( "\n" ) .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) or
202+ normalizePath ( trimQuotes ( script
203+ .splitAt ( "\n" )
204+ .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) ) or
201205 result =
202- trimQuotes ( this .getAFollowingStep ( )
203- .( Run )
204- .getScript ( )
205- .splitAt ( "\n" )
206- .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) )
206+ normalizePath ( trimQuotes ( this .getAFollowingStep ( )
207+ .( Run )
208+ .getScript ( )
209+ .splitAt ( "\n" )
210+ .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) )
207211 else
208212 if
209213 this .getAFollowingStep ( ) .( Run ) .getScript ( ) .splitAt ( "\n" ) .regexpMatch ( unzipRegexp ( ) ) or
210214 script .splitAt ( "\n" ) .regexpMatch ( unzipRegexp ( ) )
211- then result = ""
215+ then result = "GITHUB_WORKSPACE/ "
212216 else none ( )
213217 }
214218}
@@ -244,14 +248,16 @@ class DirectArtifactDownloadStep extends UntrustedArtifactDownloadStep, Run {
244248 .regexpMatch ( unzipRegexp ( ) + unzipDirArgRegexp ( ) )
245249 then
246250 result =
247- trimQuotes ( script .splitAt ( "\n" ) .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) or
251+ normalizePath ( trimQuotes ( script
252+ .splitAt ( "\n" )
253+ .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) ) or
248254 result =
249- trimQuotes ( this .getAFollowingStep ( )
250- .( Run )
251- .getScript ( )
252- .splitAt ( "\n" )
253- .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) )
254- else result = ""
255+ normalizePath ( trimQuotes ( this .getAFollowingStep ( )
256+ .( Run )
257+ .getScript ( )
258+ .splitAt ( "\n" )
259+ .regexpCapture ( unzipRegexp ( ) + unzipDirArgRegexp ( ) , 2 ) ) )
260+ else result = "GITHUB_WORKSPACE/ "
255261 }
256262}
257263
@@ -268,18 +274,16 @@ class ArtifactPoisoningSink extends DataFlow::Node {
268274 (
269275 // Check if the poisonable step is a local script execution step
270276 // and the path of the command or script matches the path of the downloaded artifact
277+ isSubpath ( poisonable .( LocalScriptExecutionRunStep ) .getPath ( ) , download .getPath ( ) )
278+ or
271279 // Checking the path for non local script execution steps is very difficult
272280 not poisonable instanceof LocalScriptExecutionRunStep
273- or
274- // TODO: account for Run's working directory
275- poisonable
276- .( LocalScriptExecutionRunStep )
277- .getCommand ( )
278- .matches ( [ "./" , "" ] + download .getPath ( ) + "%" )
281+ // Its not easy to extract the path from a non-local script execution step so skipping this check for now
282+ // and isSubpath(poisonable.(Run).getWorkingDirectory(), download.getPath())
279283 )
280284 or
281285 poisonable .( UsesStep ) = this .asExpr ( ) and
282- download .getPath ( ) = ""
286+ download .getPath ( ) = "GITHUB_WORKSPACE/ "
283287 )
284288 }
285289
0 commit comments