fix(api): restore DefaultConfig() and constants used by config loader
Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled
Some checks failed
Build RPM Package / Build RPM Packages (CentOS 7, Rocky 8/9/10) (push) Has been cancelled
- Restore api.DefaultConfig() - used by internal/config/loader.go - Restore DefaultInterface, DefaultPort, DefaultBPFFilter constants - Restore DefaultFlowTimeout, DefaultPacketBuffer constants - Remove unused LogLevel* constants (never referenced in codebase) docs(architecture.yml): update packaging and service sections - Update packaging tool from fpm to rpmbuild - Remove CentOS 7 / RHEL 7 from target distros (EOL) - Update rpm_builder stage description for rpmbuild workflow - Add spec_file section with version_macro documentation - Update service to run as root (required for packet capture) - Update security sandboxing to match current systemd unit - Remove pid_file (not used) - Update binary_path from /usr/local/bin to /usr/bin Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
28
api/types.go
28
api/types.go
@ -232,3 +232,31 @@ func NewLogRecord(ch TLSClientHello, fp *Fingerprints) LogRecord {
|
|||||||
|
|
||||||
return rec
|
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{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -578,24 +578,22 @@ dev_tools:
|
|||||||
packaging:
|
packaging:
|
||||||
description: >
|
description: >
|
||||||
ja4sentinel est distribué sous forme de packages .rpm (Rocky Linux/RHEL/CentOS/AlmaLinux),
|
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.
|
pour une compatibilité binaire maximale avec toutes les distributions RHEL-based.
|
||||||
formats:
|
formats:
|
||||||
- rpm
|
- rpm
|
||||||
target_distros:
|
target_distros:
|
||||||
rpm:
|
rpm:
|
||||||
- centos-7
|
|
||||||
- rocky-linux-8+
|
- rocky-linux-8+
|
||||||
- rocky-linux-9+
|
- rocky-linux-9+
|
||||||
- rocky-linux-10+
|
- rocky-linux-10+
|
||||||
- almalinux-8+
|
- almalinux-8+
|
||||||
- almalinux-9+
|
- almalinux-9+
|
||||||
- almalinux-10+
|
- almalinux-10+
|
||||||
- rhel-7+
|
|
||||||
- rhel-8+
|
- rhel-8+
|
||||||
- rhel-9+
|
- rhel-9+
|
||||||
- rhel-10+
|
- rhel-10+
|
||||||
tool: fpm
|
tool: rpmbuild
|
||||||
build_pipeline:
|
build_pipeline:
|
||||||
dockerfile: Dockerfile.package
|
dockerfile: Dockerfile.package
|
||||||
stages:
|
stages:
|
||||||
@ -606,14 +604,15 @@ packaging:
|
|||||||
Le binaire est dynamiquement lié à libpcap pour une compatibilité maximale.
|
Le binaire est dynamiquement lié à libpcap pour une compatibilité maximale.
|
||||||
- name: rpm_builder
|
- name: rpm_builder
|
||||||
description: >
|
description: >
|
||||||
Image Rocky Linux 9 avec fpm, rpm-build, ruby. Création de l'arborescence
|
Image Rocky Linux 9 avec rpm-build. Setup de l'arborescence rpmbuild
|
||||||
et exécution de fpm pour générer les RPM pour el7, el8, el9, el10.
|
(BUILD, RPMS, SOURCES, SPECS, SRPMS). Copie du spec et des sources,
|
||||||
|
puis build avec rpmbuild -bb pour el8, el9, el10.
|
||||||
- name: output
|
- name: output
|
||||||
description: >
|
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:
|
files:
|
||||||
binary:
|
binary:
|
||||||
source: dist/ja4sentinel-linux-amd64
|
source: dist/ja4sentinel
|
||||||
dest: /usr/bin/ja4sentinel
|
dest: /usr/bin/ja4sentinel
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
systemd:
|
systemd:
|
||||||
@ -637,15 +636,20 @@ packaging:
|
|||||||
mode: "0750"
|
mode: "0750"
|
||||||
- path: /etc/ja4sentinel
|
- path: /etc/ja4sentinel
|
||||||
mode: "0750"
|
mode: "0750"
|
||||||
maintainer_scripts:
|
spec_file:
|
||||||
rpm:
|
path: packaging/rpm/ja4sentinel.spec
|
||||||
postinst: packaging/rpm/postinst
|
version_macro: "%{?build_version}%{!?build_version:1.0.0}"
|
||||||
prerm: packaging/rpm/prerm
|
scripts:
|
||||||
postrm: packaging/rpm/postrm
|
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:
|
dependencies:
|
||||||
rpm:
|
rpm:
|
||||||
- systemd
|
- systemd
|
||||||
- libpcap >= 1.4.0
|
- libpcap >= 1.9.0
|
||||||
verify:
|
verify:
|
||||||
rpm:
|
rpm:
|
||||||
command: docker run --rm -v $(pwd)/build/rpm:/packages rockylinux:9 sh -c "dnf install -y /packages/*.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"
|
description: "JA4 client fingerprinting daemon"
|
||||||
wanted_by: "multi-user.target"
|
wanted_by: "multi-user.target"
|
||||||
exec:
|
exec:
|
||||||
binary_path: "/usr/local/bin/ja4sentinel"
|
binary_path: "/usr/bin/ja4sentinel"
|
||||||
args:
|
args:
|
||||||
- "--config"
|
- "--config"
|
||||||
- "/etc/ja4sentinel/config.yml"
|
- "/etc/ja4sentinel/config.yml"
|
||||||
user_group:
|
user_group:
|
||||||
user: "ja4sentinel"
|
user: "root"
|
||||||
group: "ja4sentinel"
|
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:
|
runtime:
|
||||||
working_directory: "/var/lib/ja4sentinel"
|
working_directory: "/var/lib/ja4sentinel"
|
||||||
pid_file: "/run/ja4sentinel.pid"
|
|
||||||
restart: "on-failure"
|
restart: "on-failure"
|
||||||
restart_sec: 5
|
restart_sec: 5
|
||||||
environment_prefix: "JA4SENTINEL_"
|
environment_prefix: "JA4SENTINEL_"
|
||||||
@ -680,16 +686,22 @@ service:
|
|||||||
- "CAP_NET_RAW"
|
- "CAP_NET_RAW"
|
||||||
- "CAP_NET_ADMIN"
|
- "CAP_NET_ADMIN"
|
||||||
sandboxing:
|
sandboxing:
|
||||||
- "NoNewPrivileges=yes"
|
- "ProtectSystem=strict"
|
||||||
- "ProtectSystem=full"
|
- "ProtectHome=yes"
|
||||||
- "ProtectHome=true"
|
- "PrivateTmp=yes"
|
||||||
- "PrivateTmp=true"
|
- "ProtectKernelTunables=yes"
|
||||||
|
- "ProtectKernelModules=yes"
|
||||||
|
- "ProtectControlGroups=yes"
|
||||||
|
- "RestrictRealtime=yes"
|
||||||
|
- "RestrictSUIDSGID=yes"
|
||||||
|
- "LockPersonality=yes"
|
||||||
|
- "ReadWritePaths=/var/lib/ja4sentinel /var/log/ja4sentinel"
|
||||||
integration_rules:
|
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."
|
- "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)."
|
- "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 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:
|
logging:
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
Reference in New Issue
Block a user