feat: pipeline L7 HTTP complet + infrastructure tests VM

Correctifs pipeline L7 (uprobe SSL_read) :
- uprobe_ssl.c : ssl_set_fd ne retourne plus tôt quand fd_conn_map est
  vide (accept4 non disponible en Docker). Sauvegarde ssl_ptr→{fd,0,0}
  pour permettre le fallback /proc côté Go.
- main.go : consumeSSLEvents reécrit avec routeur magic-bytes complet :
  * HTTP/2 preface → extraction SETTINGS + conversion correlation.HTTP2Settings
  * HTTP/1.x requête → method, path, query, headers, header_order_sig
  * HTTP/1.x réponse → status_code
  * Fallback /proc/<tgid>/fd/<fd> quand src_ip=0 (accept4 absent)
- writer/clickhouse.go : export header_order_signature ajouté

Nouveaux packages :
- internal/parser/http1.go : parseur HTTP/1.x (IsHTTP1Request,
  ParseHTTP1Request, IsHTTP1Response, ParseHTTP1Response)
- internal/parser/http1_test.go : 11 tests unitaires (28 total passent)
- internal/procutil/proc_lookup.go : résolution fd→IP via /proc avec cache
  TTL 5s (FDCache). Supporte /proc/PID/net/tcp et tcp6, IPv4-mappé IPv6.

Infrastructure tests VM (tests/vm/) :
- Vagrantfile : VM Rocky Linux 9 KVM, 4 CPU / 4 GB RAM
- provision.sh : installation toolchain eBPF + Go + Docker + nginx
- run-tests-vm.sh : suite de test complète dans la VM (L3/L4+TLS+L7)
- README.md : guide d'installation et d'utilisation
- Makefile : cibles vm-up, vm-down, vm-ssh, test-vm-nginx, test-vm-all,
  vm-rebuild-ja4ebpf

Corrections stack Docker :
- Dockerfiles nginx/apache/nginx-varnish/hitch-varnish : suppression des
  références à shared/go/ja4common/ (répertoire supprimé)
- clickhouse-init.sh : restauré depuis git, seed anubis_ua_rules obsolète
  supprimé (table REGEXP_TREE supprimée du schéma)
- traffic-gen : ajout HTTP/1.0 (http.client) et HTTP/2 (httpx)
- verify_db.py : script de vérification 35 checks (L3/L4/TLS/L7/corrélation)
- run-stack-tests.sh : phase 6 verify_db ajoutée

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
toto
2026-04-12 02:37:00 +02:00
parent 9734e21fe3
commit f85a10b012
21 changed files with 1868 additions and 74 deletions

118
tests/vm/provision.sh Executable file
View File

@ -0,0 +1,118 @@
#!/usr/bin/env bash
# =============================================================================
# provision.sh — Provisionnement de la VM Rocky Linux 9 pour ja4ebpf
#
# Installe :
# - Toolchain eBPF : clang, llvm, bpftool, libbpf-devel, kernel-devel
# - Go 1.24
# - Docker (pour ClickHouse)
# - nginx + openssl (serveur web cible)
# - Outils de test : python3, httpx
# =============================================================================
set -euo pipefail
log() { echo "[provision] $(date +%H:%M:%S) $*"; }
# ── 1. Mise à jour système + dépôts ──────────────────────────────────────────
log "Mise à jour des dépôts..."
dnf install -y epel-release dnf-plugins-core
dnf config-manager --enable crb
dnf update -y --quiet
# ── 2. Toolchain eBPF ────────────────────────────────────────────────────────
log "Installation toolchain eBPF (clang, bpftool, libbpf)..."
dnf install -y \
clang \
llvm \
bpftool \
libbpf-devel \
kernel-devel-$(uname -r) \
make \
git
# ── 3. Go (version récente) ──────────────────────────────────────────────────
log "Installation de Go..."
GO_VERSION="1.24.3"
if ! command -v go &>/dev/null || [[ "$(go version 2>/dev/null | awk '{print $3}')" != "go${GO_VERSION}" ]]; then
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf /tmp/go.tar.gz
rm /tmp/go.tar.gz
fi
export PATH="/usr/local/go/bin:$PATH"
# Persister dans le PATH
cat > /etc/profile.d/go.sh << 'EOF'
export PATH="/usr/local/go/bin:$PATH"
export GOPATH="/home/vagrant/go"
EOF
# ── 4. Docker (pour ClickHouse) ───────────────────────────────────────────────
log "Installation de Docker..."
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl enable --now docker
usermod -aG docker vagrant
# Accès sans sudo pour vagrant
chmod 666 /var/run/docker.sock || true
# ── 5. nginx + openssl ───────────────────────────────────────────────────────
log "Installation de nginx..."
dnf install -y nginx openssl curl
# ── 6. Python3 + outils de test ──────────────────────────────────────────────
log "Installation Python3 et outils de test..."
dnf install -y python3 python3-pip
pip3 install --quiet "httpx[http2]" requests
# ── 7. Outils de debug eBPF ──────────────────────────────────────────────────
log "Installation outils de debug eBPF..."
dnf install -y perf strace
# ── 8. Montage tracefs + debugfs au démarrage ─────────────────────────────────
log "Configuration des pseudo-systèmes de fichiers eBPF..."
cat > /etc/systemd/system/tracefs.mount << 'EOF'
[Unit]
Description=Mount tracefs
DefaultDependencies=no
After=local-fs.target
[Mount]
What=tracefs
Where=/sys/kernel/tracing
Type=tracefs
Options=defaults
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/debugfs.mount << 'EOF'
[Unit]
Description=Mount debugfs
DefaultDependencies=no
After=local-fs.target
[Mount]
What=debugfs
Where=/sys/kernel/debug
Type=debugfs
Options=defaults
[Install]
WantedBy=multi-user.target
EOF
systemctl enable tracefs.mount debugfs.mount
mount -t tracefs tracefs /sys/kernel/tracing 2>/dev/null || true
mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null || true
# ── 9. Build ja4ebpf depuis les sources ──────────────────────────────────────
log "Build initial de ja4ebpf..."
export PATH="/usr/local/go/bin:$PATH"
cd /ja4-platform/services/ja4ebpf
GOWORK=off go generate ./internal/loader/ 2>&1 | tail -5 || log "go generate: erreur (normal si vmlinux.h absent)"
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o /usr/local/bin/ja4ebpf ./cmd/ja4ebpf/ 2>&1 | tail -5
log "Provisionnement terminé !"
log "Lancer 'make test-vm-nginx' depuis le host pour démarrer les tests."