Skip to content

Conversation

@kkartunov
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/

What's in this PR?

Enable Trivy for the repo.

jobs:
trivy-scan:
name: Use Trivy
runs-on: ubuntu-24.04

Choose a reason for hiding this comment

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

[⚠️ maintainability]
Consider using a more stable version of Ubuntu, such as ubuntu-latest, to ensure compatibility and reduce maintenance overhead when newer versions are released.

ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,UNKNOWN'

Choose a reason for hiding this comment

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

[⚠️ security]
Including UNKNOWN severity might lead to noisy results. Ensure that this is intentional and necessary for your security policy.

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif' No newline at end of file

Choose a reason for hiding this comment

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

[💡 style]
Ensure that the SARIF file path is correct and accessible. A missing newline at the end of the file might cause issues in some systems.

Comment on lines +10 to +30
name: Use Trivy
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy scanner in repo mode
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,UNKNOWN'
scanners: vuln,secret,misconfig,license
github-pat: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif' No newline at end of file

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 15 days ago

To fix the problem, add the permissions block for the trivy-scan job (or for the root workflow if you want all jobs to inherit it). This block should enumerate the specific minimal permissions required for the current job steps:

  • contents: read is required by nearly all workflows to fetch and check out code.
  • security-events: write is needed to upload SARIF results to the GitHub Security tab using codeql-action/upload-sarif.

Add:

permissions:
  contents: read
  security-events: write

to the trivy-scan job definition, directly below runs-on. This ensures GITHUB_TOKEN has only these two permissions during job execution.

No external methods or imports are required; it's a YAML block edit.

Suggested changeset 1
.github/workflows/trivy.yaml

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/trivy.yaml b/.github/workflows/trivy.yaml
--- a/.github/workflows/trivy.yaml
+++ b/.github/workflows/trivy.yaml
@@ -9,6 +9,9 @@
   trivy-scan:
     name: Use Trivy
     runs-on: ubuntu-24.04
+    permissions:
+      contents: read
+      security-events: write
     steps:
       - name: Checkout code
         uses: actions/checkout@v4
EOF
@@ -9,6 +9,9 @@
trivy-scan:
name: Use Trivy
runs-on: ubuntu-24.04
permissions:
contents: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Copilot is powered by AI and may make mistakes. Always verify output.
@kkartunov kkartunov merged commit fa41894 into dev Oct 23, 2025
8 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.

2 participants