Skip to content

Conversation

@fqjony
Copy link
Contributor

@fqjony fqjony commented Jan 17, 2026

No description provided.

@fqjony fqjony self-assigned this Jan 17, 2026
Comment on lines +12 to +20
uses: ./.github/workflows/npm-release-ops.yml
with:
registry_url: https://registry.npmjs.org/
build_command: "" # CLI doesn't need build
test_command: "npm test"
working_directory: "cli"
environment: "Master"
secrets:
npm_token: ${{ secrets.npm_token }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 11 days ago

To fix the problem, explicitly set permissions in this workflow, so the GITHUB_TOKEN used by the release job (and any called workflows) is constrained to the least privileges needed. Since this workflow’s job only delegates to npm-release-ops.yml and uses an npm token secret for publishing, a conservative default is to set contents: read at the workflow level. If the called workflow requires additional scopes (for example, to create releases or tags), those should be added there, but with only the snippet given we should not assume extra requirements.

The single best change, without altering existing functionality, is to add a root-level permissions block (aligned with on: and jobs:) specifying contents: read. This establishes a minimal default for all jobs in this workflow, including release, while still allowing the called workflow to further reduce permissions if it wants. We do not change any other lines or behavior.

Concretely, in .github/workflows/_release-cli.yml, after the on: block and before jobs:, insert:

permissions:
  contents: read

No additional methods, imports, or definitions are required since this is purely a YAML configuration change for GitHub Actions.

Suggested changeset 1
.github/workflows/_release-cli.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/_release-cli.yml b/.github/workflows/_release-cli.yml
--- a/.github/workflows/_release-cli.yml
+++ b/.github/workflows/_release-cli.yml
@@ -7,6 +7,9 @@
       - '.github/workflows/_release-cli.yml'
   workflow_dispatch:
 
+permissions:
+  contents: read
+
 jobs:
   release:
     uses: ./.github/workflows/npm-release-ops.yml
EOF
@@ -7,6 +7,9 @@
- '.github/workflows/_release-cli.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
release:
uses: ./.github/workflows/npm-release-ops.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +65 to +105
runs-on: ubuntu-latest
outputs:
current_branch: ${{ steps.branches.outputs.branch_name }}
is_release_branch: ${{ steps.branches.outputs.is_release_branch }}
release_version: ${{ steps.package_version.outputs.version }}
package_name: ${{ steps.package_version.outputs.name }}
has_slack_webhook: ${{ steps.check_slack.outputs.has_webhook }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Package Info
id: package_version
run: |
VERSION=$(node -p "require('./package.json').version")
NAME=$(node -p "require('./package.json').name")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "📦 Package: $NAME@$VERSION"
working-directory: ${{ inputs.working_directory }}

- name: Determine Branch Information
id: branches
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT

IS_RELEASE_BRANCH=$([[ "${BRANCH_NAME}" == "${{ inputs.release_branch }}" ]] && echo "true" || echo "false")
echo "is_release_branch=${IS_RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "📌 Branch: ${BRANCH_NAME} (Release: ${IS_RELEASE_BRANCH})"

- name: Check Slack Webhook
id: check_slack
run: |
if [ -n "${{ secrets.slack_webhook_url }}" ]; then
echo "has_webhook=true" >> $GITHUB_OUTPUT
else
echo "has_webhook=false" >> $GITHUB_OUTPUT
fi

test:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 days ago

To fix the problem, add an explicit permissions block at the top level of the workflow so that all jobs without their own permissions (here: config and test) run with least-privilege GITHUB_TOKEN access. The release job already has its own permissions block, which will override the top-level one, so we leave it unchanged.

The best minimal, non‑functional change is:

  • Add permissions: contents: read near the top of .github/workflows/npm-release-ops.yml, alongside name and on.
  • This will ensure that config and test can still check out code (checkout requires contents: read) but won’t have unnecessary write permissions.
  • No imports, additional methods, or other file changes are required.

Concretely, insert:

permissions:
  contents: read

after the name: NPM Release line (or anywhere at the root level before jobs:).

Suggested changeset 1
.github/workflows/npm-release-ops.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/npm-release-ops.yml b/.github/workflows/npm-release-ops.yml
--- a/.github/workflows/npm-release-ops.yml
+++ b/.github/workflows/npm-release-ops.yml
@@ -1,5 +1,8 @@
 name: NPM Release
 
+permissions:
+  contents: read
+
 on:
   workflow_call:
     inputs:
EOF
@@ -1,5 +1,8 @@
name: NPM Release

permissions:
contents: read

on:
workflow_call:
inputs:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +106 to +128
needs: config
runs-on: ubuntu-latest
if: inputs.test_command != ''
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
cache: 'npm'
cache-dependency-path: ${{ inputs.working_directory }}/package-lock.json

- name: Install dependencies
run: npm ci
working-directory: ${{ inputs.working_directory }}

- name: Run Tests
run: ${{ inputs.test_command }}
working-directory: ${{ inputs.working_directory }}

release:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 days ago

In general, the fix is to explicitly declare permissions for the workflow or for each job, granting only what is required. Here, the release job already has a tailored permissions block (contents: write, id-token: write). The config and test jobs only read repository contents and use secrets; they do not push changes or modify GitHub resources. So we should add a restrictive permissions block to those jobs (or at the workflow root) that limits GITHUB_TOKEN to read-only. To avoid altering existing behavior for the release job, we will set permissions: contents: read at the workflow root, so it applies to all jobs by default, while the existing release job permissions block will override this as needed.

Concretely, in .github/workflows/npm-release-ops.yml, insert a top-level permissions: block right after the name: NPM Release line. This block will specify contents: read, which is the minimal permission required for actions/checkout and reading the repository during config and test. We do not need to modify the release job’s permissions because job-level permissions override the workflow-level defaults. No additional imports or external libraries are needed since this is a YAML configuration change only.

Suggested changeset 1
.github/workflows/npm-release-ops.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/npm-release-ops.yml b/.github/workflows/npm-release-ops.yml
--- a/.github/workflows/npm-release-ops.yml
+++ b/.github/workflows/npm-release-ops.yml
@@ -1,4 +1,6 @@
 name: NPM Release
+permissions:
+  contents: read
 
 on:
   workflow_call:
EOF
@@ -1,4 +1,6 @@
name: NPM Release
permissions:
contents: read

on:
workflow_call:
Copilot is powered by AI and may make mistakes. Always verify output.

- name: Create GitHub Release
if: inputs.enable_gh_release == true
uses: softprops/action-gh-release@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'NPM Release' step
Uses Step
uses 'softprops/action-gh-release' with ref 'v2', not a pinned commit hash

- name: Notify Slack
if: always() && needs.config.outputs.has_slack_webhook == 'true'
uses: slackapi/slack-github-action@v1.26.0

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'NPM Release' step
Uses Step
uses 'slackapi/slack-github-action' with ref 'v1.26.0', not a pinned commit hash
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