Skip to content

Commit faa902b

Browse files
committed
Add code-scans
1 parent fa03751 commit faa902b

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

.github/pull_request_template.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Summary
2+
3+
<!-- What does this PR do? Keep it to 1-3 bullet points. -->
4+
5+
-
6+
7+
## Type of Change
8+
9+
<!-- Check the one that applies. -->
10+
11+
- [ ] Bug fix
12+
- [ ] New feature / enhancement
13+
- [ ] Documentation update
14+
- [ ] Refactor (no behavior change)
15+
- [ ] Chore (dependencies, CI, tooling)
16+
17+
## Changes Made
18+
19+
<!-- Briefly describe the key changes. Link to relevant issues if applicable. -->
20+
21+
Resolves #<!-- issue number -->
22+
23+
## How to Test
24+
25+
<!-- Steps a reviewer can follow to verify the changes. -->
26+
27+
1.
28+
29+
## Checklist
30+
31+
- [ ] I have read the [Contributing Guide](../CONTRIBUTING.md)
32+
- [ ] My branch is up to date with `main`
33+
- [ ] New environment variables (if any) are documented in `.env.example` and the README
34+
- [ ] No secrets, API keys, or credentials are included in this PR
35+
- [ ] I have tested my changes locally
36+
37+
## Screenshots (if applicable)
38+
39+
<!-- Add screenshots for UI changes. Delete this section if not applicable. -->

.github/workflows/code-scans.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: SDLE Scans
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
PR_number:
7+
description: 'Pull request number'
8+
required: true
9+
push:
10+
branches: [ main, finsights/dev ]
11+
pull_request:
12+
types: [opened, synchronize, reopened, ready_for_review]
13+
14+
concurrency:
15+
group: sdle-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
20+
# -----------------------------
21+
# 1) Trivy Scan (fixed)
22+
# -----------------------------
23+
trivy_scan:
24+
name: Trivy Vulnerability Scan
25+
runs-on: ubuntu-latest
26+
env:
27+
TRIVY_REPORT_FORMAT: table
28+
TRIVY_SCAN_TYPE: fs
29+
TRIVY_SCAN_PATH: .
30+
TRIVY_EXIT_CODE: '1'
31+
TRIVY_VULN_TYPE: os,library
32+
TRIVY_SEVERITY: CRITICAL,HIGH
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Create report directory
37+
run: mkdir -p trivy-reports
38+
39+
- name: Run Trivy FS Scan
40+
uses: aquasecurity/trivy-action@0.35.0
41+
with:
42+
scan-type: 'fs'
43+
scan-ref: '.'
44+
scanners: 'vuln,misconfig,secret,license'
45+
ignore-unfixed: true
46+
format: 'table'
47+
exit-code: '1'
48+
output: 'trivy-reports/trivy_scan_report.txt'
49+
vuln-type: 'os,library'
50+
severity: 'CRITICAL,HIGH'
51+
52+
- name: Upload Trivy Report
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: trivy-report
56+
path: trivy-reports/trivy_scan_report.txt
57+
- name: Show Trivy Report in Logs
58+
if: failure()
59+
run: |
60+
echo "========= TRIVY FINDINGS ========="
61+
cat trivy-reports/trivy_scan_report.txt
62+
echo "================================="
63+
64+
# -----------------------------
65+
# 2) Bandit Scan
66+
# -----------------------------
67+
bandit_scan:
68+
name: Bandit security scan
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
with:
74+
submodules: 'recursive'
75+
fetch-depth: 0
76+
- uses: actions/setup-python@v5
77+
with:
78+
python-version: "3.x"
79+
- name: Install Bandit
80+
run: pip install bandit
81+
- name: Create Bandit configuration
82+
run: |
83+
cat > .bandit << 'EOF'
84+
[bandit]
85+
exclude_dirs = tests,test,venv,.venv,node_modules
86+
skips = B101
87+
EOF
88+
shell: bash
89+
- name: Run Bandit scan
90+
run: |
91+
bandit -r . -ll -iii -f screen
92+
bandit -r . -ll -iii -f html -o bandit-report.html
93+
- name: Upload Bandit Report
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: bandit-report
97+
path: bandit-report.html
98+
retention-days: 30
99+
100+
# -----------------------------
101+
# 3) CodeQL Analysis
102+
# -----------------------------
103+
codeql_scan:
104+
name: CodeQL Analysis
105+
runs-on: ubuntu-latest
106+
permissions:
107+
security-events: write
108+
contents: read
109+
actions: read
110+
strategy:
111+
fail-fast: false
112+
matrix:
113+
language: [ 'python', 'javascript' ]
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@v4
117+
118+
- name: Initialize CodeQL
119+
uses: github/codeql-action/init@v3
120+
with:
121+
languages: ${{ matrix.language }}
122+
123+
- name: Autobuild
124+
uses: github/codeql-action/autobuild@v3
125+
126+
- name: Perform CodeQL Analysis
127+
uses: github/codeql-action/analyze@v3
128+
with:
129+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)