-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add Trivy support #35
Open
phvalguima
wants to merge
18
commits into
2/edge
Choose a base branch
from
add-trivy-support
base: 2/edge
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b268bce
Add Trivy support
phvalguima 952ca34
Create build.yaml
phvalguima 2f65cfc
Delete .github/trivy.yaml
phvalguima 59b436c
Create trivy.yaml
phvalguima 12f1974
Update ci.yaml
phvalguima e2c6baf
Update trivy.yaml
phvalguima e4db17a
Update trivy.yaml
phvalguima d6f5b61
Update trivy.yaml
phvalguima 5144f5a
Update ci.yaml
phvalguima 69265cb
Delete .github/workflows/build.yaml
phvalguima 9520c56
Delete .github/workflows/trivy.yaml
phvalguima 23eb9b3
Update ci.yaml
phvalguima d84cb60
Update ci.yaml
phvalguima 7d2b8f8
Update ci.yaml
phvalguima ace0cc0
Merge branch '2/edge' into add-trivy-support
phvalguima e794a57
Update ci.yaml
phvalguima 0d63b82
Update ci.yaml
phvalguima cfc4449
Update ci.yaml
phvalguima 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 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 |
---|---|---|
|
@@ -33,13 +33,82 @@ jobs: | |
- name: Build rock | ||
run: | | ||
rockcraft pack --verbose | ||
|
||
- name: Upload built rock job artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: charmed_opensearch_rock_amd64 | ||
path: "charmed-opensearch_*.rock" | ||
|
||
scan: | ||
name: Trivy scan and sbom generation | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 120 | ||
needs: | ||
- build | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Download rock file | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: charmed_opensearch_rock_amd64 | ||
path: . | ||
|
||
- name: Install required dependencies | ||
run: | | ||
# docker | ||
# FIXME: v27.2.0 reports "...client version 1.22 is too old..." when trying to copy the | ||
# rock to the local repository --revision=2932 | ||
sudo snap install docker --channel=latest/stable --revision=2932 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue, as reported on #34 |
||
sudo addgroup --system docker; sudo adduser $USER docker | ||
newgrp docker | ||
sudo snap disable docker; sudo snap enable docker | ||
# skopeo | ||
sudo snap install --devmode --channel edge skopeo | ||
sudo snap install yq | ||
|
||
- name: Create local image | ||
run: | | ||
version="$(cat rockcraft.yaml | yq .version)" | ||
|
||
sudo skopeo \ | ||
--insecure-policy \ | ||
copy \ | ||
oci-archive:charmed-opensearch_${version}_amd64.rock \ | ||
docker-daemon:trivy/charmed_opensearch_rock_amd64:test | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: 'trivy/charmed_opensearch_rock_amd64:test' | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
severity: 'MEDIUM,HIGH,CRITICAL' | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v2 | ||
if: always() | ||
with: | ||
sarif_file: 'trivy-results.sarif' | ||
|
||
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'image' | ||
format: 'spdx-json' | ||
output: 'dependency-results.sbom.json' | ||
image-ref: 'trivy/charmed_opensearch_rock_amd64:test' | ||
github-pat: ${{ secrets.GITHUB_TOKEN }} | ||
severity: "MEDIUM,HIGH,CRITICAL" | ||
scanners: "vuln" | ||
|
||
- name: Upload trivy report as a Github artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: trivy-sbom-report | ||
path: '${{ github.workspace }}/dependency-results.sbom.json' | ||
retention-days: 90 | ||
|
||
test: | ||
name: Test Rock | ||
runs-on: ubuntu-latest | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing with 22.04 breaks this setup. As this is a 1-2-1 alignment with Spark repo, I'd rather have it as-is.