-
Notifications
You must be signed in to change notification settings - Fork 1
Fix PR and CI workflow #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| uses: ./.github/workflows/configs.yml | ||
|
|
||
| pr-build-test-nodejs: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
- General fix: Add a
permissionsblock to theget-configsjob, explicitly restricting unnecessary repository access and specifying the minimum required scope. - Detailed fix: Since the
get-configsjob simply calls a reusable workflow and, based on its naming and usage, is unlikely to need write access, the minimal appropriate permissions would becontents: read. Place apermissions:block underget-configs:at the same indentation level asuses:. - Files/regions/lines to change: In
.github/workflows/pr.yml, update lines 8–10 to insert apermissions:block with appropriate contents before theuses:line. - Methods/imports/definitions required: No new methods, imports, or outside definitions are needed; only a YAML block addition.
-
Copy modified lines R9-R10
| @@ -6,6 +6,8 @@ | ||
|
|
||
| jobs: | ||
| get-configs: | ||
| permissions: | ||
| contents: read | ||
| uses: ./.github/workflows/configs.yml | ||
|
|
||
| pr-build-test-nodejs: |
b369044 to
dbc32e5
Compare
| needs: [get-configs] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Go ${{ needs.get-configs.outputs.go-version }} | ||
| uses: actions/setup-go@v4 | ||
| with: | ||
| go-version: ${{ needs.get-configs.outputs.go-version }} | ||
| cache: true | ||
|
|
||
| - name: Build | ||
| shell: bash | ||
| run: GOPROXY=direct go build -C ./cfn-init ./... | ||
|
|
||
| - name: Test | ||
| shell: bash | ||
| run: GOPROXY=direct go test -C ./cfn-init -v -cover ./... |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix this problem, we should specify a permissions block for the pr-build-test-go job, explicitly limiting the permissions granted to the GITHUB_TOKEN. Reviewing the pr-build-test-go job, none of its steps requires write access to repository contents, pull requests, or any other resource. Thus, the minimal required permission is contents: read, which allows the job to check out code but does not grant unnecessary write privileges.
You should add the following block beneath runs-on: ubuntu-latest within the pr-build-test-go job:
permissions:
contents: readThis change is entirely localized to lines 56-57 (runs-on to first steps:) and does not interfere with existing functionality.
-
Copy modified lines R57-R58
| @@ -54,6 +54,8 @@ | ||
| pr-build-test-go: | ||
| needs: [get-configs] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
|
Fix PR and CI workflow