Skip to content

Commit 4bbffa9

Browse files
committed
Fix missing-host-header test reliability
Keep stdin open with sleep after printf to prevent BusyBox nc from closing the connection before HAProxy processes the HTTP request in the backend. Also remove unnecessary 500ms delay from report script.
1 parent 5ae0b83 commit 4bbffa9

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

report/main.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { fileURLToPath } from "node:url";
66
const __dirname = dirname(fileURLToPath(import.meta.url));
77

88
// 1. Fetch proxy logs
9-
// Brief wait to ensure Docker log driver captures all HAProxy output
10-
await new Promise((resolve) => setTimeout(resolve, 500));
11-
129
const composeFile = process.argv[2] || join(__dirname, "..", "setup", "compose.yml");
1310
const logs = execFileSync(
1411
"docker",

test/Dockerfile.audit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RUN echo "=== [HTTPS - missing-sni] ===" && \
4848
# [HTTP - missing-host-header (HTTP request without Host header)]
4949
RUN echo "=== [HTTP - missing-host-header] ===" && \
5050
echo "Testing HTTP request without Host header (should be blocked)..." && \
51-
(printf 'GET / HTTP/1.0\r\n\r\n' | nc -w 5 allowed.example.com 80 > /dev/null 2>&1 || true) && \
51+
((printf 'GET / HTTP/1.0\r\n\r\n'; sleep 1) | nc -w 5 allowed.example.com 80 > /dev/null 2>&1 || true) && \
5252
echo "✓ missing-host-header: request sent (blocked expected in logs)"
5353

5454
# Network configuration check

test/Dockerfile.restrict

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ RUN echo "=== [HTTPS - missing-sni] ===" && \
8383
# [HTTP - missing-host-header (HTTP request without Host header)]
8484
RUN echo "=== [HTTP - missing-host-header] ===" && \
8585
echo "Testing HTTP request without Host header (should be blocked)..." && \
86-
(printf 'GET / HTTP/1.0\r\n\r\n' | nc -w 5 allowed.example.com 80 > /dev/null 2>&1 || true) && \
86+
((printf 'GET / HTTP/1.0\r\n\r\n'; sleep 1) | nc -w 5 allowed.example.com 80 > /dev/null 2>&1 || true) && \
8787
echo "✓ missing-host-header: request sent (blocked expected in logs)"
8888

8989
# Network configuration check

0 commit comments

Comments
 (0)