-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
62 lines (54 loc) · 1.86 KB
/
Copy pathentrypoint.sh
File metadata and controls
62 lines (54 loc) · 1.86 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
#!/bin/bash
set -e
TARGET="${PENTEST_TARGET:?Target URL is required}"
MODE="${PENTEST_MODE:-quick}"
OUTPUT_FORMAT="${PENTEST_OUTPUT:-json}"
DEPTH="${PENTEST_DEPTH:-2}"
TOOLS="${PENTEST_TOOLS:-all}"
PROVIDER="${LLM_PROVIDER:-openai}"
MODEL="${LLM_MODEL:-gpt-4}"
API_KEY="${LLM_API_KEY:?API key is required}"
mkdir -p pentest-results
echo "============================================"
echo " PentestCode - AI Penetration Testing"
echo "============================================"
echo ""
echo "Target: $TARGET"
echo "Mode: $MODE"
echo "Depth: $DEPTH"
echo "Tools: $TOOLS"
echo "LLM: $PROVIDER/$MODEL"
echo ""
pentestcode scan "$TARGET" \
--mode "$MODE" \
--output "pentest-results/report.$OUTPUT_FORMAT" \
--depth "$DEPTH" \
--tools "$TOOLS" \
--format "$OUTPUT_FORMAT" \
2>&1 | tee pentest-results/scan.log
# Parse results for GitHub outputs
if [ -f "pentest-results/report.json" ]; then
CRITICAL=$(cat pentest-results/report.json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('summary',{}).get('critical',0))" 2>/dev/null || echo "0")
HIGH=$(cat pentest-results/report.json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('summary',{}).get('high',0))" 2>/dev/null || echo "0")
else
CRITICAL=0
HIGH=0
fi
echo ""
echo "============================================"
echo " Scan Complete"
echo "============================================"
echo "Critical: $CRITICAL"
echo "High: $HIGH"
echo ""
# Set GitHub outputs if GITHUB_OUTPUT is available
if [ -n "$GITHUB_OUTPUT" ]; then
echo "results=pentest-results/report.$OUTPUT_FORMAT" >> "$GITHUB_OUTPUT"
echo "critical=$CRITICAL" >> "$GITHUB_OUTPUT"
echo "high=$HIGH" >> "$GITHUB_OUTPUT"
fi
# Fail on critical if requested
if [ "${FAIL_ON_CRITICAL:-false}" = "true" ] && [ "$CRITICAL" -gt 0 ]; then
echo "::error::Critical vulnerabilities found!"
exit 1
fi