Skip to content

Commit c049cce

Browse files
wip
1 parent c79f067 commit c049cce

File tree

3 files changed

+221
-0
lines changed

3 files changed

+221
-0
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,44 @@ jobs:
158158
echo "Failing due to CodeQL alerts."
159159
exit 1
160160
fi
161+
162+
clamav_malware_scan:
163+
name: ClamAV Malware Scan
164+
runs-on: ubuntu-latest
165+
steps:
166+
- name: Checkout repository
167+
uses: actions/checkout@v4
168+
169+
- name: Install ClamAV
170+
run: |
171+
sudo apt-get update
172+
sudo apt-get install -y clamav clamav-daemon
173+
174+
- name: Update ClamAV database
175+
run: |
176+
sudo systemctl stop clamav-freshclam || true
177+
sudo freshclam --verbose
178+
179+
- name: Scan repository with ClamAV
180+
run: |
181+
echo "Starting ClamAV scan of repository..."
182+
clamscan -r -i --exclude-dir=node_modules --exclude-dir=.git --exclude-dir=dist . > clamav-scan.log 2>&1 || true
183+
cat clamav-scan.log
184+
185+
- name: Check for infections
186+
run: |
187+
if grep -q "Infected files: 0" clamav-scan.log; then
188+
echo "✅ No malware detected!"
189+
exit 0
190+
else
191+
echo "❌ Malware detected! Check the scan log."
192+
grep "FOUND" clamav-scan.log || true
193+
exit 1
194+
fi
195+
196+
- name: Upload ClamAV scan log
197+
if: always()
198+
uses: actions/upload-artifact@v4
199+
with:
200+
name: clamav-scan-log
201+
path: clamav-scan.log

docs/SECURITY-TESTING.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Security Testing Guide
2+
3+
This guide explains how to run security scans locally before pushing to CI.
4+
5+
## ClamAV Malware Scan
6+
7+
### Installation
8+
9+
**macOS:**
10+
```bash
11+
brew install clamav
12+
```
13+
14+
**Ubuntu/Debian:**
15+
```bash
16+
sudo apt-get update
17+
sudo apt-get install clamav clamav-daemon
18+
```
19+
20+
### Update Virus Database
21+
22+
```bash
23+
# Stop the freshclam daemon if running
24+
sudo systemctl stop clamav-freshclam # Linux
25+
# or
26+
brew services stop clamav # macOS
27+
28+
# Update the database
29+
sudo freshclam
30+
# or
31+
freshclam # if running as user
32+
```
33+
34+
### Run Scan Locally
35+
36+
```bash
37+
# Scan the repository (excluding node_modules, .git, dist)
38+
clamscan -r -i --exclude-dir=node_modules --exclude-dir=.git --exclude-dir=dist .
39+
```
40+
41+
**Options:**
42+
- `-r` : Recursive scan
43+
- `-i` : Only show infected files
44+
- `--exclude-dir` : Exclude specific directories
45+
46+
### Expected Output
47+
48+
If no malware is detected:
49+
```
50+
----------- SCAN SUMMARY -----------
51+
Known viruses: 8700000
52+
Engine version: 1.0.0
53+
Scanned directories: X
54+
Scanned files: XXX
55+
Infected files: 0
56+
Data scanned: XX.XX MB
57+
Time: XX.XXX sec (X m XXs)
58+
Start Date: YYYY:MM:DD HH:MM:SS
59+
End Date: YYYY:MM:DD HH:MM:SS
60+
```
61+
62+
## Other Security Scans
63+
64+
### Semgrep
65+
66+
```bash
67+
# Install
68+
pip install semgrep
69+
70+
# Run scan
71+
semgrep scan --config auto .
72+
```
73+
74+
### Gitleaks (Secret Detection)
75+
76+
```bash
77+
# Install
78+
brew install gitleaks # macOS
79+
# or download from https://github.com/gitleaks/gitleaks/releases
80+
81+
# Run scan
82+
gitleaks detect --source . --no-git
83+
```
84+
85+
### Dependency Audit
86+
87+
```bash
88+
# Check for vulnerable dependencies
89+
npx audit-ci --package-manager yarn --severity high
90+
```
91+
92+
### All Tests
93+
94+
```bash
95+
# Run unit tests with coverage
96+
yarn test
97+
yarn coverage
98+
```
99+
100+
## Continuous Integration
101+
102+
All these scans run automatically in GitHub Actions on every push:
103+
104+
- **Test** : Unit tests with coverage
105+
- **Semgrep** : SAST security scanning
106+
- **CodeQL** : Advanced security analysis
107+
- **Gitleaks** : Secret detection
108+
- **Dependency Audit** : npm/yarn vulnerability check
109+
- **ClamAV** : Malware detection
110+
111+
Check `.github/workflows/ci.yml` for the full CI configuration.
112+
113+
## Troubleshooting
114+
115+
### ClamAV Database Update Fails
116+
117+
If `freshclam` fails with permission errors:
118+
```bash
119+
sudo freshclam
120+
```
121+
122+
If it fails because the daemon is running:
123+
```bash
124+
# Linux
125+
sudo systemctl stop clamav-freshclam
126+
sudo freshclam
127+
sudo systemctl start clamav-freshclam
128+
129+
# macOS
130+
brew services stop clamav
131+
freshclam
132+
brew services start clamav
133+
```
134+
135+
### ClamAV Scan Takes Too Long
136+
137+
Use the `-i` flag to only show infected files and speed up output:
138+
```bash
139+
clamscan -r -i --exclude-dir=node_modules .
140+
```
141+
142+
### False Positives
143+
144+
If ClamAV reports a false positive:
145+
1. Verify the file is legitimate
146+
2. Report to ClamAV: https://www.clamav.net/reports/fp
147+
3. Add to exclusion list if needed

