Skip to content

Commit 9ecda65

Browse files
author
Alvaro Muñoz
committed
Update Priv workflow definition
1 parent 25eace7 commit 9ecda65

File tree

8 files changed

+102
-23
lines changed

8 files changed

+102
-23
lines changed

ql/lib/codeql-pack.lock.yml

-16
This file was deleted.

ql/lib/codeql/actions/Ast.qll

+9-4
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,33 @@ class Workflow extends AstNode instanceof WorkflowImpl {
208208

209209
predicate hasSingleTrigger(string trigger) {
210210
this.getATriggerEvent() = trigger and
211-
count(string t | this.getATriggerEvent() = t | t) = 1
211+
count(this.getATriggerEvent()) = 1
212212
}
213213

214214
predicate isPrivileged() {
215215
// The Workflow has a permission to write to some scope
216-
this.getPermissions().getAPermission() = "write" and
216+
this.getPermissions().getAPermission() = "write"
217+
or
217218
// The Workflow accesses a secret
218219
exists(SecretsExpression expr |
219220
expr.getEnclosingWorkflow() = this and not expr.getFieldName() = "GITHUB_TOKEN"
220221
)
221222
or
222223
// The Workflow is triggered by an event other than `pull_request`
223-
not this.hasSingleTrigger("pull_request")
224+
count(this.getATriggerEvent()) = 1 and
225+
not this.getATriggerEvent() = ["pull_request", "workflow_call"]
224226
or
225227
// The Workflow is only triggered by `workflow_call` and there is
226228
// a caller workflow triggered by an event other than `pull_request`
227229
this.hasSingleTrigger("workflow_call") and
228230
exists(ExternalJob call, Workflow caller |
229231
call.getCallee() = this.getLocation().getFile().getRelativePath() and
230232
caller = call.getWorkflow() and
231-
not caller.hasSingleTrigger("pull_request")
233+
caller.isPrivileged()
232234
)
235+
or
236+
// The Workflow has multiple triggers so at least one is ont "pull_request"
237+
count(this.getATriggerEvent()) > 1
233238
}
234239
}
235240

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Documentation
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
parse_commit_info:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
can_deploy: ${{ steps.decide.outputs.can_deploy }}
12+
deploy_to: ${{ steps.decide.outputs.deploy_to }}
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Copy build utils
21+
run: |
22+
cp -r .github/utils ../utils
23+
24+
- name: Decide Whether to Build and/or Release
25+
id: decide
26+
run: |
27+
set -xe
28+
CAN_DEPLOY=$(python ../utils/please.py can_i_deploy_documentation)
29+
DEPLOY_TO=$(python ../utils/please.py where_can_i_deploy_documentation)
30+
31+
echo "can_deploy=$CAN_DEPLOY" >> $GITHUB_OUTPUT
32+
echo "deploy_to=$DEPLOY_TO" >> $GITHUB_OUTPUT
33+
echo github.ref ${{ github.ref }}
34+
35+
build-documentation:
36+
runs-on: ubuntu-latest
37+
needs: parse_commit_info
38+
39+
strategy:
40+
matrix:
41+
python-version: [3.11]
42+
43+
steps:
44+
- name: Checkout Code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Install Quarto
53+
uses: quarto-dev/quarto-actions/setup@v2
54+
with:
55+
version: pre-release
56+
57+
- name: Install Package
58+
shell: bash
59+
run: |
60+
make doc-deps
61+
62+
- name: Environment Information
63+
shell: bash
64+
run: |
65+
ls -la
66+
ls -la doc
67+
pip list
68+
69+
- name: Build docs
70+
shell: bash
71+
run: |
72+
pushd doc; make doc; popd
73+
74+
- name: Environment Information
75+
shell: bash
76+
run: |
77+
ls -la doc
78+
cat doc/_variables.yml
79+
ls -la doc/reference
80+
81+
- name: Deploy to Documentation to a Branch
82+
uses: JamesIves/github-pages-deploy-action@v4
83+
if: contains(needs.parse_commit_info.outputs.can_deploy, 'true')
84+
with:
85+
folder: doc/_site
86+
branch: ${{ needs.parse_commit_info.outputs.deploy_to }}
87+
commit-message: ${{ github.event.head_commit.message }}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
edges
22
nodes
33
| .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | semmle.label | github.event.comment.body |
4+
| .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | semmle.label | github.event.head_commit.message |
45
subpaths
56
#select
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
edges
22
nodes
33
| .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | semmle.label | github.event.comment.body |
4+
| .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | semmle.label | github.event.head_commit.message |
45
subpaths
56
#select
67
| .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | Potential privileged command injection in $@, which may be controlled by an external user. | .github/workflows/comment_issue.yml:9:26:9:57 | github.event.comment.body | ${{ github.event.comment.body }} |
8+
| .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | Potential privileged command injection in $@, which may be controlled by an external user. | .github/workflows/documentation.yml:87:28:87:66 | github.event.head_commit.message | ${{ github.event.head_commit.message }} |

