Skip to content

Create security scan script #2731

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 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Image Extracting and Security Scanning



on:
push:
branches:
- master

jobs:
image-extraction-and-security-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

# Install kustomize
- name: Install kustomize
run: |
sudo apt update
sudo apt install snapd
sudo snap install kustomize

# Install trivy
- name: Install trivy
run: |
sudo apt update
sudo snap install trivy

# Install jq
- name: Install jq
run: |
sudo apt update
sudo apt install jq

# Install Python
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
Copy link
Member

@juliusvonkohout juliusvonkohout Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the latest Python available in the base image


# Install prettytable package
- name: Install prettytable
run: |
pip install prettytable

# Run the shell script (extract_images.sh)
- name: Run image extracting and security scanning script
run: |
cd hack
chmod +x trivy_scan.sh
./trivy_scan.sh

# Upload the artifact
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment out the upload part for now? we do not want external dependencies.

- name: Upload trivy scanned_results
uses: actions/upload-artifact@v4
with:
name: trivy_scanned_results
path: docs/image_lists/




6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]


# Scanning reports of trivy
docs/image_lists/summary_of_severity_counts_for_WG/
docs/image_lists/severity_counts_with_images_for_WG/
docs/image_lists/security_scan_reports/
76 changes: 0 additions & 76 deletions hack/extract_images.sh

This file was deleted.

44 changes: 44 additions & 0 deletions hack/table_generate_for_security_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import json
from prettytable import PrettyTable

# Path to your JSON file
json_file = '../docs/image_lists/summary_of_severity_counts_for_WG/severity_summary_in_json_format.json'

# Load JSON content from the file
with open(json_file, 'r') as file:
data = json.load(file)

# Define a mapping for working group names
groupnames = {
"Automl": "AutoML",
"Pipelines": "Pipelines",
"Workbenches":"Workbenches(Notebooks)",
"Serving": "Kserve",
"Manifests":"Manifests",
"Training": "Training",
"Model-registry":"Model Registry",
"total": "All Images",
}

# Create PrettyTable
table = PrettyTable()
table.field_names = ["Working Group", "Images", "Critical CVE", "High CVE", "Medium CVE", "Low CVE"]

# Populate the table with data
for group_name in groupnames:
if group_name in data: # Check if group_name exists in data
value = data[group_name]
table.add_row([groupnames[group_name], value["images"], value["CRITICAL"], value["HIGH"], value["MEDIUM"], value["LOW"]])


# Print the table
print(table)

output_folder='../docs/image_lists/summary_of_severity_counts_for_WG/'

# Write the table output to a file in the specified folder
output_file = output_folder + 'summary_of_severity_counts_for_WGs_in_table.txt'
with open(output_file, 'w') as f:
f.write(str(table))

print("Output saved to:", output_file)
Loading