Skip to content

Potential fix for code scanning alert no. 1: Workflow does not contain permissions#33

Draft
JunAishima wants to merge 1 commit intomainfrom
alert-autofix-1
Draft

Potential fix for code scanning alert no. 1: Workflow does not contain permissions#33
JunAishima wants to merge 1 commit intomainfrom
alert-autofix-1

Conversation

@JunAishima
Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/NSLS2/srx-workflows/security/code-scanning/1

To fix the problem, explicitly define permissions in the workflow so that the GITHUB_TOKEN has only the minimal required scopes. For a linting/pre-commit workflow that only checks code and does not modify the repository via the API, contents: read is typically sufficient. Defining it at the workflow root will apply to all jobs that do not override it.

The best fix here is to add a permissions block at the top level of .github/workflows/linting.yml, between the name: and on: keys, with contents: read. This avoids changing any existing job behavior: actions/checkout will still be able to read the repository, and the pre-commit action will run as before, but the token will not have unnecessary write access. No imports or additional methods are needed since this is a YAML configuration change only.

Concretely, in .github/workflows/linting.yml, insert:

permissions:
  contents: read

after line 1 (the name: line) and before the on: block.

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>
@JunAishima JunAishima requested a review from AbbyGi March 26, 2026 17:35
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.

1 participant