ql/test/query-tests/Security/CWE-094/.github/workflows/inter-job4.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jn: push
1+
on: push
22

33
jobs:
44
job0:

ql/test/query-tests/Security/CWE-094/CodeInjection.expected

+2
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,6 @@ nodes
234234
subpaths
235235
#select
236236
| .github/workflows/changed-files.yml:22:24:22:75 | steps.changed-files.outputs.all_changed_files | .github/workflows/changed-files.yml:16:9:20:6 | Uses Step: changed-files | .github/workflows/changed-files.yml:22:24:22:75 | steps.changed-files.outputs.all_changed_files | Potential code injection in $@, which may be controlled by an external user. | .github/workflows/changed-files.yml:22:24:22:75 | steps.changed-files.outputs.all_changed_files | ${{ steps.changed-files.outputs.all_changed_files }} |
237+
| .github/workflows/changelog.yml:58:26:58:39 | env.log | .github/workflows/changelog.yml:49:19:49:56 | github.event.pull_request.title | .github/workflows/changelog.yml:58:26:58:39 | env.log | Potential code injection in $@, which may be controlled by an external user. | .github/workflows/changelog.yml:58:26:58:39 | env.log | ${{ env.log }} |
238+
| .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | .github/workflows/changelog_from_prt.yml:49:19:49:56 | github.event.pull_request.title | .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | Potential code injection in $@, which may be controlled by an external user. | .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | ${{ env.log }} |
237239
| action1/action.yml:14:19:14:50 | github.event.comment.body | action1/action.yml:14:19:14:50 | github.event.comment.body | action1/action.yml:14:19:14:50 | github.event.comment.body | Potential code injection in $@, which may be controlled by an external user. | action1/action.yml:14:19:14:50 | github.event.comment.body | ${{ github.event.comment.body }} |

ql/test/query-tests/Security/CWE-094/PrivilegedCodeInjection.expected

-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ subpaths
236236
| .github/workflows/argus_case_study.yml:27:33:27:77 | steps.remove_quotations.outputs.replaced | .github/workflows/argus_case_study.yml:17:25:17:53 | github.event.issue.title | .github/workflows/argus_case_study.yml:27:33:27:77 | steps.remove_quotations.outputs.replaced | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/argus_case_study.yml:27:33:27:77 | steps.remove_quotations.outputs.replaced | ${{steps.remove_quotations.outputs.replaced}} |
237237
| .github/workflows/artifactpoisoning1.yml:34:67:34:92 | steps.pr.outputs.id | .github/workflows/artifactpoisoning1.yml:14:9:20:6 | Uses Step | .github/workflows/artifactpoisoning1.yml:34:67:34:92 | steps.pr.outputs.id | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/artifactpoisoning1.yml:34:67:34:92 | steps.pr.outputs.id | ${{ steps.pr.outputs.id }} |
238238
| .github/workflows/artifactpoisoning2.yml:22:17:22:42 | steps.pr.outputs.id | .github/workflows/artifactpoisoning2.yml:13:9:19:6 | Uses Step: pr | .github/workflows/artifactpoisoning2.yml:22:17:22:42 | steps.pr.outputs.id | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/artifactpoisoning2.yml:22:17:22:42 | steps.pr.outputs.id | ${{ steps.pr.outputs.id }} |
239-
| .github/workflows/changelog.yml:58:26:58:39 | env.log | .github/workflows/changelog.yml:49:19:49:56 | github.event.pull_request.title | .github/workflows/changelog.yml:58:26:58:39 | env.log | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/changelog.yml:58:26:58:39 | env.log | ${{ env.log }} |
240-
| .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | .github/workflows/changelog_from_prt.yml:49:19:49:56 | github.event.pull_request.title | .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/changelog_from_prt.yml:58:26:58:39 | env.log | ${{ env.log }} |
241239
| .github/workflows/comment_issue.yml:9:15:9:46 | github.event.comment.body | .github/workflows/comment_issue.yml:9:15:9:46 | github.event.comment.body | .github/workflows/comment_issue.yml:9:15:9:46 | github.event.comment.body | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/comment_issue.yml:9:15:9:46 | github.event.comment.body | ${{ github.event.comment.body }} |
242240
| .github/workflows/comment_issue.yml:15:19:15:50 | github.event.comment.body | .github/workflows/comment_issue.yml:15:19:15:50 | github.event.comment.body | .github/workflows/comment_issue.yml:15:19:15:50 | github.event.comment.body | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/comment_issue.yml:15:19:15:50 | github.event.comment.body | ${{ github.event.comment.body }} |
243241
| .github/workflows/comment_issue.yml:16:19:16:48 | github.event.issue.body | .github/workflows/comment_issue.yml:16:19:16:48 | github.event.issue.body | .github/workflows/comment_issue.yml:16:19:16:48 | github.event.issue.body | Potential privileged code injection in $@, which may be controlled by an external user. | .github/workflows/comment_issue.yml:16:19:16:48 | github.event.issue.body | ${{ github.event.issue.body }} |

0 commit comments

Comments
 (0)