Skip to content

Commit 8892c96

Browse files
committed
chore: update $PROJECT_ROOT ou $SCRIPT_DI path
1. full-security-audit.sh - Agora chama os outros scripts corretamente 2. brakeman-scan.sh - Usa caminhos absolutos 3. dependency-scan.sh - Usa caminhos absolutos 4. zap-baseline-scan.sh - Usa caminhos absolutos 5. zap-api-scan.sh - Usa caminhos absolutos 6. zap-full-scan.sh - Usa caminhos absolutos
1 parent 5cbab3a commit 8892c96

6 files changed

Lines changed: 44 additions & 14 deletions

File tree

security_tests/scripts/brakeman-scan.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44
set -e
55

6-
REPORT_DIR="./security_tests/reports/brakeman"
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+
11+
REPORT_DIR="$PROJECT_ROOT/security_tests/reports/brakeman"
712
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
813

914
GREEN='\033[0;32m'

security_tests/scripts/dependency-scan.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
set -e
66

7-
REPORT_DIR="./security_tests/reports/dependency-check"
7+
# Find project root directory
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
10+
cd "$PROJECT_ROOT"
11+
12+
REPORT_DIR="$PROJECT_ROOT/security_tests/reports/dependency-check"
813
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
914

1015
GREEN='\033[0;32m'

security_tests/scripts/full-security-audit.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
set -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+
611
GREEN='\033[0;32m'
712
YELLOW='\033[1;33m'
813
RED='\033[0;31m'
@@ -11,7 +16,7 @@ NC='\033[0m'
1116

1217
TARGET_URL=${1:-"http://localhost:3333"}
1318
TIMESTAMP=$(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

1621
mkdir -p "$REPORT_DIR"
1722

@@ -38,16 +43,16 @@ echo -e "${GREEN}✅ API is running${NC}\n"
3843
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
3944
echo -e "${GREEN}[1/6] Running Brakeman (Rails Security Scanner)${NC}"
4045
echo -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
4348
echo ""
4449

4550
# 2. Dependency Vulnerabilities
4651
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
4752
echo -e "${GREEN}[2/6] Checking Dependencies for Vulnerabilities${NC}"
4853
echo -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
5156
echo ""
5257

5358
# 3. Secret Detection
@@ -86,16 +91,16 @@ echo ""
8691
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
8792
echo -e "${GREEN}[4/6] OWASP ZAP Baseline Scan${NC}"
8893
echo -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
9196
echo ""
9297

9398
# 5. ZAP API Scan
9499
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
95100
echo -e "${GREEN}[5/6] OWASP ZAP API Scan${NC}"
96101
echo -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
99104
echo ""
100105

101106
# 6. Security Headers Check

security_tests/scripts/zap-api-scan.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
set -e
66

7+
# Find project root directory
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
10+
cd "$PROJECT_ROOT"
11+
712
TARGET_URL=${1:-"http://host.docker.internal:3333"}
813
API_SPEC=${2:-"http://host.docker.internal:3333/api-docs/v1/swagger.json"}
9-
REPORT_DIR="./security_tests/reports/zap"
14+
REPORT_DIR="$PROJECT_ROOT/security_tests/reports/zap"
1015
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
1116

1217
GREEN='\033[0;32m'

security_tests/scripts/zap-baseline-scan.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
set -e
66

7+
# Find project root directory
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
10+
cd "$PROJECT_ROOT"
11+
712
TARGET_URL=${1:-"http://host.docker.internal:3333"}
8-
REPORT_DIR="./security_tests/reports/zap"
13+
REPORT_DIR="$PROJECT_ROOT/security_tests/reports/zap"
914
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
1015

1116
GREEN='\033[0;32m'

security_tests/scripts/zap-full-scan.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
set -e
66

7+
# Find project root directory
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
10+
cd "$PROJECT_ROOT"
11+
712
TARGET_URL=${1:-"http://host.docker.internal:3333"}
8-
REPORT_DIR="./security_tests/reports/zap"
13+
REPORT_DIR="$PROJECT_ROOT/security_tests/reports/zap"
914
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
1015

1116
GREEN='\033[0;32m'

0 commit comments

Comments
 (0)