diff --git a/api/types.go b/api/types.go index 9f0e385..4da76a6 100644 --- a/api/types.go +++ b/api/types.go @@ -232,3 +232,31 @@ func NewLogRecord(ch TLSClientHello, fp *Fingerprints) LogRecord { return rec } + +// Default values and constants + +const ( + DefaultInterface = "eth0" + DefaultPort = 443 + DefaultBPFFilter = "" + DefaultFlowTimeout = 30 // seconds + DefaultPacketBuffer = 1000 // packet channel buffer size +) + +// DefaultConfig returns an AppConfig with sensible default values. +// Uses eth0 as the default interface, port 443 for monitoring, +// no BPF filter, a 30-second flow timeout, and a 1000-packet +// channel buffer. Returns an empty outputs slice (caller must +// configure outputs explicitly). +func DefaultConfig() AppConfig { + return AppConfig{ + Core: Config{ + Interface: DefaultInterface, + ListenPorts: []uint16{DefaultPort}, + BPFFilter: DefaultBPFFilter, + FlowTimeoutSec: DefaultFlowTimeout, + PacketBufferSize: DefaultPacketBuffer, + }, + Outputs: []OutputConfig{}, + } +} diff --git a/architecture.yml b/architecture.yml index 20656d1..14b11ca 100644 --- a/architecture.yml +++ b/architecture.yml @@ -578,24 +578,22 @@ dev_tools: packaging: description: > ja4sentinel est distribué sous forme de packages .rpm (Rocky Linux/RHEL/CentOS/AlmaLinux), - construits intégralement dans Docker avec fpm. Le binaire est compilé sur Rocky Linux 9 + construits intégralement dans Docker avec rpmbuild. Le binaire est compilé sur Rocky Linux 9 pour une compatibilité binaire maximale avec toutes les distributions RHEL-based. formats: - rpm target_distros: rpm: - - centos-7 - rocky-linux-8+ - rocky-linux-9+ - rocky-linux-10+ - almalinux-8+ - almalinux-9+ - almalinux-10+ - - rhel-7+ - rhel-8+ - rhel-9+ - rhel-10+ - tool: fpm + tool: rpmbuild build_pipeline: dockerfile: Dockerfile.package stages: @@ -606,14 +604,15 @@ packaging: Le binaire est dynamiquement lié à libpcap pour une compatibilité maximale. - name: rpm_builder description: > - Image Rocky Linux 9 avec fpm, rpm-build, ruby. Création de l'arborescence - et exécution de fpm pour générer les RPM pour el7, el8, el9, el10. + Image Rocky Linux 9 avec rpm-build. Setup de l'arborescence rpmbuild + (BUILD, RPMS, SOURCES, SPECS, SRPMS). Copie du spec et des sources, + puis build avec rpmbuild -bb pour el8, el9, el10. - name: output description: > - Image Alpine minimale contenant les packages RPM dans /packages/rpm/el{7,8,9,10}. + Image Alpine minimale contenant les packages RPM dans /packages/rpm/el{8,9,10}. files: binary: - source: dist/ja4sentinel-linux-amd64 + source: dist/ja4sentinel dest: /usr/bin/ja4sentinel mode: "0755" systemd: @@ -637,15 +636,20 @@ packaging: mode: "0750" - path: /etc/ja4sentinel mode: "0750" - maintainer_scripts: - rpm: - postinst: packaging/rpm/postinst - prerm: packaging/rpm/prerm - postrm: packaging/rpm/postrm + spec_file: + path: packaging/rpm/ja4sentinel.spec + version_macro: "%{?build_version}%{!?build_version:1.0.0}" + scripts: + pre: > + Script %pre intégré dans le spec - ne crée plus d'utilisateur + car le service tourne en root pour la capture réseau. + post: > + Script %post intégré dans le spec - configure les permissions + root:root sur les directories et active le service systemd. dependencies: rpm: - systemd - - libpcap >= 1.4.0 + - libpcap >= 1.9.0 verify: rpm: command: docker run --rm -v $(pwd)/build/rpm:/packages rockylinux:9 sh -c "dnf install -y /packages/*.rpm" @@ -656,16 +660,18 @@ service: description: "JA4 client fingerprinting daemon" wanted_by: "multi-user.target" exec: - binary_path: "/usr/local/bin/ja4sentinel" + binary_path: "/usr/bin/ja4sentinel" args: - "--config" - "/etc/ja4sentinel/config.yml" user_group: - user: "ja4sentinel" - group: "ja4sentinel" + user: "root" + group: "root" + note: > + Le service tourne en root pour la capture réseau (CAP_NET_RAW, CAP_NET_ADMIN). + La création d'utilisateur ja4sentinel a été supprimée. runtime: working_directory: "/var/lib/ja4sentinel" - pid_file: "/run/ja4sentinel.pid" restart: "on-failure" restart_sec: 5 environment_prefix: "JA4SENTINEL_" @@ -680,16 +686,22 @@ service: - "CAP_NET_RAW" - "CAP_NET_ADMIN" sandboxing: - - "NoNewPrivileges=yes" - - "ProtectSystem=full" - - "ProtectHome=true" - - "PrivateTmp=true" + - "ProtectSystem=strict" + - "ProtectHome=yes" + - "PrivateTmp=yes" + - "ProtectKernelTunables=yes" + - "ProtectKernelModules=yes" + - "ProtectControlGroups=yes" + - "RestrictRealtime=yes" + - "RestrictSUIDSGID=yes" + - "LockPersonality=yes" + - "ReadWritePaths=/var/lib/ja4sentinel /var/log/ja4sentinel" integration_rules: - - "Le binaire doit s’arrêter proprement sur SIGTERM (systemd stop)." + - "Le binaire doit s'arrêter proprement sur SIGTERM (systemd stop)." - "Le module cmd_ja4sentinel gère les signaux et termine la capture proprement." - "Les chemins (config, socket UNIX, logs) doivent être compatibles avec FHS (/etc, /var/run, /var/log)." - "Le module cmd_ja4sentinel capture SIGTERM/SIGINT et déclenche un arrêt propre (stop capture, flush outputs, fermer socket UNIX)." - - "Le processus doit retourner un code de sortie non nul en cas d’erreur fatale au démarrage." + - "Le processus doit retourner un code de sortie non nul en cas d'erreur fatale au démarrage." logging: strategy: