Skip to content

Potential fix for code scanning alert no. 2: Workflow does not contain permissions - #68

Merged
Rui Xia (harrysummer) merged 3 commits into
mainfrom
alert-autofix-2
Dec 6, 2025
Merged

Potential fix for code scanning alert no. 2: Workflow does not contain permissions#68
Rui Xia (harrysummer) merged 3 commits into
mainfrom
alert-autofix-2

Conversation

@harrysummer

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/microsoft/visionmetrics/security/code-scanning/2

The best way to fix the problem is to explicitly restrict the GITHUB_TOKEN permissions by adding a permissions block to the workflow, following the principle of least privilege. In this workflow, the minimum required permission is to allow reading repository contents (e.g., for actions/checkout to read source code). This can be achieved by adding the following at the root level, just below the workflow name and above on::

permissions:
  contents: read

This applies the restriction to all jobs unless a job-specific permissions block overrides it. No other permissions are needed for the workflow's steps. Only one region of the file (.github/workflows/release.yml, near the top) needs to be edited to insert this 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>
@harrysummer Rui Xia (harrysummer) self-assigned this Dec 5, 2025
@harrysummer
Rui Xia (harrysummer) marked this pull request as ready for review December 5, 2025 20:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a GitHub code scanning alert by adding explicit permissions to the release workflow and includes an unrelated dependency version pin. The primary change restricts the GITHUB_TOKEN to read-only access following the principle of least privilege.

  • Added permissions: contents: read to the release workflow to address security alert
  • Pinned pycocotools to version 2.0.8 (unrelated to workflow security fix)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/release.yml Added permissions block to restrict GITHUB_TOKEN to read-only access for security
setup.cfg Pinned pycocotools version to 2.0.8 with explanatory comment (unrelated to PR purpose)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup.cfg Outdated
Comment thread setup.cfg Outdated

@juliagongms Julia Gong (juliagongms) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left one minor comment, but looks good otherwise. Thanks!

@harrysummer
Rui Xia (harrysummer) merged commit 361c5c0 into main Dec 6, 2025
5 checks passed
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.

3 participants