-
Notifications
You must be signed in to change notification settings - Fork 74
[SYNPY-1764] Add Trivy container vulnerability scanning #1346
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
532295e
Add initial CLAUDE.md for AI-assisted development
BryanFauble eb74b2b
Add module-level CLAUDE.md files for models, api, core, and tests
BryanFauble f54c099
Rewrite and expand CLAUDE.md coverage to 16 files
BryanFauble 0497f30
[SYNPY-1764] Add Trivy container vulnerability scanning to Docker build
BryanFauble 1d63fa1
Address PR review feedback from linglp and jaymedina
BryanFauble e41235d
Prevent infinite rebuild loop in periodic Trivy scan
BryanFauble 629e014
pre-commit
BryanFauble 162c80b
Merge branch 'develop' into synpy-1764-trivy-scanning
BryanFauble ac7f11b
Update Trivy scan workflow to use previous tag and adjust image refer…
BryanFauble cc95718
Merge branch 'develop' into synpy-1764-trivy-scanning
BryanFauble f31dd2d
Merge branch 'develop' into synpy-1764-trivy-scanning
BryanFauble 1f955dc
Address PR review feedback
BryanFauble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| --- | ||
|
BryanFauble marked this conversation as resolved.
|
||
| # | ||
| # Reusable workflow to build, scan, and push a Docker image. | ||
| # Called by the periodic scan workflow to rebuild images | ||
| # when new vulnerabilities are found. | ||
| # | ||
| name: Build and publish a Docker image | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| REF_TO_CHECKOUT: | ||
| required: false | ||
| type: string | ||
| description: "Reference to checkout, e.g. a tag like v1.0.1. Defaults to the branch/tag of the current event." | ||
| IMAGE_REFERENCES: | ||
| required: true | ||
| type: string | ||
| description: "Comma-separated image references, e.g., ghcr.io/sage-bionetworks/synapsepythonclient:1.0.1" | ||
|
|
||
| env: | ||
| TARFILE_NAME: image.tar | ||
| LOCAL_IMAGE_TAG: rebuild-image:local | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.REF_TO_CHECKOUT }} | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Build Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: false | ||
| load: true | ||
| tags: ${{ env.LOCAL_IMAGE_TAG }} | ||
| file: ./Dockerfile | ||
| platforms: linux/amd64 | ||
|
|
||
| - name: Save Docker image to tar | ||
| run: docker save ${{ env.LOCAL_IMAGE_TAG }} -o ${{ env.TARFILE_NAME }} | ||
|
|
||
| - name: Upload tarball for use by Trivy job | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ env.TARFILE_NAME }} | ||
| path: ${{ env.TARFILE_NAME }} | ||
| retention-days: 1 | ||
|
|
||
| outputs: | ||
| tarfile_artifact: ${{ env.TARFILE_NAME }} | ||
|
|
||
| trivy-scan: | ||
| needs: build | ||
| uses: "./.github/workflows/trivy.yml" | ||
| with: | ||
| SOURCE_TYPE: tar | ||
| IMAGE_NAME: rebuild-image:local | ||
| TARFILE_NAME: ${{ needs.build.outputs.tarfile_artifact }} | ||
| EXIT_CODE: 1 | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| actions: read | ||
|
|
||
| push-image: | ||
| needs: [build, trivy-scan] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Download tar artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ${{ needs.build.outputs.tarfile_artifact }} | ||
| path: /tmp | ||
|
|
||
| - name: Load Docker image from tar | ||
| run: docker load -i /tmp/${{ needs.build.outputs.tarfile_artifact }} | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Tag and push Docker image | ||
| shell: bash | ||
| run: | | ||
| IFS=',' read -ra TAGS <<< "${{ inputs.IMAGE_REFERENCES }}" | ||
| for TAG in "${TAGS[@]}"; do | ||
| docker tag ${{ env.LOCAL_IMAGE_TAG }} "$TAG" | ||
| docker push "$TAG" | ||
| done | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.