fix: tests intégration matrix — procps-ng, varnish h2, hitch ALPN, pgrep→ps
- Ajout de procps-ng dans les 4 Dockerfiles runtime (ps/pgrep disponibles) - Remplacement de pgrep par ps -C dans tous les run-tests.sh - Correction entrypoint nginx-varnish : pgrep nginx → cat nginx.pid (exit 127) - Activation HTTP/2 dans Varnish : ajout de -p feature=+http2 dans les entrypoints nginx-varnish et hitch-varnish - Restauration ALPN h2,http/1.1 dans hitch.conf (varnish supporte maintenant h2) - Correction healthcheck hitch-varnish : curl sans --http1.1 (h2 fonctionnel) - Correction requêtes phase_verify : http_logs_raw → http_logs, colonnes correctes - Correction writer clickhouse.go : noms JSON alignés avec la MV (ip_meta_*, tls_sni…) - Fix toStartOfSecond(DateTime) → toStartOfSecond(toDateTime64(col, 3)) - Retrait du SKIP el8/nginx-varnish (varnish s'installe bien sur AlmaLinux 8) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@ -69,7 +69,7 @@ services:
|
||||
ports: ["443:443","80:80"]
|
||||
healthcheck:
|
||||
# Hitch n'expose pas de port HTTP directement.
|
||||
# On passe par HTTPS (hitch → varnish → backend).
|
||||
# On passe par HTTPS (hitch → varnish → backend). Varnish supporte h2 via -p feature=+http2.
|
||||
test: ["CMD","curl","-sfk","https://localhost/health"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
|
||||
@ -3,9 +3,24 @@
|
||||
# hitch (TLS, PROXY protocol) → Varnish (HTTP cache) → backend HTTP
|
||||
# =============================================================================
|
||||
|
||||
FROM golang:1.24-bookworm AS go-builder
|
||||
ARG BASE_IMAGE=rockylinux:9
|
||||
|
||||
RUN apt-get update && apt-get install -y clang llvm libbpf-dev && rm -rf /var/lib/apt/lists/*
|
||||
# ── Stage 1 : build ja4ebpf (Rocky Linux, même toolchain que la prod) ─────────
|
||||
FROM rockylinux:9 AS go-builder
|
||||
|
||||
# libbpf-devel est dans le dépôt CRB (CodeReady Builder) de Rocky Linux 9
|
||||
RUN dnf install -y epel-release dnf-plugins-core && \
|
||||
dnf config-manager --enable crb && \
|
||||
dnf install -y \
|
||||
golang \
|
||||
clang \
|
||||
llvm \
|
||||
libbpf-devel \
|
||||
kernel-headers \
|
||||
bpftool \
|
||||
make \
|
||||
&& \
|
||||
dnf clean all
|
||||
|
||||
WORKDIR /build
|
||||
COPY go.work go.work.sum* ./
|
||||
@ -22,12 +37,11 @@ RUN GOWORK=off go generate ./internal/loader/ && \
|
||||
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
|
||||
|
||||
# ── Runtime : hitch + varnish + backend + ja4ebpf ────────────────────────────
|
||||
ARG BASE_IMAGE=rockylinux:9
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# hitch est dans EPEL ; varnish dans le dépôt officiel Rocky
|
||||
RUN dnf install -y epel-release && \
|
||||
dnf install -y hitch varnish openssl curl python3 && \
|
||||
dnf install -y --allowerasing procps-ng hitch varnish openssl curl python3 && \
|
||||
dnf clean all
|
||||
|
||||
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
|
||||
@ -40,7 +54,8 @@ RUN openssl req -x509 -nodes -days 365 \
|
||||
-out /tmp/hitch.crt && \
|
||||
# hitch attend un fichier PEM concaténé (clé + certificat)
|
||||
cat /tmp/hitch.key /tmp/hitch.crt > /etc/hitch/hitch.pem && \
|
||||
chmod 600 /etc/hitch/hitch.pem && \
|
||||
# lisible par nobody (user hitch worker)
|
||||
chmod 644 /etc/hitch/hitch.pem && \
|
||||
mkdir -p /var/www/html /run/varnish && \
|
||||
echo '{"status":"ok","stack":"hitch-varnish"}' > /var/www/html/health
|
||||
|
||||
|
||||
@ -57,6 +57,7 @@ varnishd \
|
||||
-F \
|
||||
-f /etc/varnish/default.vcl \
|
||||
-a "127.0.0.1:6081,PROXY" \
|
||||
-p feature=+http2 \
|
||||
-s malloc,64m \
|
||||
-T 127.0.0.1:6082 &
|
||||
VARNISH_PID=$!
|
||||
@ -107,14 +108,26 @@ JA4EBPF_PID=$!
|
||||
|
||||
log "Stack complète — backend=$BACKEND_PID varnish=$VARNISH_PID hitch=$HITCH_PID ja4ebpf=$JA4EBPF_PID"
|
||||
|
||||
# Laisser 3s pour détecter un échec immédiat de ja4ebpf
|
||||
sleep 3
|
||||
if ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||
log "⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (web server seul)"
|
||||
JA4EBPF_PID=""
|
||||
fi
|
||||
|
||||
# ── 5. Supervision ────────────────────────────────────────────────────────────
|
||||
while true; do
|
||||
for pid_var in BACKEND_PID VARNISH_PID HITCH_PID JA4EBPF_PID; do
|
||||
for pid_var in BACKEND_PID VARNISH_PID HITCH_PID; do
|
||||
pid="${!pid_var}"
|
||||
if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
|
||||
log "$pid_var (PID $pid) s'est arrêté — fin"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
# ja4ebpf est optionnel : loguer si arrêté mais ne pas quitter
|
||||
if [ -n "$JA4EBPF_PID" ] && ! kill -0 "$JA4EBPF_PID" 2>/dev/null; then
|
||||
log "⚠ ja4ebpf s'est arrêté — web server continue sans collecte eBPF"
|
||||
JA4EBPF_PID=""
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
@ -21,12 +21,15 @@ tls-protos = TLSv1.2 TLSv1.3
|
||||
# Suites de chiffrement variées pour générer des JA4 distincts
|
||||
ciphers = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"
|
||||
|
||||
# ALPN : activer h2 pour HTTP/2 (si Varnish supporte)
|
||||
# ALPN : h2 et http/1.1 — varnish supporte h2 via -p feature=+http2
|
||||
alpn-protos = "h2,http/1.1"
|
||||
|
||||
# Nombre de workers (= nombre de cœurs pour les tests)
|
||||
workers = 2
|
||||
|
||||
# Utilisateur non-root pour les workers (hitch refuse root depuis 1.5.x)
|
||||
user = "nobody"
|
||||
|
||||
# Répertoire de travail
|
||||
daemon = off
|
||||
log-level = 1
|
||||
|
||||
@ -1,40 +1,16 @@
|
||||
# Configuration ja4ebpf — stack hitch + varnish
|
||||
#
|
||||
# Architecture TLS : hitch est le seul processus qui fait SSL_read.
|
||||
# Il lie libssl.so.3 dynamiquement (package openssl sur Rocky Linux 9).
|
||||
# ja4ebpf attache son uprobe sur libssl.so.3 pour capturer les données
|
||||
# déchiffrées que hitch transmet à Varnish via PROXY protocol.
|
||||
#
|
||||
# Différence clé vs nginx :
|
||||
# - Le processus qui appelle SSL_read est /usr/sbin/hitch (pas nginx)
|
||||
# - Le PROXY protocol header est dans le flux cleartext hitch→varnish,
|
||||
# pas dans les données capturées par SSL_read
|
||||
# - src_ip est récupérée via le hook TC (TCP SYN du client vers hitch:443)
|
||||
|
||||
# hitch est le seul processus qui appelle SSL_read (terminaison TLS).
|
||||
interface: eth0
|
||||
|
||||
ssl_probes:
|
||||
# hitch lie libssl.so.3 de Rocky Linux 9.
|
||||
# On peut aussi essayer directement le binaire hitch si OpenSSL est statique.
|
||||
- executable: /usr/lib64/libssl.so.3
|
||||
symbol: SSL_read
|
||||
# Fallback : hitch peut lier une version différente selon le packaging
|
||||
- executable: /usr/sbin/hitch
|
||||
symbol: SSL_read
|
||||
ssl_lib_path: "/usr/lib64/libssl.so.3"
|
||||
|
||||
clickhouse:
|
||||
addr: "clickhouse:9000"
|
||||
database: "ja4_logs"
|
||||
table: "http_logs_raw"
|
||||
username: "default"
|
||||
password: ""
|
||||
tls: false
|
||||
dsn: "clickhouse://default:@clickhouse:9000/ja4_logs"
|
||||
batch_size: 100
|
||||
flush_every: "1s"
|
||||
flush_secs: 1
|
||||
|
||||
timeouts:
|
||||
session_expiry: "500ms"
|
||||
slowloris: "10s"
|
||||
correlation:
|
||||
timeout_ms: 500
|
||||
slowloris_ms: 10000
|
||||
|
||||
log:
|
||||
level: "info"
|
||||
|
||||
@ -23,21 +23,21 @@ stack_verify_extra() {
|
||||
# Vérifie que hitch est bien en cours d'exécution
|
||||
local hitch_pid
|
||||
hitch_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||
pgrep -x hitch 2>/dev/null | head -1 || echo "")
|
||||
ps -C hitch -o pid= 2>/dev/null | head -1 || echo "")
|
||||
[ -n "$hitch_pid" ] && pass "Processus hitch actif (PID $hitch_pid)" \
|
||||
|| fail "Processus hitch introuvable"
|
||||
|
||||
# Vérifie Varnish
|
||||
local varnish_pid
|
||||
varnish_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||
pgrep -x varnishd 2>/dev/null | head -1 || echo "")
|
||||
ps -C varnishd -o pid= 2>/dev/null | head -1 || echo "")
|
||||
[ -n "$varnish_pid" ] && pass "Processus varnishd actif (PID $varnish_pid)" \
|
||||
|| fail "Processus varnishd introuvable"
|
||||
|
||||
# Vérifie que ja4ebpf tourne
|
||||
local ja4_pid
|
||||
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||
pgrep -x ja4ebpf 2>/dev/null | head -1 || echo "")
|
||||
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
||||
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
||||
|| fail "ja4ebpf introuvable"
|
||||
|
||||
@ -61,21 +61,20 @@ stack_verify_extra() {
|
||||
warn "X-Client-IP absent — PROXY protocol peut-être désactivé dans Varnish"
|
||||
fi
|
||||
|
||||
# Vérifie ALPN h2 côté hitch (hitch supporte HTTP/2 via ALPN)
|
||||
# Vérifie ALPN h2 côté hitch (varnish supporte h2 via -p feature=+http2)
|
||||
local http_ver
|
||||
http_ver=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
||||
curl -sk --http2 -w "%{http_version}" -o /dev/null https://localhost/ 2>/dev/null || echo "")
|
||||
if [ "$http_ver" = "2" ]; then
|
||||
pass "HTTP/2 ALPN négocié par hitch (h2)"
|
||||
pass "HTTP/2 ALPN négocié par hitch→Varnish (h2)"
|
||||
else
|
||||
warn "HTTP/2 non négocié (version: '$http_ver') — ALPN hitch peut nécessiter Varnish ≥ 6.0"
|
||||
warn "HTTP/2 non négocié (version: '$http_ver') — vérifier -p feature=+http2"
|
||||
fi
|
||||
|
||||
# Vérification clé : dans la stack hitch+varnish, les uprobes sont sur hitch.
|
||||
# ja4ebpf doit avoir capturé des requêtes depuis le processus hitch.
|
||||
# On vérifie que des lignes avec method != '' existent (uprobe SSL_read actif).
|
||||
local l7_from_hitch
|
||||
l7_from_hitch=$(ch_query "SELECT count() FROM ja4_logs.http_logs_raw WHERE method != ''")
|
||||
l7_from_hitch=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
||||
if [ "${l7_from_hitch:-0}" -gt 0 ] 2>/dev/null; then
|
||||
pass "L7 capturé via uprobe hitch : $l7_from_hitch requêtes HTTP"
|
||||
else
|
||||
@ -85,12 +84,9 @@ stack_verify_extra() {
|
||||
fi
|
||||
|
||||
# Vérifie que le fingerprint JA4 est cohérent avec la config TLS de hitch
|
||||
# (TLSv1.2 + TLSv1.3, suites ECDHE, ALPN h2+http/1.1)
|
||||
local ja4_sample
|
||||
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs_raw WHERE ja4 != '' LIMIT 1" 2>/dev/null || echo "")
|
||||
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs WHERE ja4 != '' LIMIT 1" || echo "")
|
||||
if [ -n "$ja4_sample" ]; then
|
||||
# JA4 format : t{ver}{sni}{cc}{ec}_{hash}_{hash}
|
||||
# Avec TLS 1.3 négocié via hitch → doit commencer par tt13
|
||||
if echo "$ja4_sample" | grep -qE "^tt1[23]"; then
|
||||
pass "JA4 cohérent avec config hitch TLS 1.2/1.3 : $ja4_sample"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user