Skip to content

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#159

Merged
thpierce merged 2 commits intomainfrom
alert-autofix-3
Oct 14, 2025
Merged

Potential fix for code scanning alert no. 3: Workflow does not contain permissions#159
thpierce merged 2 commits intomainfrom
alert-autofix-3

Conversation

@thpierce
Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/aws-observability/aws-otel-ruby/security/code-scanning/3

To remedy the issue, a permissions block should be added to restrict the GITHUB_TOKEN privileges so the workflow or job only receives the rights it needs. Specifically, the actions/stale uses the bot to read and write issues and pull-requests, label them, and potentially close them. The minimal required set is contents: write, issues: write, and pull-requests: write. This block can be placed either at the root of the workflow (making it apply to all jobs) or at the job level (stale-close). According to the CodeQL recommendation, it's preferable to put it at the job level so that only the job has the permissions it needs.
Edit .github/workflows/stale-bot.yml, and under jobs: stale-close: (before runs-on:), add:

permissions:
  contents: write
  issues: write
  pull-requests: write

No new imports or external code definitions are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@thpierce thpierce marked this pull request as ready for review October 14, 2025 16:20
@thpierce thpierce requested a review from a team as a code owner October 14, 2025 16:20

jobs:
stale-close:
permissions:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need contents: write? See https://github.com/aws-observability/aws-otel-python/pull/99/files

also: not blocking, but for parity we could put all permissions at job level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contents: write # only for delete-branch option - https://github.com/actions/stale

Will remove.

@thpierce thpierce merged commit 682b0cb into main Oct 14, 2025
5 checks passed
@thpierce thpierce deleted the alert-autofix-3 branch October 14, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants