Skip to content

Commit ab8dd59

Browse files
author
Alvaro Muñoz
committed
fix(queries): Fix Missing Permissions query
If a job is only triggered by `workflow_call`, we dont report any issues since they should be reported on the calling workflows
1 parent 8ffac29 commit ab8dd59

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

ql/src/Security/CWE-275/MissingActionsPermissions.ql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
import actions
1515

16-
from Workflow workflow, Job job
16+
from Job job
1717
where
18-
job = workflow.getAJob() and
19-
(
20-
not exists(workflow.getPermissions()) and
21-
not exists(job.getPermissions())
18+
not exists(job.getPermissions()) and
19+
not exists(job.getEnclosingWorkflow().getPermissions()) and
20+
// exists a trigger event that is not a workflow_call
21+
exists(Event e |
22+
e = job.getATriggerEvent() and
23+
not e.getName() = "workflow_call"
2224
)
2325
select job, "Actions Job or Workflow does not set permissions"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
pull_request
3+
4+
jobs:
5+
build:
6+
name: Build and test
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
test:
11+
name: Build and test
12+
runs-on: ubuntu-latest
13+
permissions: {}
14+
steps:
15+
- uses: actions/checkout@v2
16+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
name: Build and test
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
on:
2+
workflow_call:
3+
workflow_dispatch:
4+
5+
jobs:
6+
build:
7+
name: Build and test
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
| .github/workflows/missing_perms.yml:6:5:9:32 | Job: build | Actions Job or Workflow does not set permissions |
1+
| .github/workflows/perms1.yml:6:5:9:32 | Job: build | Actions Job or Workflow does not set permissions |
2+
| .github/workflows/perms2.yml:6:5:10:2 | Job: build | Actions Job or Workflow does not set permissions |
3+
| .github/workflows/perms5.yml:7:5:10:32 | Job: build | Actions Job or Workflow does not set permissions |

0 commit comments

Comments
 (0)