-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (113 loc) · 4.83 KB
/
Makefile
File metadata and controls
138 lines (113 loc) · 4.83 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
.PHONY: help install test scan pipeline-test clean docker-build docker-scan
# Default target
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
# Installation
install: ## Install the scanner and dependencies
pip install -e .
install-dev: ## Install development dependencies
pip install -e ".[test,dev]"
# Testing
test: ## Run all tests
pytest tests/ -v
test-pipeline: ## Test pipeline integration
@echo "Testing pipeline integration..."
@./scripts/pipeline-scan.sh --no-fail --summary-only .
@echo "Pipeline test completed successfully"
# Scanning
scan: ## Run basic scan on current directory
python -m confusion_hunter.scanner . --pretty --stdout
scan-pipeline: ## Run pipeline-friendly scan
python -m confusion_hunter.scanner . --fail-on-found --quiet --summary-only
scan-sarif: ## Run scan with SARIF output
python -m confusion_hunter.scanner . --output results.sarif --pretty
@echo "Results saved to results.sarif"
scan-json: ## Run scan with JSON output
python -m confusion_hunter.scanner . --raw --pretty --output results.json
@echo "Results saved to results.json"
# Pipeline testing
pipeline-test-github: ## Test GitHub Actions pipeline locally
@echo "Testing GitHub Actions pipeline..."
@pip install confusion-hunter 2>/dev/null || pip install -e .
@confusion-hunter . --fail-on-found --output github-test.sarif --pretty || true
@echo "GitHub Actions test completed"
pipeline-test-gitlab: ## Test GitLab CI pipeline locally
@echo "Testing GitLab CI pipeline..."
@pip install confusion-hunter 2>/dev/null || pip install -e .
@confusion-hunter . --fail-on-found --quiet --summary-only || true
@echo "GitLab CI test completed"
pipeline-test-jenkins: ## Test Jenkins pipeline locally
@echo "Testing Jenkins pipeline..."
@pip install confusion-hunter 2>/dev/null || pip install -e .
@confusion-hunter . --fail-on-found --output jenkins-test.sarif || true
@echo "Jenkins test completed"
# Docker
docker-build: ## Build Docker image
docker build -t confusion-hunter .
docker-scan: ## Run scan using Docker
docker run --rm -v $(PWD):/workspace confusion-hunter /workspace --fail-on-found --quiet --summary-only
# Development
lint: ## Run linting
flake8 confusion_hunter/ tests/
mypy confusion_hunter/
format: ## Format code
black confusion_hunter/ tests/
isort confusion_hunter/ tests/
# Cleanup
clean: ## Clean up generated files
rm -f *.sarif *.json
rm -rf __pycache__/ */__pycache__/
rm -rf .pytest_cache/
rm -rf *.egg-info/
rm -rf build/ dist/
clean-all: clean ## Clean everything including virtual environment
rm -rf venv/
# Examples and documentation
examples: ## Generate example outputs
@echo "Generating example outputs..."
@mkdir -p examples/outputs
@python -m confusion_hunter.scanner . --output examples/outputs/example.sarif --pretty 2>/dev/null || true
@python -m confusion_hunter.scanner . --raw --output examples/outputs/example.json --pretty 2>/dev/null || true
@echo "Examples generated in examples/outputs/"
# CI/CD simulation
simulate-ci: ## Simulate CI/CD pipeline execution
@echo "=== Simulating CI/CD Pipeline ==="
@echo "1. Installing scanner..."
@pip install -e . >/dev/null 2>&1
@echo "2. Running dependency scan..."
@confusion-hunter . --fail-on-found --output ci-simulation.sarif --quiet || { \
echo "❌ Pipeline would FAIL - unclaimed packages detected"; \
echo "Check ci-simulation.sarif for details"; \
exit 1; \
}
@echo "✅ Pipeline would SUCCEED - no issues found"
@rm -f ci-simulation.sarif
# Performance testing
perf-test: ## Run performance test
@echo "Running performance test..."
@time python -m confusion_hunter.scanner . --quiet --summary-only
@echo "Performance test completed"
# Security validation
security-check: ## Run security validation
@echo "Running security validation..."
@python -c "import confusion_hunter.scanner; print('✅ Scanner imports successfully')"
@python -m confusion_hunter.scanner --help >/dev/null && echo "✅ CLI interface works"
@echo "✅ Security validation passed"
# Release preparation
prepare-release: clean lint test ## Prepare for release
@echo "Preparing release..."
@python setup.py check
@echo "✅ Release preparation completed"
# Quick development workflow
dev: install-dev lint test ## Quick development setup and validation
# Pipeline integration validation
validate-pipelines: ## Validate all pipeline configurations
@echo "Validating pipeline configurations..."
@echo "✅ GitHub Actions: examples/github-actions.yml"
@echo "✅ GitLab CI: examples/gitlab-ci.yml"
@echo "✅ Jenkins: examples/jenkins.groovy"
@echo "✅ Azure DevOps: examples/azure-pipelines.yml"
@echo "✅ Docker Compose: examples/docker-compose.yml"
@echo "✅ Pipeline script: scripts/pipeline-scan.sh"
@echo "All pipeline configurations validated"