Skip to content

Commit

Permalink
Feat/trivyignore (#211)
Browse files Browse the repository at this point in the history
* feat(trivy): Add autoremove ignored CVEs
  • Loading branch information
merkata authored Nov 27, 2023
1 parent 2c57e4d commit d650bed
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build_rocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ jobs:
path: ${{ fromJSON(needs.get-rocks.outputs.rock-paths) }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Extract rock information
run: |
IMAGE_NAME=$(yq '.name' "${{ matrix.path }}/rockcraft.yaml")
Expand Down Expand Up @@ -224,3 +226,23 @@ jobs:
env:
TRIVY_USERNAME: ${{ github.actor }}
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Check trivyignore
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.46.0
if [ -f ".trivyignore" ]
then
output=$(trivy image $ROCK_IMAGE --severity HIGH,CRITICAL -q -f json --ignorefile "" | jq -r '.Results[].Vulnerabilities[].VulnerabilityID' 2>/dev/null || echo "No vulnerabilities found")
line=0
while read CVE;
do
line=$(( line + 1 ))
if [[ "$output" != *"$CVE"* ]] && [[ ! "$CVE" =~ ^#.* ]]
then
echo "::notice file=.trivyignore,line=${line}::$CVE not present anymore, can be safely removed."
fi
done < .trivyignore
fi
env:
TRIVY_USERNAME: ${{ github.actor }}
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
ROCK_IMAGE: ${{ env.IMAGE_REF }}

0 comments on commit d650bed

Please sign in to comment.