[PRM-495] Added dispatch to workflows#256
Conversation
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Hello World | ||
| run: echo "Hello, world!" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, explicitly specify the minimal necessary workflow permissions using the permissions key. Since the workflow appears only to echo "Hello, world!" and does not interact with the repository or GitHub resources, it is safe to restrict all permissions (permissions: {};), or as GitHub recommends, set contents: read at the top level. The best practice is to add the permissions block at the workflow root (directly under the name field, before on:), which applies it to all jobs in the workflow unless overridden.
- Edit
.github/workflows/e2e.yml - Add the following block after
name: e2eand beforeon::(alternatively,permissions: contents: read
permissions: {}is an even stricter minimal baseline, butcontents: readis more typically recommended) - No additional imports or definitions are necessary.
| @@ -1,4 +1,6 @@ | ||
| name: e2e | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: |
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Hello World | ||
| run: echo "Hello, world!" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
The best approach is to explicitly define a permissions block that grants only the minimal rights required by this workflow. Since the current workflow only prints a message and does not use the GITHUB_TOKEN for any operations (read or write), the most restrictive and therefore safest configuration is permissions: {} at either the workflow or job level.
Recommended: Add the following at the top level (just after the name: and before or after on:):
permissions: {}Alternatively, for jobs that do require some permissions (e.g., pushing to the repository), you would set only those specific permissions. But in this case, since no permission is required, {} suffices.
What to change:
- Add a
permissions: {}block after thename:line (line 1), or before thejobs:block (after line 25), or (less optimal) under each job. The most common and clear place is immediately aftername: ...so it acts as a workflow-global default. - No extra imports or methods are necessary.
| @@ -1,4 +1,5 @@ | ||
| name: ehr-repo-build-and-publish | ||
| permissions: {} | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: |
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Hello World | ||
| run: echo "Hello, world!" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix this issue, you should add a permissions block to the workflow. The preferred location is at the root level, just below the workflow name and triggers, which sets the permissions for all jobs unless overridden. Since this workflow does not perform any sensitive repository actions, you should specify the most restrictive permissible setting: contents: read (which allows reading repository content, not writing), or even none if nothing at all is needed. However, for many simple jobs, contents: read is recommended as a safe default. The change should be made at the top of .github/workflows/test-ehr-repo.yml, just below the workflow name (name: test-ehr-repo and before the on: block).
| @@ -1,4 +1,6 @@ | ||
| name: test-ehr-repo | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: |
Report for environment: pre-prodTerraform Format and Style 🖌
|
Report for environment: prodTerraform Format and Style 🖌
|
Report for environment: testTerraform Format and Style 🖌
|
Report for environment: devTerraform Format and Style 🖌
|
No description provided.