33
44set -e
55
6+ # Find project root directory
7+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
8+ PROJECT_ROOT=" $( cd " $SCRIPT_DIR /../.." && pwd) "
9+ cd " $PROJECT_ROOT "
10+
611GREEN=' \033[0;32m'
712YELLOW=' \033[1;33m'
813RED=' \033[0;31m'
@@ -11,7 +16,7 @@ NC='\033[0m'
1116
1217TARGET_URL=${1:- " http://localhost:3333" }
1318TIMESTAMP=$( date +%Y%m%d_%H%M%S)
14- REPORT_DIR=" . /security_tests/reports/audit-${TIMESTAMP} "
19+ REPORT_DIR=" $PROJECT_ROOT /security_tests/reports/audit-${TIMESTAMP} "
1520
1621mkdir -p " $REPORT_DIR "
1722
@@ -38,16 +43,16 @@ echo -e "${GREEN}✅ API is running${NC}\n"
3843echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
3944echo -e " ${GREEN} [1/6] Running Brakeman (Rails Security Scanner)${NC} "
4045echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
41- ./security_tests/scripts/ brakeman-scan.sh
42- cp security_tests/reports/brakeman/brakeman-* .{html,json} " $REPORT_DIR /" 2> /dev/null || true
46+ " $SCRIPT_DIR / brakeman-scan.sh"
47+ cp " $PROJECT_ROOT / security_tests/reports/brakeman/brakeman-" * .{html,json} " $REPORT_DIR /" 2> /dev/null || true
4348echo " "
4449
4550# 2. Dependency Vulnerabilities
4651echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
4752echo -e " ${GREEN} [2/6] Checking Dependencies for Vulnerabilities${NC} "
4853echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
49- ./security_tests/scripts/ dependency-scan.sh || true
50- cp security_tests/reports/dependency-check/* " $REPORT_DIR /" 2> /dev/null || true
54+ " $SCRIPT_DIR / dependency-scan.sh" || true
55+ cp " $PROJECT_ROOT / security_tests/reports/dependency-check/" * " $REPORT_DIR /" 2> /dev/null || true
5156echo " "
5257
5358# 3. Secret Detection
@@ -86,16 +91,16 @@ echo ""
8691echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
8792echo -e " ${GREEN} [4/6] OWASP ZAP Baseline Scan${NC} "
8893echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
89- ./security_tests/scripts/ zap-baseline-scan.sh " $TARGET_URL " || true
90- cp security_tests/reports/zap/baseline-scan-* .{html,json} " $REPORT_DIR /" 2> /dev/null || true
94+ " $SCRIPT_DIR / zap-baseline-scan.sh" " $TARGET_URL " || true
95+ cp " $PROJECT_ROOT / security_tests/reports/zap/baseline-scan-" * .{html,json} " $REPORT_DIR /" 2> /dev/null || true
9196echo " "
9297
9398# 5. ZAP API Scan
9499echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
95100echo -e " ${GREEN} [5/6] OWASP ZAP API Scan${NC} "
96101echo -e " ${BLUE} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC} "
97- ./security_tests/scripts/ zap-api-scan.sh " $TARGET_URL " " ${TARGET_URL} /api-docs/v1/swagger.json" || true
98- cp security_tests/reports/zap/api-scan-* .{html,json} " $REPORT_DIR /" 2> /dev/null || true
102+ " $SCRIPT_DIR / zap-api-scan.sh" " $TARGET_URL " " ${TARGET_URL} /api-docs/v1/swagger.json" || true
103+ cp " $PROJECT_ROOT / security_tests/reports/zap/api-scan-" * .{html,json} " $REPORT_DIR /" 2> /dev/null || true
99104echo " "
100105
101106# 6. Security Headers Check
0 commit comments