docs/SECURITY.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,39 @@
22

33
This document describes security measures implemented in Tab Modifier.
44

5+
## CI/CD Security Scanning
6+
7+
Tab Modifier uses multiple security scanning tools in the CI/CD pipeline to ensure code quality and security:
8+
9+
### 1. ClamAV Malware Scan
10+
- **Purpose**: Detects viruses, trojans, and other malware in the codebase
11+
- **Frequency**: On every push to any branch
12+
- **Configuration**: `.github/workflows/ci.yml` - `clamav_malware_scan` job
13+
- **Coverage**: Scans all files except `node_modules`, `.git`, and `dist`
14+
- **Action on detection**: Pipeline fails if malware is detected
15+
16+
### 2. Semgrep SAST (Static Application Security Testing)
17+
- **Purpose**: Detects security vulnerabilities and code quality issues
18+
- **Configuration**: `.github/workflows/ci.yml` - `semgrep_scan` job
19+
- **Results**: Uploaded to GitHub Security Dashboard as SARIF
20+
21+
### 3. CodeQL SAST
22+
- **Purpose**: Advanced semantic code analysis for security vulnerabilities
23+
- **Configuration**: `.github/workflows/ci.yml` - `codeql_sast` job
24+
- **Queries**: `security-extended` and `security-and-quality`
25+
- **Results**: Uploaded to GitHub Security Dashboard
26+
27+
### 4. Gitleaks Secret Scan
28+
- **Purpose**: Detects hardcoded secrets, API keys, and credentials
29+
- **Configuration**: `.github/workflows/ci.yml` - `gitleaks_scan` job
30+
- **Action on detection**: Pipeline fails if secrets are found
31+
32+
### 5. Dependency Vulnerability Audit
33+
- **Purpose**: Checks for known vulnerabilities in npm/yarn dependencies
34+
- **Configuration**: `.github/workflows/ci.yml` - `dependency_audit` job
35+
- **Severity**: Fails on HIGH severity and above
36+
- **Tool**: `audit-ci` with yarn
37+
538
## ReDoS (Regular Expression Denial of Service) Protection
639

740
### Background

0 commit comments

Comments
 (0)