forked from jndamito/onlinebookstore
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (102 loc) · 3.4 KB
/
security-scan.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Security Scan
on:
workflow_dispatch:
# push:
# branches:
# - main
jobs:
snyk_scan:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Snyk CLI
run: npm install -g snyk
- name: Authenticate with Snyk
run: snyk auth ${{ secrets.SNYK_TOKEN }}
- name: Run Snyk scan and save JSON report
run: |
snyk test --json > snyk_results.json || true
sleep 10
- name: Upload Snyk results
uses: actions/upload-artifact@v3
with:
name: snyk-results
path: snyk_results.json
code-ql-analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
packages: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [java-kotlin]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Maven Build
run: mvn -B clean package
env:
JAVA_HOME: ${{ steps.setup-java.outputs.java-home }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
output: codeql-results.sarif
- name: Debug - List files
run: ls -la ./codeql-results.sarif
- name: Convert SARIF to JSON
run: |
wget -O sarif-converter https://gitlab.com/ignis-build/sarif-converter/-/releases/permalink/latest/downloads/bin/sarif-converter-linux
chmod +x sarif-converter
./sarif-converter --type codequality codeql-results.sarif/java.sarif codeql-results.json
- name: Upload CodeQL results
uses: actions/upload-artifact@v3
with:
name: codeql-results
path: codeql-results.json
compare_results:
runs-on: ubuntu-latest
needs: [snyk_scan, code-ql-analyze] # Depends on both scans
# env:
# SEMGREP_SEND_METRICS: 'on'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
# - name: Install Semgrep
# run: |
# pip install semgrep
# pip install -r Matching_scripts/requirements.txt
# - name: Compare and Consolidate Results
# run: |
# semgrep --config ./Matching_scripts/semgrep.yml ./snyk-results/snyk_results.json ./codeql-results/codeql-results.json --json --output results_comparison.json
# # semgrep --metrics off --config Matching_scripts/semgrep.yml \
# # snyk-results.json codeql-results.json \
# # --json --output results_comparison.json
- name: Process Comparison Results
run: python ./Matching_scripts/compare_vulnerabilities.py
- name: Upload Consolidated Results
uses: actions/upload-artifact@v3
with:
name: consolidated-results
path: consolidated_results.json