-
-
Notifications
You must be signed in to change notification settings - Fork 0
Potential fix for code scanning alert no. 901: Workflow does not contain permissions #584
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
Merged
+6
−1
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a887e2e
Potential fix for code scanning alert no. 901: Workflow does not cont…
aurelianware 6b0fc8f
Fix CRLF line endings in Azure Static Web Apps workflow file
Copilot bb7aa0a
Merge branch 'main' into alert-autofix-901
aurelianware de46876
Scope permissions per-job: add pull-requests: write to build_and_depl…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
95 changes: 49 additions & 46 deletions
95
.github/workflows/azure-static-web-apps-agreeable-meadow-0da15b31e.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,49 @@ | ||
| name: Azure Static Web Apps CI/CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build_and_deploy_job: | ||
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | ||
| runs-on: ubuntu-latest | ||
| name: Build and Deploy Job | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| submodules: true | ||
| lfs: false | ||
| - name: Build And Deploy | ||
| id: builddeploy | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN}} | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | ||
| action: "upload" | ||
| ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### | ||
| # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | ||
| app_location: "./src/site/" # App source code path | ||
| api_location: "" # Api source code path - optional | ||
| output_location: "." # Built app content directory - optional | ||
| ###### End of Repository/Build Configurations ###### | ||
|
|
||
| close_pull_request_job: | ||
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
| runs-on: ubuntu-latest | ||
| name: Close Pull Request Job | ||
| steps: | ||
| - name: Close Pull Request | ||
| id: closepullrequest | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| action: "close" | ||
| name: Azure Static Web Apps CI/CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build_and_deploy_job: | ||
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') | ||
| runs-on: ubuntu-latest | ||
| name: Build and Deploy Job | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| submodules: true | ||
| lfs: false | ||
| - name: Build And Deploy | ||
| id: builddeploy | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN}} | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | ||
| action: "upload" | ||
| ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### | ||
| # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | ||
| app_location: "./src/site/" # App source code path | ||
| api_location: "" # Api source code path - optional | ||
| output_location: "." # Built app content directory - optional | ||
| ###### End of Repository/Build Configurations ###### | ||
|
|
||
| close_pull_request_job: | ||
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
| runs-on: ubuntu-latest | ||
| name: Close Pull Request Job | ||
| steps: | ||
| - name: Close Pull Request | ||
| id: closepullrequest | ||
| uses: Azure/static-web-apps-deploy@v1 | ||
| with: | ||
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| action: "close" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new workflow-level
permissionsrestrictsGITHUB_TOKENtocontents: read, but this workflow passessecrets.GITHUB_TOKENasrepo_tokentoAzure/static-web-apps-deploy@v1(notably for PR integrations/PR comments). With onlycontents: read, the action will no longer be able to create/update PR comments or other PR metadata, changing existing behavior. Consider adding the minimal additional scopes required (typicallypull-requests: write, and scope it per-job if you wantclose_pull_request_jobto remain read-only).