Please define actions workflow permissions
Workflow permissions improvement
There are 16 workflow files that are currently lacking explicit permissions
Affected Workflow Files
The following workflow files need permissions to be explicitly defined:
-
.github/workflows/code-scanning-pack-gen.yml -
.github/workflows/codeql_unit_tests.yml -
.github/workflows/dispatch-matrix-test-on-comment.yml -
.github/workflows/dispatch-release-performance-check.yml -
.github/workflows/extra-rule-validation.yml -
.github/workflows/finalize-release.yml -
.github/workflows/generate-html-docs.yml -
.github/workflows/standard_library_upgrade_tests.yml -
.github/workflows/tooling-unit-tests.yml -
.github/workflows/update-release.yml -
.github/workflows/upgrade_codeql_dependencies.yml -
.github/workflows/validate-package-files.yml -
.github/workflows/validate-query-formatting.yml -
.github/workflows/validate-query-help.yml -
.github/workflows/validate-query-test-case-formatting.yml -
.github/workflows/verify-standard-library-dependencies.yml
Request
Ensure permissions are explicitly defined. Below are Copilot prompts/instructions if you would like Copilot's assistance with addressing this.
GitHub Copilot Assignment Prompts and Context
Task: Add explicit permissions to GitHub Actions workflow files that are currently missing them.
Scope: Update the workflow files listed above to include appropriate permissions: blocks.
Analysis Methodology:
- Gather Current State: Check if the workflow has any existing permissions defined
-
Inventory Workflow Actions:
- Actions performed directly by the workflow
- API calls made by the workflow
- External actions included via
uses:statements
- Determine Required Permissions: Map each action to its minimum required permissions
- Synthesize Minimal Permissions: Create permissions block with only necessary permissions
Requirements:
- Add a
permissions:block to each workflow file that doesn't have one - Start with
contents: readas the minimum permission - Add additional permissions only if the workflow actually needs them based on the actions it performs
- Place the
permissions:block at the job level or workflow level as appropriate - Ensure the syntax is correct and follows YAML formatting
- Maintain existing content formatting, including indentation and comments
Files to modify: See the list of affected workflow files above.
Acceptance criteria:
- [ ] All listed workflow files have explicit permissions defined
- [ ] Permissions follow the principle of least privilege
- [ ] YAML syntax is valid
- [ ] Workflows still function correctly after changes
Copilot Instructions:
Please create a pull request that adds appropriate permissions: blocks to each of the workflow files listed above. Analyze each workflow to determine the minimum permissions required based on the actions it performs, and add only those necessary permissions.