Skip to content

Conversation

@i-oden
Copy link
Member

@i-oden i-oden commented Nov 20, 2025

📋 Summary

This PR adds the github action trivy. Taken from the pathogens portal repo and slightly altered.

🛠️ Changes Made

  • New actions: trivy-branch and trivy-scheduled, just as in pathogens-portal.
  • Started with copying the workflows from the pathogens-portal repo, but altered them
  • I've added exit-code and if: always() -- the action will fail if it detects a vulnerability but it will always publish the results to the security tab
  • For trivy-scheduled.yaml I kept the scan on main anyway (discussion on slack), but removed some unnecessary steps.

🔍 Notes for Reviewers

As discussed on slack, I looked at only scanning latest instead of main. However we don't publish any tag called latest if I've understood correctly, so I decided to go for main anyway instead of altering the publishing.

✅ Checklist

  • PR title follows the pattern: FREYA-XXXX: Clear and short description
  • Jira / Github issue is linked in description
  • Assignee is selected
  • Code and content adhere to conventions
  • Automated checks pass
  • Reviewer is selected when the PR is marked as ready for review

🔗 Jira Issue

Closes: FREYA-1889

@i-oden i-oden self-assigned this Nov 20, 2025
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@i-oden i-oden marked this pull request as ready for review December 3, 2025 10:00
@i-oden i-oden requested a review from a team as a code owner December 3, 2025 10:00
Copy link
Member

@Ziip-dev Ziip-dev left a comment

Choose a reason for hiding this comment

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

Good work! We just need to agree on failing the action or not as mentioned here before approving :)

@i-oden i-oden requested review from a team and Ziip-dev December 4, 2025 10:24
@i-oden
Copy link
Member Author

i-oden commented Dec 5, 2025

Good work! We just need to agree on failing the action or not as mentioned here before approving :)

Fixed ✅

@i-oden
Copy link
Member Author

i-oden commented Dec 9, 2025

@Ziip-dev Could you have a look at this when you have some time? 🙏🏻

@Ziip-dev
Copy link
Member

Ziip-dev commented Dec 9, 2025

@Ziip-dev Could you have a look at this when you have some time? 🙏🏻

Oups I had forgotten this one sorry, thanks for the reminder!

@i-oden
Copy link
Member Author

i-oden commented Dec 9, 2025

@Ziip-dev Could you have a look at this when you have some time? 🙏🏻

Oups I had forgotten this one sorry, thanks for the reminder!

No worries!

Copy link
Member

@Ziip-dev Ziip-dev left a comment

Choose a reason for hiding this comment

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

Nice work :)
Some minor changes, the rest is more open questions and trails for improvement that I would like to have the team's opinion on

Comment on lines +12 to +13
push:
branches: [main]
Copy link
Member

Choose a reason for hiding this comment

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

Not sure this one is necessary as we can't push to main

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I saw your comment about this after publishing the review, but I'm curious why then as I missed the discussion :)

scan-type: "fs"
scan-ref: "." # Default but being explicit
scanners: "vuln,secret" # Default but being explicit
# ignore-unfixed: true
Copy link
Member

Choose a reason for hiding this comment

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

What is ignore-unfixed for initially? And why is it commented out here?
Genuine question, I'm not that familiar with actions so if you can briefly explain to me :) (asking because it's set as true in the old portal repo)

security-events: write
name: Build
runs-on: ubuntu-latest
steps:
Copy link
Member

Choose a reason for hiding this comment

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

We don't need the checkout action here?


- name: Upload Trivy scan results to GitHub Security tab
if: always() # Publish results to security tab even if scan fails
uses: github/codeql-action/upload-sarif@v3
Copy link
Member

Choose a reason for hiding this comment

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

Although we still have one year before deprecation, since we have a warning already and the v4 has been released:

Suggested change
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4


- name: Upload Trivy scan results to GitHub Security tab
if: always() # Publish results to security tab even if scan fails
uses: github/codeql-action/upload-sarif@v3
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4

Comment on lines +32 to +33
TRIVY_DB_REPOSITORY: >-
ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
Copy link
Member

Choose a reason for hiding this comment

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

No issue here, just an idea: could we benefit from trivy built-in cache step to reduce runtime? This would avoid downloading the entire db on every run

with:
scan-type: "fs"
scan-ref: "." # Default but being explicit
scanners: "vuln,secret" # Default but being explicit
Copy link
Member

Choose a reason for hiding this comment

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

Would adding the misconfig scanner be beneficial?

# ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
Copy link
Member

Choose a reason for hiding this comment

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

Another open question :)
Are we interested in broader severity coverage? Like MEDIUM severity at least? Or do we want to ignore everything below HIGH severity

ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
uses: aquasecurity/[email protected]
with:
image-ref: ghcr.io/scilifelabdatacentre/swedish-pathogens-portal:main
Copy link
Member

Choose a reason for hiding this comment

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

So this workflow scans the built Docker image via image-ref, which is good, but never the repository file system.
Is it intended and why?

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