Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/vulnerable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: pull_request_target

jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-node@v1
- run: |
npm install
npm build
- uses: completely/fakeaction@v2
Comment on lines +13 to +16

Check failure

Code scanning / CodeQL

Checkout of untrusted code in a privileged context Critical

Potential execution of untrusted code on a privileged workflow (
pull_request_target
)
with:
arg1: ${{ secrets.supersecret }}

- uses: fakerepo/comment-on-pr@v1
with:
message: |
Thank you!
Comment on lines +5 to +23

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 8 months ago

To resolve the issue, we will add a permissions block at the root of the workflow, applying it to all jobs unless overridden. In this case, we will set the contents permission to read (allowing the workflow to read repository contents) and the pull-requests permission to write (required for commenting on pull requests). This ensures the workflow has the least privilege necessary to perform its tasks. We will add the permissions block after the on key to apply it globally.


Suggested changeset 1
.github/workflows/vulnerable.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/vulnerable.yml b/.github/workflows/vulnerable.yml
--- a/.github/workflows/vulnerable.yml
+++ b/.github/workflows/vulnerable.yml
@@ -1,3 +1,6 @@
+permissions:
+  contents: read
+  pull-requests: write
 on: pull_request_target
 
 jobs:
EOF
@@ -1,3 +1,6 @@
permissions:
contents: read
pull-requests: write
on: pull_request_target

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.