Skip to content

Commit d4fa09c

Browse files
committed
chore: adjust test scheme
1 parent dc4921f commit d4fa09c

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

.pentest/test-secrets-quick.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fi
4444

4545
# 3. Check .env is in .gitignore
4646
echo "[3/5] Checking .env is ignored..."
47-
if grep -q "^\.env$" .gitignore 2>/dev/null; then
47+
if grep -qP "^\.env\r?$" .gitignore 2>/dev/null; then
4848
echo -e "${GREEN}[PASS]${NC} .env is in .gitignore"
4949
else
5050
echo -e "${RED}[FAIL]${NC} .env should be in .gitignore"
@@ -80,7 +80,6 @@ if [ $ISSUES -eq 0 ]; then
8080
echo -e "${GREEN}✓ No secrets exposed${NC}"
8181
exit 0
8282
else
83-
echo -e "${YELLOW}$ISSUES potential issues detected${NC}"
84-
echo "Review findings above"
85-
exit 0 # Warning, not critical failure
83+
echo -e "${RED}$ISSUES issue(s) detected — review findings above${NC}"
84+
exit 1
8685
fi

.pentest/test-ssrf-quick.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
22
# Quick SSRF Protection Test (works without auth since we check rejection)
33

4-
set -e
5-
64
API_URL="http://localhost:3333"
75
GREEN='\033[0;32m'
86
RED='\033[0;31m'
@@ -25,8 +23,8 @@ test_result() {
2523
fi
2624
}
2725

28-
# Note: Image proxy now requires authentication
29-
# So all these should return 401 Unauthorized (which is good - not vulnerable to SSRF from unauthenticated users)
26+
# Note: Image proxy intentionally skips JWT auth (browsers can't send Authorization on <img> src).
27+
# Security is enforced via domain allowlist + HTTPS-only + private IP/scheme blocking.
3028

3129
echo "[1/9] Testing localhost access (should be blocked)..."
3230
RESULT=$(curl -s -w "\n%{http_code}" "$API_URL/api/v1/images/proxy?url=http://localhost:6379")
@@ -108,14 +106,14 @@ else
108106
test_result "FAIL" "Should block HTTP (got HTTP $HTTP_CODE)"
109107
fi
110108

111-
echo "[9/9] Authentication required check..."
112-
RESULT=$(curl -s -w "\n%{http_code}" "$API_URL/api/v1/images/proxy?url=https://upload.wikimedia.org/test.png")
109+
echo "[9/9] Testing file:// scheme (local file read)..."
110+
RESULT=$(curl -s -w "\n%{http_code}" "$API_URL/api/v1/images/proxy?url=file:///etc/passwd")
113111
HTTP_CODE=$(echo "$RESULT" | tail -n1)
114112

115-
if [ "$HTTP_CODE" = "401" ]; then
116-
test_result "PASS" "Endpoint requires authentication (HTTP 401)"
113+
if [ "$HTTP_CODE" = "400" ] || [ "$HTTP_CODE" = "403" ]; then
114+
test_result "PASS" "Blocks file:// scheme (HTTP $HTTP_CODE)"
117115
else
118-
test_result "FAIL" "Endpoint should require authentication (got HTTP $HTTP_CODE)"
116+
test_result "FAIL" "Should block file:// scheme (got HTTP $HTTP_CODE)"
119117
fi
120118

121119
echo ""
@@ -127,7 +125,7 @@ echo -e "${GREEN}Passed: $PASSED${NC}"
127125
echo -e "${RED}Failed: $FAILED${NC}"
128126
echo ""
129127

130-
if [ $PASSED -ge 8 ]; then
128+
if [ $FAILED -eq 0 ]; then
131129
echo -e "${GREEN}✓ SSRF protection is SECURE${NC}"
132130
echo ""
133131
echo "Notes:"
@@ -136,6 +134,6 @@ if [ $PASSED -ge 8 ]; then
136134
echo "- Private IPs, localhost, and metadata endpoints protected"
137135
exit 0
138136
else
139-
echo -e "${RED}✗ SSRF vulnerabilities detected!${NC}"
137+
echo -e "${RED}✗ SSRF vulnerabilities detected ($FAILED failure(s))!${NC}"
140138
exit 1
141139
fi

0 commit comments

Comments
 (0)