Skip to content
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

added branch creation with result file #48

Merged
merged 42 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2fd6b40
added branch creation with result file
RonShvarz Jul 6, 2023
0abe4e6
added clickable link to log
RonShvarz Jul 6, 2023
6be1e9a
force result branch override
RonShvarz Jul 6, 2023
34beee2
try trivy bash scanning with license enabled
RonShvarz Jul 6, 2023
2e6896c
fix trivy url
RonShvarz Jul 6, 2023
53f07c3
fixed trivy url to latest
RonShvarz Jul 6, 2023
bd4f34a
remove unnecesary code
RonShvarz Jul 6, 2023
11f99cb
upgrade deprecated bash command
RonShvarz Jul 6, 2023
ce46aef
added correct tags, and fs path
RonShvarz Jul 9, 2023
b41966b
Added full scanning flow with licenses and vulnrabilities
RonShvarz Sep 6, 2023
cc08c1c
trigger manual workflow so it will be available.
RonShvarz Sep 7, 2023
dbd6c0f
amend
RonShvarz Sep 7, 2023
7c13ff6
Added default value to image
RonShvarz Sep 7, 2023
0539d81
trying to fix default run
RonShvarz Sep 7, 2023
c1dab4b
manually added value to force availability of the ci action
RonShvarz Sep 7, 2023
f1dbc39
latest is not supported, ovveride with last version.
RonShvarz Sep 7, 2023
c743443
clean yaml file
RonShvarz Sep 7, 2023
4944ebb
fix commit message for the branch creation.
RonShvarz Sep 10, 2023
ad6e957
Debugging force push removal, mock image name WIP
RonShvarz Sep 11, 2023
16d88a8
feed the correct branch to the pull action
RonShvarz Sep 11, 2023
b9bbc55
more git changes for ci
RonShvarz Sep 11, 2023
a82c4e1
branch existance verification
RonShvarz Sep 11, 2023
3e2f05a
pull with strategy
RonShvarz Sep 11, 2023
594984f
Pulling origin/branch in ci
RonShvarz Sep 13, 2023
1ff2b66
added echo and pull in ci
RonShvarz Sep 13, 2023
d6805d2
trying to find the origin branch
RonShvarz Sep 13, 2023
a77c855
remove 'local' keyword
RonShvarz Sep 13, 2023
d8066cd
hardcoded branch name
RonShvarz Sep 13, 2023
91d9ad9
remove empty string conditional
RonShvarz Sep 13, 2023
346b8c5
Added fetch, and echos for debug.
RonShvarz Sep 13, 2023
2602911
Add final flow that saves previous run results.
RonShvarz Sep 13, 2023
72bdad2
Some step name changes, applied git strategy to existing ci
RonShvarz Sep 13, 2023
884792a
test if pull is unneeded
RonShvarz Sep 18, 2023
31a82f7
add push to trigger
RonShvarz Sep 18, 2023
69d295f
added pull after untracked message
RonShvarz Sep 18, 2023
dee2fe1
format the scan files to be json
RonShvarz Sep 18, 2023
141dd06
Always show branch link even if steps fail.
RonShvarz Sep 18, 2023
de42bdf
step rename + triggering action
RonShvarz Sep 18, 2023
ff7b405
Added git status for debug
RonShvarz Sep 18, 2023
78044f2
revert to txt files, add unique file to be able to commit
RonShvarz Sep 18, 2023
890e648
step rename
RonShvarz Sep 18, 2023
66ed4d0
Added back license scan on-demand, edited main CI to contain timestam…
RonShvarz Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 57 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,66 @@ jobs:
env:
DOCKER_HUB_PASS: ${{ secrets.DOCKER_PASSWORD }}

- name: Run Trivy vulnerability scanner on the docker image
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.IMAGE_NAME }}'
severity: CRITICAL
format: 'sarif'
output: 'trivy-results.sarif'
- name: Install Trivy
run: |
wget https://github.com/aquasecurity/trivy/releases/download/v0.43.0/trivy_0.43.0_Linux-64bit.deb
sudo dpkg -i trivy_0.43.0_Linux-64bit.deb

- name: Run Trivy license scan on repo
run: trivy fs /home/runner/work --scanners license --license-full --severity 'HIGH,CRITICAL' > trivy_license_filesystem.txt

- name: Run Trivy vulnerability scanner on the repo
run: trivy fs /home/runner/work --severity 'HIGH,CRITICAL' --format sarif --output trivy_vuln_filesystem.sarif

- name: Run Trivy license scan on image
run: trivy image --scanners license --license-full --severity 'HIGH,CRITICAL' '${{ env.IMAGE_NAME }}' > trivy_license_image.txt

