Files
ja4-platform/tests/integration/apache/platform/Dockerfile
toto f85a10b012 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>
2026-04-12 02:37:00 +02:00

70 lines
2.5 KiB
Docker

# =============================================================================
# Platform apache — Multi-distro (Rocky Linux 9 par défaut)
#
# Architecture :
# traffic-gen ─HTTPS→ Apache HTTPD (TLS, HTTP/2) → ClickHouse
# ↑
# ja4ebpf (uprobe httpd/libssl + hook TC ingress)
#
# ja4ebpf attache ses uprobes sur /usr/sbin/httpd qui lie OpenSSL.
# Le hook TC ingress capture TCP SYN + TLS ClientHello sur eth0.
# =============================================================================
# ARG global : doit être déclaré avant tous les FROM
ARG BASE_IMAGE=rockylinux:9
# ── 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* ./
COPY services/ja4ebpf/go.mod services/ja4ebpf/go.sum* ./services/ja4ebpf/
RUN cd services/ja4ebpf && go mod download 2>/dev/null; true
COPY services/ja4ebpf/ ./services/ja4ebpf/
WORKDIR /build/services/ja4ebpf
RUN GOWORK=off go generate ./internal/loader/ && \
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o /out/ja4ebpf ./cmd/ja4ebpf/
# ── Stage 2 : runtime Apache HTTPD + ja4ebpf ─────────────────────────────────
FROM ${BASE_IMAGE}
RUN dnf install -y epel-release 2>/dev/null; \
dnf install -y --allowerasing procps-ng httpd mod_ssl mod_http2 openssl curl && \
dnf clean all
COPY --from=go-builder /out/ja4ebpf /usr/local/bin/ja4ebpf
# Certificat TLS auto-signé pour Apache
RUN openssl req -x509 -nodes -days 365 \
-subj "/CN=platform.test" \
-newkey rsa:2048 \
-keyout /etc/pki/tls/private/apache.key \
-out /etc/pki/tls/certs/apache.crt && \
mkdir -p /var/www/html /var/log/httpd && \
echo '{"status":"ok","stack":"apache"}' > /var/www/html/health
COPY tests/integration/apache/platform/httpd-ssl.conf /etc/httpd/conf.d/ssl.conf
COPY tests/integration/apache/platform/ja4ebpf.yml /etc/ja4ebpf/config.yml
COPY tests/integration/apache/platform/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 80 443
CMD ["/entrypoint.sh"]