Skip to content

Commit

Permalink
adding trivy config
Browse files Browse the repository at this point in the history
Signed-off-by: John O'Loughlin <[email protected]>
  • Loading branch information
johnoloughlin committed Jan 11, 2024
1 parent ade22dc commit 51e3089
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/generate_reports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: "0.Gen_Report"

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Build
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11


- name: Build the Docker image
run: docker build . -f ./docker/userspacecni/Dockerfile -t userspacecni:latest


- name: Trivy Generate Reports
run: |
wget -q https://github.com/aquasecurity/trivy/releases/download/v0.48.2/trivy_0.48.2_Linux-64bit.deb
sudo apt install -y ./*.deb
echo "trivy fs -d ." |tee ./trivy_fs_scan.txt
trivy fs -d . &> ./trivy_fs_scan.txt
echo "trivy config -s HIGH,CRITICAL . -d" |tee ./trivy_config_scan.txt
trivy config -s HIGH,CRITICAL -d . &> ./trivy_config_scan.txt
echo "trivy image userspacecni:latest -s HIGH,CRITICAL" > ./trivy_image_scan.txt
trivy image userspacecni:latest -s HIGH,CRITICAL &> ./trivy_image_scan.txt
- name: Initialize CodeQL
uses: github/codeql-action/init@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v2.3.3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v2.3.3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v2.3.3
with:
category: "/language:${{ matrix.language }}"

- name: CodeQL and Dependabot Report Action
# if: ${{ github.event_name == 'workflow_dispatch' }}
uses: rsdmike/github-security-report-action@a149b24539044c92786ec39af8ba38c93496495d # v3.0.4
with:
template: report
token: ${{ secrets.SECURITY_TOKEN }}

- name: golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
$(go env GOPATH)/bin/golangci-lint run --color always -v ./...; exitcode=$?; [[ $exitcode != 0 ]] && echo "failed $exitcode" || echo "passed $exitcode" | aha > golangci-lint.html
- name: GitHub Upload Trivy Reports
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: reports
path: |
./trivy_fs_scan.txt
./trivy_config_scan.txt
./trivy_image_scan.txt
./report.pdf
30 changes: 30 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,33 @@ jobs:
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v3.22.12
with:
sarif_file: 'trivy-results.sarif'

# - name: Run Trivy vulnerability scanner in repo mode
# uses: aquasecurity/trivy-action@master
# id: fs_trivy
# with:
# scan-type: 'fs'
# format: 'github' #table
# output: './trivy_config.txt'
# # severity: 'CRITICAL,HIGH'

- name: Trivy Generate Reports
run: |
wget -q https://github.com/aquasecurity/trivy/releases/download/v0.48.2/trivy_0.48.2_Linux-64bit.deb
sudo apt install -y ./*.deb
echo "trivy fs -d ." |tee ./trivy_fs_scan.txt
trivy fs -d . &> ./trivy_fs_scan.txt
echo "trivy config -s HIGH,CRITICAL . -d" |tee ./trivy_config_scan.txt
trivy config -s HIGH,CRITICAL -d . &> ./trivy_config_scan.txt
echo "trivy image userspacecni:latest -s HIGH,CRITICAL" > ./trivy_image_scan.txt
trivy image userspacecni:latest -s HIGH,CRITICAL &> ./trivy_image_scan.txt
- name: GitHub Upload Trivy Reports
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: trivy_reports
path: |
./trivy_fs_scan.txt
./trivy_config_scan.txt
./trivy_image_scan.txt

0 comments on commit 51e3089

Please sign in to comment.