- name: Run Trivy vulnerability scanner on image
run: trivy image --severity 'HIGH,CRITICAL' --format sarif --output trivy_vuln_image.sarif '${{ env.IMAGE_NAME }}'

- name: Upload Trivy scan results to GitHub Security tab
- name: Upload Trivy image vulnerability results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy_vuln_image.sarif'
category: 'Trivy-Vulnerability-Image'

- name: Upload Trivy repo vulnerability results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
sarif_file: 'trivy_vuln_filesystem.sarif'
category: 'Trivy-Vulnerability-Repo'

- name: Update a branch with scan results
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"

existed_in_remote=$(git ls-remote --heads origin trivy-scan-results)
if [[ ${existed_in_remote} ]]; then
echo "branch exists in remote"
git fetch origin trivy-scan-results
echo "branch fetched"
git checkout trivy-scan-results
echo "origin branch swapped"
else
git checkout -b trivy-scan-results
echo "new branch swapped"
fi

mkdir -p TrivyScans
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
echo "$TIMESTAMP" > ScanTimeStamp.txt
cp ScanTimeStamp.txt TrivyScans/
cp trivy_license_filesystem.txt TrivyScans/
cp trivy_license_image.txt TrivyScans/
git add TrivyScans/trivy_license_filesystem.txt
git add TrivyScans/trivy_license_image.txt
git add TrivyScans/ScanTimeStamp.txt
git commit -m "Add trivy scan result files to the folder 'TrivyScans'"
git push origin trivy-scan-results

- name: Display branch and file path link
run: echo "Results uploaded to [trivy-scan-results branch](https://github.com/$GITHUB_REPOSITORY/tree/trivy-scan-results/TrivyScans/)"

- name: trigger site docker
id: trigger
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This is a basic workflow to help you get started with Actions

name: TRIVY-SCAN

# Controls when the action will run.
on:
workflow_dispatch:
inputs:
image-ref:
description: Full docker image path (e.g. docker.io/hkube/site:v1.2.3)
required: true
default: 'docker.io/hkube/site:v2.6.4'
jobs:
# This workflow contains a single job called "scan_and_upload"
scan_and_upload:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Install Trivy
run: |
wget https://github.com/aquasecurity/trivy/releases/download/v0.43.0/trivy_0.43.0_Linux-64bit.deb
sudo dpkg -i trivy_0.43.0_Linux-64bit.deb

- name: Run Trivy license scan on repo
run: trivy fs /home/runner/work --scanners license --license-full --severity 'HIGH,CRITICAL' --format json --output trivy_license_filesystem.txt

- name: Run Trivy vulnerability scanner on repo
run: trivy fs /home/runner/work --severity 'HIGH,CRITICAL' > trivy_vuln_filesystem.txt

- name: Run Trivy license scan on image
run: trivy image --scanners license --license-full --severity 'HIGH,CRITICAL' '${{ inputs.image-ref }}' > trivy_license_image.txt

- name: Run Trivy vulnerability scanner on image
run: trivy image --severity 'HIGH,CRITICAL' '${{ inputs.image-ref }}' > trivy_vuln_image.txt

- name: Update a branch with scan results
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"

existed_in_remote=$(git ls-remote --heads origin trivy-scan-results)
if [[ ${existed_in_remote} ]]; then
echo "branch exists in remote"
git fetch origin trivy-scan-results
echo "branch fetched"
git checkout trivy-scan-results
echo "origin branch swapped"
else
git checkout -b trivy-scan-results
echo "new branch swapped"
fi

mkdir -p TrivyScans
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
echo "$TIMESTAMP" > ScanTimeStamp.txt
cp ScanTimeStamp.txt TrivyScans/
cp trivy_license_filesystem.txt TrivyScans/
cp trivy_vuln_filesystem.txt TrivyScans/
cp trivy_license_image.txt TrivyScans/
cp trivy_vuln_image.txt TrivyScans/
git add TrivyScans/trivy_license_filesystem.txt
git add TrivyScans/trivy_vuln_filesystem.txt
git add TrivyScans/trivy_license_image.txt
git add TrivyScans/trivy_vuln_image.txt
git add TrivyScans/ScanTimeStamp.txt
git commit -m "Add trivy scan result files to the folder 'TrivyScans'"
git push origin trivy-scan-results


- name: Display branch link
run: echo "Results uploaded to [trivy-scan-results branch](https://github.com/$GITHUB_REPOSITORY/tree/trivy-scan-results/TrivyScans/)"
if: always()
33 changes: 0 additions & 33 deletions .github/workflows/trivy_docker.yaml

This file was deleted.