-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix CodeQL workflow errors by pinning actions to full commit SHAs #3
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||||||||||||||||||||||||||||
| name: Security | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||
| branches: [ main, develop ] | ||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||
| branches: [ main, develop ] | ||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||
| # Run security scans weekly on Monday at 00:00 UTC | ||||||||||||||||||||||||||||||||
| - cron: '0 0 * * 1' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| npm-audit: | ||||||||||||||||||||||||||||||||
| name: NPM Audit | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Setup Node.js | ||||||||||||||||||||||||||||||||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| node-version: '18.x' | ||||||||||||||||||||||||||||||||
| cache: 'npm' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Run npm audit | ||||||||||||||||||||||||||||||||
| run: npm audit --audit-level=moderate | ||||||||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Run npm audit (production only) | ||||||||||||||||||||||||||||||||
| run: npm audit --production --audit-level=high | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| codeql: | ||||||||||||||||||||||||||||||||
| name: CodeQL Analysis | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| security-events: write | ||||||||||||||||||||||||||||||||
| actions: read | ||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Initialize CodeQL | ||||||||||||||||||||||||||||||||
| uses: github/codeql-action/init@497990dfed22177a82ba1bbab381bc8f6d27058f # v3.31.6 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| languages: javascript | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Perform CodeQL Analysis | ||||||||||||||||||||||||||||||||
| uses: github/codeql-action/analyze@497990dfed22177a82ba1bbab381bc8f6d27058f # v3.31.6 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| dependency-review: | ||||||||||||||||||||||||||||||||
| name: Dependency Review | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Dependency Review | ||||||||||||||||||||||||||||||||
| uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| fail-on-severity: moderate | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| snyk: | ||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+73
Check warningCode 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 AutofixAI 5 months ago To fix the problem, we need to add a
Suggested changeset
1
.github/workflows/security.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||
| name: Snyk Security Scan | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Run Snyk to check for vulnerabilities | ||||||||||||||||||||||||||||||||
| uses: snyk/actions/node@9adf32b1121593767fc3c057af55b55db032dc04 # v1.0.0 | ||||||||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| args: --severity-threshold=high | ||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+88
Check warningCode 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 AutofixAI 5 months ago To fix the problem, we should add a
Suggested changeset
1
.github/workflows/security.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 5 months ago
To fix this issue, we should add a
permissionsblock to thenpm-auditjob, specifying only the necessary permissions. For typical audit jobs, thecontents: readpermission is sufficient, ensuring the job can read the repository code but cannot write to it or make repository changes. The change should be added directly under the job definition (below thename: NPM Auditline and aboveruns-on). No further imports or methods are necessary—simply add the correct YAML configuration. No other jobs or workflow-level changes are necessary, as each job can declare its own block.