Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
233 lines (193 loc) Β· 7.11 KB
/
Copy pathMakefile
File metadata and controls
233 lines (193 loc) Β· 7.11 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Enhanced DevSecOps Policy Scanner Makefile
# Provides convenient commands for development and usage
.PHONY: help install test scan clean lint format docs build docker-build docker-run
# Default target
help:
@echo "π Enhanced DevSecOps Policy Scanner"
@echo "======================================"
@echo ""
@echo "Available commands:"
@echo ""
@echo "π¦ Installation & Setup:"
@echo " install Install all dependencies"
@echo " install-dev Install development dependencies"
@echo " install-tools Install security scanning tools"
@echo ""
@echo "π Scanning Commands:"
@echo " scan Run basic security scan"
@echo " scan-verbose Run verbose security scan"
@echo " scan-critical Scan only critical severity issues"
@echo " scan-cis Scan using CIS framework"
@echo " scan-owasp Scan using OWASP framework"
@echo " scan-k8s Scan Kubernetes manifests"
@echo " scan-docker Scan Docker configurations"
@echo " scan-terraform Scan Terraform code"
@echo ""
@echo "π Reporting & Analysis:"
@echo " list-policies List all available policies"
@echo " summary Show policy engine summary"
@echo " export-json Export policies to JSON"
@echo " export-yaml Export policies to YAML"
@echo " report-html Generate HTML report"
@echo ""
@echo "π§ͺ Development:"
@echo " test Run all tests"
@echo " test-coverage Run tests with coverage"
@echo " lint Run code linting"
@echo " format Format code with black"
@echo " clean Clean generated files"
@echo ""
@echo "π³ Docker:"
@echo " docker-build Build Docker image"
@echo " docker-run Run scanner in Docker"
@echo ""
@echo "π Documentation:"
@echo " docs Generate documentation"
@echo " docs-serve Serve documentation locally"
# Installation targets
install:
@echo "π¦ Installing dependencies..."
pip install -r requirements.txt
install-dev:
@echo "π§ Installing development dependencies..."
pip install -r requirements-dev.txt
install-tools:
@echo "π οΈ Installing security scanning tools..."
pip install bandit safety semgrep checkov trivy-python-plugin
# Scanning targets
scan:
@echo "π Running security scan..."
python src/enhanced_cli.py scan . --format text
scan-verbose:
@echo "π Running verbose security scan..."
python src/enhanced_cli.py scan . --verbose --format text
scan-critical:
@echo "π¨ Scanning critical severity issues..."
python src/enhanced_cli.py scan . --severity critical --format text
scan-cis:
@echo "π‘οΈ Scanning with CIS framework..."
python src/enhanced_cli.py scan . --framework CIS --format text
scan-owasp:
@echo "π Scanning with OWASP framework..."
python src/enhanced_cli.py scan . --framework OWASP --format text
scan-k8s:
@echo "βΈοΈ Scanning Kubernetes manifests..."
python src/enhanced_cli.py scan . --category pod_security --format text
scan-docker:
@echo "π³ Scanning Docker configurations..."
python src/enhanced_cli.py scan . --category container_security --format text
scan-terraform:
@echo "ποΈ Scanning Terraform code..."
python src/enhanced_cli.py scan . --category infrastructure --format text
# Reporting targets
list-policies:
@echo "π Listing all policies..."
python src/enhanced_cli.py list-policies
summary:
@echo "π Showing policy engine summary..."
python src/enhanced_cli.py summary
export-json:
@echo "π€ Exporting policies to JSON..."
python src/enhanced_cli.py export --format json --output policies_export
export-yaml:
@echo "π€ Exporting policies to YAML..."
python src/enhanced_cli.py export --format yaml --output policies_export
report-html:
@echo "π Generating HTML report..."
python src/enhanced_cli.py scan . --format html --output security_report
# Development targets
test:
@echo "π§ͺ Running tests..."
pytest tests/ -v
test-coverage:
@echo "π§ͺ Running tests with coverage..."
pytest tests/ --cov=src --cov-report=html --cov-report=term
lint:
@echo "π Running code linting..."
flake8 src/ tests/
bandit -r src/
format:
@echo "π¨ Formatting code..."
black src/ tests/
isort src/ tests/
clean:
@echo "π§Ή Cleaning generated files..."
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -delete
find . -type f -name "*.json" -path "./reports/*" -delete
find . -type f -name "*.html" -path "./reports/*" -delete
find . -type f -name "policies_export.*" -delete
find . -type f -name "security_report.*" -delete
rm -rf .coverage htmlcov/ .pytest_cache/
# Docker targets
docker-build:
@echo "π³ Building Docker image..."
docker build -t devsecops-policy-scanner .
docker-run:
@echo "π³ Running scanner in Docker..."
docker run --rm -v $(PWD):/app devsecops-policy-scanner scan /app
# Documentation targets
docs:
@echo "π Generating documentation..."
mkdocs build
docs-serve:
@echo "π Serving documentation locally..."
mkdocs serve
# Advanced scanning targets
scan-comprehensive:
@echo "π Running comprehensive security scan..."
python src/enhanced_cli.py scan . --verbose --format html --output comprehensive_report
scan-quick:
@echo "β‘ Running quick security scan..."
python src/enhanced_cli.py scan . --severity critical,high --format text
scan-custom:
@echo "π― Running custom security scan..."
python src/enhanced_cli.py scan . --category authentication,encryption --format json --output custom_report
# CI/CD targets
ci-scan:
@echo "π€ Running CI/CD security scan..."
python src/enhanced_cli.py scan . --format json --output ci_report
python src/advanced_scanner.py
ci-test:
@echo "π€ Running CI/CD tests..."
pytest tests/ --cov=src --cov-report=xml
flake8 src/ tests/
bandit -r src/ -f json -o bandit-report.json
# Security analysis targets
analyze-secrets:
@echo "π Analyzing for secrets..."
python src/advanced_scanner.py
analyze-dependencies:
@echo "π¦ Analyzing dependencies..."
safety check --json --output safety-report.json
analyze-code:
@echo "π» Analyzing code security..."
bandit -r src/ -f json -o bandit-report.json
# Utility targets
setup-dev:
@echo "π Setting up development environment..."
make install
make install-dev
make install-tools
@echo "β
Development environment ready!"
demo:
@echo "π― Running demo scan..."
python src/enhanced_cli.py scan . --severity critical,high --format text
@echo "π Generating demo report..."
python src/enhanced_cli.py scan . --format html --output demo_report
validate:
@echo "β
Validating configuration..."
python -c "from src.enhanced_policy_engine import EnhancedPolicyEngine; engine = EnhancedPolicyEngine(); print('β
Policy engine loaded successfully')"
@echo "β
Configuration is valid!"
# Helpers
.PHONY: check-deps
check-deps:
@echo "π Checking dependencies..."
python -c "import sys; print(f'Python version: {sys.version}')"
pip list | grep -E "(typer|rich|pyyaml|click)"
.PHONY: version
version:
@echo "π Scanner version information..."
python -c "import sys; print(f'Python: {sys.version}')"
python -c "import typer; print(f'Typer: {typer.__version__}')"
python -c "import rich; print(f'Rich: {rich.__version__}')"