Make the `YARA` scanner asynchronous to avoid blocking the event loop
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with the YARA scanner's Scan() method, the inline eligibility and setup logic it contains, and the rwxs and mmaps maps, which will need a mutex. Also read Close(), where the drain must happen before the compiler is destroyed, and the config struct that will gain AsyncQueueSize and MaxWorkers. This is concurrency design work touching ETW event handling, so get maintainer agreement on the approach before writing code. Done means Scan() returns (false, nil) without blocking, drops are counted in yara.dropped.scans, and Close() waits for in-flight scans.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Motivation
The YARA scanner currently runs Scan() synchronously on the caller's goroutine, which means every scan, including the underlying libyara call executes inline on the ETW event processing path. This couples scan latency directly to event throughput: a slow or backed-up scan stalls the event loop rather than just delaying the scan result, which is a problem under high event volume or when scanning larger payloads (e.g. ADS reads).
Expectation
Scanning should no longer block event processing.
Scan()returns immediately after enqueuing the work; scan results reach consumers only through the existing alert-sender pipeline- Under load, once the pending-scan queue is full, new scan requests are dropped (not blocked), and the drop is observable via a metric
- The number of concurrent scan workers is bounded and configurable
- A
Wait()/Flush()mechanism allows draining in-flight scans deterministically (used by tests, and by shutdown)
Proposal
- Introduce a bounded queue (buffered, size controlled by a new AsyncQueueSize config option, default 1024).
Scan()does a non-blocking send. A full channel drops the event and increments ayara.dropped.scansmetric - Add a semaphore (
sem chan struct{}, capacity MaxWorkers, default 32, also configurable), gating how many scan goroutines run concurrently; a single dispatch() goroutine acquires a slot before launching each worker - Track every launched goroutine with a drainWg sync.WaitGroup so Close() can drain all in-flight work before destroying the YARA compiler, avoiding calls into libyara after
Destroy() - Extract the eligibility/setup logic currently inline in
Scan()into a function that runs synchronously on the caller's goroutine (fast path); only the actual yara.Scanner invocation moves into the worker pool. This includes making the ADSsys.ReadFileread synchronous (capped at 1MB with a 1s timeout) so scan bytes are captured before the event may be recycled - Protect the
rwxs/mmapsmaps with a mutex, since worker goroutines now write to them concurrently - Update the
Scan()interface contract: it currently returns (bool, error) with the bool indicating a match, which is incompatible with async execution. It should always return (false, nil), with match results delivered exclusively via the alert-sender pipeline - Add new config fields for
AsyncQueueSizeandMaxWorkers
Here is the proposed architecture diagram:
- Lenguaje dominante
- Go
- Estrellas
- 2.6k
- Forks
- 222
- Merge medio
- 16 h 23 min
- PR fusionados (30 d)
- 11
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rabbitstack/fibratus
-
Service crashes on Windows Server 2016: "panic: sub-authority index out of range" in RidToStringAbiertotype: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
rabbitstack/fibratus#761 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CI: the test job has been red since September, and TestFsProcessor looks like a real mmap regressionAbiertoci
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
rabbitstack/fibratus#754 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
ci rules type: enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
rabbitstack/fibratus#715 ·
Los mantenedores suelen responder en 1 día
-
scope: hardering type: enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
rabbitstack/fibratus#713 ·
Los mantenedores suelen responder en 1 día
-
Add `WMI` activity telemetryAbiertoneeds: config scope: events/telemetry type: feature
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
rabbitstack/fibratus#710 ·
Los mantenedores suelen responder en 1 día
Todos los issues de rabbitstack/fibratus
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
unbound-force/replicator#193 ·
Los mantenedores suelen responder en 2 días
-
A Gemini stream that fails partway completes the call with the partial textPosiblemente ocupada @bnaylor la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
go-steer/core-agent#1600 ·
Los mantenedores suelen responder en 1 día
-
bug raised-by:reviewer
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
medici-finance/assay#7655 ·
Los mantenedores suelen responder en 1 día
-
Add /exit and /quit commandsAbiertoenhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Edwin-metcalf/MetCode#67 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día