1- # name: Scan Image Frontend
2- # on:
3- # workflow_call:
1+ name : Scan Image Frontend
2+ on :
3+ workflow_call :
44
5- # jobs:
6- # scan-image:
7- # name: Security Scan
8- # runs-on: ubuntu-latest
9- # steps:
10- # - name: Install Trivy
11- # run: |
12- # sudo apt-get update
13- # sudo apt-get install -y wget
14- # wget https://github.com/aquasecurity/trivy/releases/download/v0.40.0/trivy_0.40.0_Linux-64bit.deb
15- # sudo dpkg -i trivy_0.40.0_Linux-64bit.deb
5+ jobs :
6+ scan-image :
7+ name : Security Scan
8+ runs-on : ubuntu-latest
9+ steps :
10+ - name : Install Trivy
11+ run : |
12+ sudo apt-get update
13+ sudo apt-get install -y wget
14+ wget https://github.com/aquasecurity/trivy/releases/download/v0.40.0/trivy_0.40.0_Linux-64bit.deb
15+ sudo dpkg -i trivy_0.40.0_Linux-64bit.deb
1616
17- # - name: Scan Docker image with Trivy
18- # id: scan-image
19- # run: |
20- # trivy image --format json --output scan-results.json datuits/devops-frontend:latest
17+ - name : Scan Docker image with Trivy
18+ id : scan-image
19+ run : |
20+ trivy image --format json --output scan-results.json datuits/devops-frontend:latest
2121
22- # - name: Extract high and critical vulnerabilities
23- # id: extract_vulnerabilities
24- # run: |
25- # jq -r '
26- # def hr(severity):
27- # if severity == "HIGH" or severity == "CRITICAL" then true else false end;
28- # def to_md:
29- # "| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
30- # [
31- # "# Docker Image Scan Results",
32- # "",
33- # "## High and Critical Vulnerabilities",
34- # "",
35- # "| Vulnerability ID | Package | Version | Severity | Description |",
36- # "|------------------|---------|---------|----------|-------------|",
37- # (.Results[] | .Vulnerabilities[] | select(hr(.Severity)) | to_md),
38- # ""
39- # ] | join("\n")
40- # ' scan-results.json > vulnerability-report.md
22+ - name : Extract high and critical vulnerabilities
23+ id : extract_vulnerabilities
24+ run : |
25+ jq -r '
26+ def hr(severity):
27+ if severity == "HIGH" or severity == "CRITICAL" then true else false end;
28+ def to_md:
29+ "| " + (.VulnerabilityID // "") + " | " + (.PkgName // "") + " | " + (.InstalledVersion // "") + " | " + (.Severity // "") + " | " + (.Title // "") + " |";
30+ [
31+ "# Docker Image Scan Results",
32+ "",
33+ "## High and Critical Vulnerabilities",
34+ "",
35+ "| Vulnerability ID | Package | Version | Severity | Description |",
36+ "|------------------|---------|---------|----------|-------------|",
37+ (.Results[] | .Vulnerabilities[] | select(hr(.Severity)) | to_md),
38+ ""
39+ ] | join("\n")
40+ ' scan-results.json > vulnerability-report.md
4141
42- # - name: Upload vulnerability report
43- # uses: actions/upload-artifact@v2
44- # with:
45- # name: vulnerability-report
46- # path: vulnerability-report.md
42+ - name : Upload vulnerability report
43+ uses : actions/upload-artifact@v2
44+ with :
45+ name : vulnerability-report
46+ path : vulnerability-report.md
4747
0 commit comments