Make the `YARA` scanner asynchronous to avoid blocking the event loop
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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:
- Langage dominant
- Go
- Étoiles
- 2.6k
- Forks
- 222
- Merge moyen
- 16 h 23 min
- PR mergées (30 j)
- 11
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rabbitstack/fibratus
-
Service crashes on Windows Server 2016: "panic: sub-authority index out of range" in RidToStringOuvertetype: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
rabbitstack/fibratus#761 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
CI: the test job has been red since September, and TestFsProcessor looks like a real mmap regressionOuverteci
Difficulté 4/5 3-5 jours Accessibilité débutants 22/100
rabbitstack/fibratus#754 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
ci rules type: enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
rabbitstack/fibratus#715 ·
Les mainteneurs répondent en général sous 1 jour
-
scope: hardering type: enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
rabbitstack/fibratus#713 ·
Les mainteneurs répondent en général sous 1 jour
-
Add `WMI` activity telemetryOuverteneeds: config scope: events/telemetry type: feature
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
rabbitstack/fibratus#710 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rabbitstack/fibratus
Issues similaires
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 72/100
hiero-ledger/hiero-sdk-go#1911 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 4 jours
-
[Bugs] AMF `ParseGMM()` panic — `RejectedNSSAI.UnmarshalBinary` reads out of boundsPeut-être pris @PerryLink l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
ccfos/nightingale#3514 ·
Les mainteneurs répondent en général sous 1 jour
-
[bug] Explorer trims leading spaces on file namesPeut-être pris @unshade l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
mickael-kerjean/filestash#1033 · 1 commentaire ·