@@ -359,18 +359,6 @@ class CompositeActionImpl extends AstNodeImpl, TCompositeAction {
359359 }
360360
361361 EventImpl getATriggerEvent ( ) { result = this .getACallerJob ( ) .getATriggerEvent ( ) }
362-
363- /** Holds if the action is privileged and externally triggerable. */
364- predicate isPrivilegedExternallyTriggerable ( ) {
365- // the action is externally triggerable
366- exists ( JobImpl caller , EventImpl event |
367- caller = this .getACallerJob ( ) and
368- event = caller .getATriggerEvent ( ) and
369- event .isExternallyTriggerable ( ) and
370- // the action is privileged
371- ( this .isPrivileged ( ) or caller .isPrivileged ( ) )
372- )
373- }
374362}
375363
376364class WorkflowImpl extends AstNodeImpl , TWorkflowNode {
@@ -970,31 +958,30 @@ class JobImpl extends AstNodeImpl, TJobNode {
970958 }
971959
972960 /** Holds if the action is privileged and externally triggerable. */
973- predicate isPrivilegedExternallyTriggerable ( ) {
974- exists ( EventImpl e | this .getATriggerEvent ( ) = e |
975- // job is triggereable by an external user
976- e .isExternallyTriggerable ( ) and
977- // no matter if `pull_request` is granted write permissions or access to secrets
978- // when the job is triggered by a `pull_request` event from a fork, they will get revoked
979- not e .getName ( ) = "pull_request" and
980- (
981- // job is privileged (write access or access to secrets)
982- this .isPrivileged ( )
983- or
984- // the trigger event is __normally__ privileged
985- e .isPrivileged ( ) and
986- // and we have no runtime data to prove otherwise
987- not this .hasRuntimeData ( ) and
988- // and the job is not explicitly non-privileged
989- not (
990- (
991- this .hasExplicitNonePermission ( ) or
992- this .hasImplicitNonePermission ( ) or
993- this .hasExplicitReadPermission ( ) or
994- this .hasImplicitReadPermission ( )
995- ) and
996- not this .hasExplicitSecretAccess ( )
997- )
961+ predicate isPrivilegedExternallyTriggerable ( EventImpl event ) {
962+ this .getATriggerEvent ( ) = event and
963+ // job is triggereable by an external user
964+ event .isExternallyTriggerable ( ) and
965+ // no matter if `pull_request` is granted write permissions or access to secrets
966+ // when the job is triggered by a `pull_request` event from a fork, they will get revoked
967+ not event .getName ( ) = "pull_request" and
968+ (
969+ // job is privileged (write access or access to secrets)
970+ this .isPrivileged ( )
971+ or
972+ // the trigger event is __normally__ privileged
973+ event .isPrivileged ( ) and
974+ // and we have no runtime data to prove otherwise
975+ not this .hasRuntimeData ( ) and
976+ // and the job is not explicitly non-privileged
977+ not (
978+ (
979+ this .hasExplicitNonePermission ( ) or
980+ this .hasImplicitNonePermission ( ) or
981+ this .hasExplicitReadPermission ( ) or
982+ this .hasImplicitReadPermission ( )
983+ ) and
984+ not this .hasExplicitSecretAccess ( )
998985 )
999986 )
1000987 }
@@ -1073,6 +1060,12 @@ class StepImpl extends AstNodeImpl, TStepNode {
10731060
10741061 override YamlMapping getNode ( ) { result = n }
10751062
1063+ override JobImpl getEnclosingJob ( ) {
1064+ // if a step is within a composite action, we should follow the caller job
1065+ result = this .getEnclosingCompositeAction ( ) .getACallerJob ( ) or
1066+ result = super .getEnclosingJob ( )
1067+ }
1068+
10761069 EnvImpl getEnv ( ) { result .getNode ( ) = n .lookup ( "env" ) }
10771070
10781071 /** Gets the ID of this step, if any. */
0 commit comments