From a8d70adad8e53437ffe90c24b531b5afdb54e685 Mon Sep 17 00:00:00 2001 From: SherlockOmss <209794074+SherlockOmss@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:01:55 +0100 Subject: [PATCH 1/2] docs: document yara and small crates' fields and variants (Refs #362) Removes the #[allow(missing_docs)] // #362 markers from yara, inventory, response, sinks, tamper, transport, updater and verdict. Comments only. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: SherlockOmss <209794074+SherlockOmss@users.noreply.github.com> --- crates/inventory/src/lib.rs | 9 ++- crates/response/src/kill.rs | 25 ++++++-- crates/response/src/quarantine.rs | 16 ++++- crates/sinks/src/lib.rs | 4 +- crates/tamper/src/integrity.rs | 16 +++-- crates/transport/src/detection_upload.rs | 3 +- crates/transport/src/error.rs | 13 +++- crates/updater/src/content.rs | 2 +- crates/updater/src/error.rs | 82 ++++++++++++++++++++---- crates/verdict/src/lib.rs | 8 ++- crates/yara/src/access.rs | 3 +- crates/yara/src/lib.rs | 25 ++++++-- crates/yara/src/memory.rs | 15 +++-- crates/yara/src/queue.rs | 7 +- 14 files changed, 181 insertions(+), 47 deletions(-) diff --git a/crates/inventory/src/lib.rs b/crates/inventory/src/lib.rs index 81482fd5..d0ac49fc 100644 --- a/crates/inventory/src/lib.rs +++ b/crates/inventory/src/lib.rs @@ -36,21 +36,26 @@ pub type PackageSnapshot = BTreeMap; /// What happened to one package between two snapshots. #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub enum PackageChangeKind { + /// The package is in the new snapshot but not in the old one. Added, + /// The package was in the old snapshot and is gone from the new one. Removed, + /// The package is in both snapshots with a different version. Upgraded, } /// One package's change between two snapshots, enough to build the /// `schema::PackageChangeEvent` the agent emits for it. #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub struct PackageChange { + /// Package name, the key of the [`PackageSnapshot`] entry. pub package: String, + /// Whether the package was added, removed or upgraded. pub kind: PackageChangeKind, + /// Version in the old snapshot; `None` for an added package. pub previous_version: Option, + /// Version in the new snapshot; `None` for a removed package. pub version: Option, } diff --git a/crates/response/src/kill.rs b/crates/response/src/kill.rs index a0c3e43e..9c612bc1 100644 --- a/crates/response/src/kill.rs +++ b/crates/response/src/kill.rs @@ -14,21 +14,36 @@ use policy::ResponsePolicy; /// #25's "policy off = observe-only" acceptance criterion: observing is not a /// different code path from acting, just a different variant of the same result). #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub enum KillOutcome { /// The process was signaled; `terminate` reported success. - Killed { pid: u32 }, + Killed { + /// Process id that was signaled. + pid: u32, + }, /// `policy.kill_enabled` was false — no signal was sent. - ObserveOnly { pid: u32 }, + ObserveOnly { + /// Process id that would have been signaled. + pid: u32, + }, /// `policy.kill_enabled` was true, but `terminate` failed (already exited, /// permission denied, ...). `error` is `terminate`'s error rendered to a string, /// not a structured type — this crate has no opinion on the caller's OS error type. - Failed { pid: u32, error: String }, + Failed { + /// Process id `terminate` was called on. + pid: u32, + /// `terminate`'s error, rendered to a string. + error: String, + }, /// The pid is one this crate never signals, whatever the policy says (see /// [`protected_reason`]). Reported instead of [`KillOutcome::ObserveOnly`] /// even with kill disabled, so the audit line says the truth: it would not /// have been killed, rather than that it would have. - Refused { pid: u32, reason: &'static str }, + Refused { + /// The protected process id that was not signaled. + pid: u32, + /// Why the pid is protected, as returned by [`protected_reason`]. + reason: &'static str, + }, } /// Why `pid` must never be handed to `terminate`, or `None` when it may be. diff --git a/crates/response/src/quarantine.rs b/crates/response/src/quarantine.rs index c8d3efb8..41c10db0 100644 --- a/crates/response/src/quarantine.rs +++ b/crates/response/src/quarantine.rs @@ -58,20 +58,30 @@ use policy::ResponsePolicy; /// this is one enum covering both the acted and observe-only cases rather than two /// separate code paths. #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub enum QuarantineOutcome { /// `path` was moved into `quarantine_dir` under a digest-based name. Identical /// payloads use a numeric suffix so each original path has its own record. Quarantined { + /// The path the file had before it was moved. original: PathBuf, + /// Where the file now lives inside `quarantine_dir`. quarantined_at: PathBuf, + /// Lowercase hex SHA-256 of the quarantined content. sha256_hex: String, }, /// `policy.quarantine_enabled` was false — `path` was left untouched. - ObserveOnly { path: PathBuf }, + ObserveOnly { + /// The path that would have been quarantined. + path: PathBuf, + }, /// Policy allowed it, but hashing or the move failed (already gone, permission /// denied, ...). `error` is the underlying `io::Error` rendered to a string. - Failed { path: PathBuf, error: String }, + Failed { + /// The path whose quarantine failed. + path: PathBuf, + /// The underlying `io::Error`, rendered to a string. + error: String, + }, } /// Policy-gates quarantining `path` into `quarantine_dir` (created if missing). diff --git a/crates/sinks/src/lib.rs b/crates/sinks/src/lib.rs index b4fc2239..47470985 100644 --- a/crates/sinks/src/lib.rs +++ b/crates/sinks/src/lib.rs @@ -116,10 +116,12 @@ fn needs_tail_repair(path: &Path) -> bool { /// on-disk record stays a sink concern: the agent converts whatever its detection /// engines emit into this record. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[allow(missing_docs)] // #362 pub struct AlertRecord { + /// Time of the detection, in nanoseconds. pub timestamp_ns: u64, + /// ATT&CK technique the detection maps to. pub technique: String, + /// Human-readable description of what was detected. pub message: String, } diff --git a/crates/tamper/src/integrity.rs b/crates/tamper/src/integrity.rs index 6d38c853..8ae8ef17 100644 --- a/crates/tamper/src/integrity.rs +++ b/crates/tamper/src/integrity.rs @@ -102,25 +102,33 @@ impl Manifest { /// What is wrong with one protected path (each variant is one failed check). #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub enum ViolationKind { /// The file exists and was hashed, but the hash does not match the manifest — /// the artifact was replaced or edited. - Modified { expected: String, actual: String }, + Modified { + /// Hash the manifest records for the path. + expected: String, + /// Hash computed from the file on disk. + actual: String, + }, /// The protected path is gone — an uninstall or a move as a prelude to a swap. Missing, /// The path exists but could not be read as a regular file (a FIFO/device /// planted at the path, a permissions change, an I/O error). Unreadable, /// The file grew past [`MAX_VERIFY_BYTES`] — suspicious in its own right. - Oversized { size: u64 }, + Oversized { + /// Size of the file in bytes. + size: u64, + }, } /// One protected path that failed verification. #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub struct IntegrityViolation { + /// The protected path that failed its check. pub path: PathBuf, + /// Which check failed. pub kind: ViolationKind, } diff --git a/crates/transport/src/detection_upload.rs b/crates/transport/src/detection_upload.rs index f1871dee..6c603f6e 100644 --- a/crates/transport/src/detection_upload.rs +++ b/crates/transport/src/detection_upload.rs @@ -29,9 +29,10 @@ const SERVER_INVALID_PAYLOAD: &str = "Invalid payload"; /// The retry identity is persisted in the same spool record as its detection. /// Reopening an in-flight segment therefore reuses the exact same key. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[allow(missing_docs)] // #362 pub struct QueuedDetection { + /// Idempotency key sent with every attempt, so a retry is recognised as the same upload. pub key: String, + /// The detection to upload. pub detection: Detection, } diff --git a/crates/transport/src/error.rs b/crates/transport/src/error.rs index b4a90b70..c7732ef2 100644 --- a/crates/transport/src/error.rs +++ b/crates/transport/src/error.rs @@ -7,11 +7,15 @@ pub type Result = std::result::Result; /// Errors that can occur during transport operations. #[derive(Debug, Error)] -#[allow(missing_docs)] // #362 pub enum TransportError { /// Server returned an error status code. #[error("server error: {status} - {message}")] - ServerError { status: u16, message: String }, + ServerError { + /// HTTP status code of the response. + status: u16, + /// The server's error message, or the response body when it gave none. + message: String, + }, /// Network error (connection refused, timeout, etc.). #[error("network error: {0}")] @@ -46,7 +50,10 @@ pub enum TransportError { /// lost silently: the segment is not acknowledged, so the next drain delivers it again, and /// only the attempt budget skips it, with a warning that counts what was dropped. #[error("{count} event(s) cannot be sent under the body limit")] - Unsendable { count: usize }, + Unsendable { + /// How many events of the segment could not be shortened. + count: usize, + }, /// Server is unreachable (for graceful degradation). #[error("server unreachable")] diff --git a/crates/updater/src/content.rs b/crates/updater/src/content.rs index bb3c0d2e..49838537 100644 --- a/crates/updater/src/content.rs +++ b/crates/updater/src/content.rs @@ -141,8 +141,8 @@ impl ContentEntry { /// Field order is alphabetical and fixed by declaration — canonicalization /// relies on it, exactly like [`crate::manifest::ReleaseManifest`]. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[allow(missing_docs)] // #362 pub struct ContentManifest { + /// The content files this release lists, each with its path and hash. pub entries: Vec, /// Monotone, strictly increasing per `ring`. See [`Self::check_release_version`]. pub release_version: u64, diff --git a/crates/updater/src/error.rs b/crates/updater/src/error.rs index ef6866f9..26b5e419 100644 --- a/crates/updater/src/error.rs +++ b/crates/updater/src/error.rs @@ -8,12 +8,16 @@ use thiserror::Error; /// Everything that can go wrong staging, verifying, or promoting a release. #[derive(Debug, Error)] -#[allow(missing_docs)] // #362 pub enum UpdaterError { /// The manifest's `schema_version` is not one this build understands /// (ADR-0015 Decision 2: readers reject an unknown value outright). #[error("manifest schema_version {found} is not supported (expected {expected})")] - SchemaVersionUnsupported { found: u32, expected: u32 }, + SchemaVersionUnsupported { + /// The `schema_version` the manifest carries. + found: u32, + /// The `schema_version` this build understands. + expected: u32, + }, /// The manifest's Ed25519 signature does not verify against the embedded /// public key. @@ -28,14 +32,22 @@ pub enum UpdaterError { /// `release_version` is not strictly greater than the currently installed /// one (ADR-0015 Decision 2: anti-rollback-attack check). #[error("release {offered} is not newer than the installed release {current}")] - ReleaseNotNewer { offered: u64, current: u64 }, + ReleaseNotNewer { + /// The `release_version` the manifest offers. + offered: u64, + /// The `release_version` currently installed. + current: u64, + }, /// A content manifest lists nothing while the agent has applied content: applying it /// would delete every recorded file and leave the agent with no rules. A release that /// really withdraws everything must be a deliberate, separate decision; an empty or /// mis-globbed build must not be able to do it by accident. #[error("the manifest lists no content but {would_remove} applied file(s) would be removed")] - EmptyContentManifest { would_remove: usize }, + EmptyContentManifest { + /// How many applied files the empty manifest would remove. + would_remove: usize, + }, /// A content manifest's `ring` does not match the ring the caller actually /// requested. A valid signature only proves "we signed this manifest", not @@ -43,7 +55,12 @@ pub enum UpdaterError { /// correctly-signed manifest for a different (e.g. less-vetted canary) ring /// would still verify and be accepted. #[error("manifest is for ring `{found}`, expected `{requested}`")] - RingMismatch { requested: String, found: String }, + RingMismatch { + /// The ring the caller asked for. + requested: String, + /// The ring the manifest declares. + found: String, + }, /// `release_version` is on the local ban list — a previous install of this /// exact release failed its health check (ADR-0015 Decision 6). @@ -65,29 +82,48 @@ pub enum UpdaterError { /// A file the manifest lists is missing from the staged release directory. #[error("staged release is missing manifest entry `{path}`")] - StagedFileMissing { path: PathBuf }, + StagedFileMissing { + /// The manifest entry path that has no file in the staged directory. + path: PathBuf, + }, /// A staged file's content does not match the manifest's recorded hash. #[error("staged file `{path}` hash mismatch (expected {expected}, found {actual})")] StagedFileMismatch { + /// The staged file whose hash differs. path: PathBuf, + /// The hash the manifest records. expected: String, + /// The hash computed from the staged file. actual: String, }, /// A snapshot manifest's `kind` is not one this build knows (ADR-0033: only `common-set`). #[error("snapshot manifest kind `{found}` is not supported")] - SnapshotKindUnsupported { found: String }, + SnapshotKindUnsupported { + /// The `kind` the snapshot manifest declares. + found: String, + }, /// A snapshot manifest's `built_at` is not later than the snapshot in force: a replay or a /// rollback of the server's own state. The snapshot in force stays (ADR-0033 decision 3). #[error("snapshot built at {offered} is not newer than the one in force ({current})")] - SnapshotNotNewer { offered: u64, current: u64 }, + SnapshotNotNewer { + /// The `built_at` of the offered snapshot. + offered: u64, + /// The `built_at` of the snapshot in force. + current: u64, + }, /// A snapshot manifest claims to be built further in the future than the clock-skew /// tolerance allows: a wrong server clock, or a manifest made to outlive its maximum age. #[error("snapshot built at {built_at} is dated beyond now ({now}) plus the tolerance")] - SnapshotFromFuture { built_at: u64, now: u64 }, + SnapshotFromFuture { + /// The `built_at` the manifest claims. + built_at: u64, + /// The local clock reading it was compared with. + now: u64, + }, /// The artifact does not match the signed manifest that names it (size, hash, or a header /// that disagrees with the manifest). @@ -105,17 +141,30 @@ pub enum UpdaterError { #[error( "key-rotation manifest does not apply: it retires a {role} key this install does not trust" )] - RotationDoesNotApply { role: &'static str }, + RotationDoesNotApply { + /// The key role (`release` or `content`) the manifest tried to retire a key for. + role: &'static str, + }, /// A key-rotation manifest is past its `expires_at`. #[error("key-rotation manifest expired at {expires_at} (now {now})")] - RotationExpired { expires_at: u64, now: u64 }, + RotationExpired { + /// The manifest's `expires_at`. + expires_at: u64, + /// The local clock reading it was compared with. + now: u64, + }, /// A key-rotation manifest is dated beyond now plus the clock-skew tolerance. #[error( "key-rotation manifest issued at {issued_at} is dated beyond now ({now}) plus the tolerance" )] - RotationNotYetValid { issued_at: u64, now: u64 }, + RotationNotYetValid { + /// The manifest's `issued_at`. + issued_at: u64, + /// The local clock reading it was compared with. + now: u64, + }, /// The file that records the applied key rotations exists but cannot be trusted: it does not /// parse, one of its rotations does not verify under the embedded `recovery` key, they are not @@ -123,7 +172,10 @@ pub enum UpdaterError { /// Refused rather than ignored: a file that exists proves a rotation happened, and falling /// back to the embedded keys could re-trust a key that was rotated away from. #[error("the key-rotation record is not trustworthy: {reason}")] - TrustStateCorrupt { reason: String }, + TrustStateCorrupt { + /// Which of the checks on the record failed. + reason: String, + }, /// The install already holds [`crate::trust_state::MAX_ROTATIONS`] rotations. #[error("this install already holds the maximum of {0} recorded key rotations")] @@ -133,7 +185,9 @@ pub enum UpdaterError { /// specifics (missing permissions, disk full, etc). #[error("I/O error on {path}: {source}")] Io { + /// The file or directory the operation was on. path: PathBuf, + /// The underlying I/O error. #[source] source: std::io::Error, }, @@ -143,7 +197,9 @@ pub enum UpdaterError { /// never expected from this crate's own [`crate::layout::Layout::persist_manifest`]. #[error("manifest at {path} is corrupt: {source}")] ManifestCorrupt { + /// The persisted manifest file. path: PathBuf, + /// The JSON error from parsing it. #[source] source: serde_json::Error, }, diff --git a/crates/verdict/src/lib.rs b/crates/verdict/src/lib.rs index 230aa20d..a7c3ea5b 100644 --- a/crates/verdict/src/lib.rs +++ b/crates/verdict/src/lib.rs @@ -42,10 +42,13 @@ use store::BoundedMap; /// with the same rule as the rest of the stack: two known, different stamps are two /// incarnations, and a `None` on either side cannot disprove identity. #[derive(Debug, Clone, PartialEq, Eq, Hash)] -#[allow(missing_docs)] // #362 pub struct EntityKey { + /// Parent process id of the process the findings are about. pub ppid: u32, + /// Command name (`comm`) of the process. pub comm: String, + /// Incarnation stamp of the parent `ppid`, when the sensor gave one; tells a recycled + /// parent pid apart from the original. pub parent_generation: Option, } @@ -131,9 +134,10 @@ impl EntityState { /// technique, source and (bounded) piece of evidence folded into this entity /// so far. #[derive(Debug, Clone, PartialEq)] -#[allow(missing_docs)] // #362 pub struct Verdict { + /// The entity this snapshot is about. pub entity: EntityKey, + /// The highest severity among the folded findings. pub severity: Severity, /// The highest-confidence score seen across every contributing source, when /// any source carried one. Simple max composition, not a weighted blend: a diff --git a/crates/yara/src/access.rs b/crates/yara/src/access.rs index 61daf243..70bee03f 100644 --- a/crates/yara/src/access.rs +++ b/crates/yara/src/access.rs @@ -19,9 +19,10 @@ use std::{fs::File, io, path::Path}; /// The user behind a scan request, as the sensor saw them. #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub struct Requester { + /// Numeric user id of the requesting process; 0 (root) is never restricted. pub uid: u32, + /// Numeric primary group id of the requesting process, matched against the file's group. pub gid: u32, } diff --git a/crates/yara/src/lib.rs b/crates/yara/src/lib.rs index efac1559..015d6dac 100644 --- a/crates/yara/src/lib.rs +++ b/crates/yara/src/lib.rs @@ -33,25 +33,40 @@ pub const MAX_SCAN_BYTES: u64 = 64 * 1024 * 1024; /// Errors from loading rules or running a scan. Rule-loading variants name the path or rule /// identifier at fault. #[derive(Debug, thiserror::Error)] -#[allow(missing_docs)] // #362 pub enum YaraError { + /// A rule file or directory could not be read. #[error("failed to read {path}: {source}")] Io { + /// The file or directory that failed to read. path: String, + /// The underlying I/O error. source: std::io::Error, }, + /// A rule file did not compile. #[error("rule compilation failed in {path}: {message}")] - Compile { path: String, message: String }, + Compile { + /// The rule file that failed to compile. + path: String, + /// The compiler's error message. + message: String, + }, /// Issue #73: every rule must carry severity/technique/falsepositives in its /// `meta:` block. Names the rule identifier — the file path isn't available /// once rules are compiled into one `yara_x::Rules` set. #[error("missing or invalid rule metadata in `{identifier}`: {what}")] - MissingMetadata { identifier: String, what: String }, + MissingMetadata { + /// Identifier of the offending rule. + identifier: String, + /// Which `meta:` entry is missing or invalid. + what: String, + }, /// The OS refused a scan worker thread (`EAGAIN`: a thread or process limit). `thread` names /// the worker, so a log line says which one the host could not start. #[error("failed to start the {thread} thread: {source}")] Spawn { + /// Name of the worker thread that could not be started. thread: &'static str, + /// The error the OS returned. source: std::io::Error, }, } @@ -69,10 +84,12 @@ struct RuleMetadata { /// One YARA match, with the metadata required by issues #73/#74 attached — the /// scanner no longer hands back a bare rule identifier only. #[derive(Debug, Clone)] -#[allow(missing_docs)] // #362 pub struct YaraMatch { + /// Identifier of the matching rule. pub identifier: String, + /// Severity from the rule's `meta:` block. pub severity: Severity, + /// ATT&CK technique from the rule's `meta:` block. pub technique: String, } diff --git a/crates/yara/src/memory.rs b/crates/yara/src/memory.rs index e6c92ce5..58f9e8a0 100644 --- a/crates/yara/src/memory.rs +++ b/crates/yara/src/memory.rs @@ -36,10 +36,12 @@ use crate::{RuleSet, ScanContext, YaraError, YaraMatch}; /// Permissions of a mapped region. #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[allow(clippy::struct_excessive_bools)] // r/w/x/p are four independent mapping flags -#[allow(missing_docs)] // #362 pub struct RegionPerms { + /// The `r` flag: the region is readable. pub read: bool, + /// The `w` flag: the region is writable. pub write: bool, + /// The `x` flag: the region is executable. pub exec: bool, } @@ -73,12 +75,14 @@ pub enum RegionKind { /// One mapped region of a process. #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub struct MemoryRegion { + /// Start address (inclusive). pub start: u64, /// Exclusive end. pub end: u64, + /// Read/write/execute flags of the mapping. pub perms: RegionPerms, + /// What backs the mapping. pub kind: RegionKind, } @@ -167,10 +171,10 @@ impl Default for MemoryBudget { /// What one memory scan did, including everything it chose not to do. #[derive(Debug, Clone, Default)] -#[allow(missing_docs)] // #362 pub struct MemoryScanReport { /// Distinct matching rules across all scanned regions. pub matches: Vec, + /// Regions read and scanned. pub regions_scanned: usize, /// Candidate regions left unread because a budget was spent. pub regions_skipped: usize, @@ -178,6 +182,7 @@ pub struct MemoryScanReport { pub regions_unreadable: usize, /// Regions read only in part because of `max_region_bytes` or `max_total_bytes`. pub regions_truncated: usize, + /// Total bytes handed to the scanner across all regions. pub bytes_scanned: u64, } @@ -239,14 +244,16 @@ pub fn scan_memory( /// One scan's result, delivered when it found something. #[derive(Debug, Clone)] -#[allow(missing_docs)] // #362 pub struct MemoryScanOutcome { + /// Process id that was scanned. pub pid: u32, + /// Incarnation stamp of `pid`, when known; tells a recycled pid apart from the original. pub generation: Option, /// Who the scan was about, as the trigger described them (`(ppid, comm)` and the /// triggering event's time), so a match can be keyed to the same entity as the /// finding that caused the scan. pub context: Option, + /// What the scan read, matched and skipped. pub report: MemoryScanReport, } diff --git a/crates/yara/src/queue.rs b/crates/yara/src/queue.rs index 36b832df..4be5ac5c 100644 --- a/crates/yara/src/queue.rs +++ b/crates/yara/src/queue.rs @@ -25,9 +25,10 @@ const SETTLE: Duration = Duration::from_millis(200); /// The fields mirror the correlator's entity join `(ppid, comm)` plus the parent's /// incarnation (issues #614, #592). #[derive(Debug, Clone, PartialEq, Eq)] -#[allow(missing_docs)] // #362 pub struct ScanContext { + /// Parent process id of the process that triggered the scan. pub ppid: u32, + /// Command name (`comm`) of the process that triggered the scan. pub comm: String, /// The incarnation of the parent `ppid` names, when the sensor stamped one /// (`EventMeta::parent_process_generation`): without it a recycled parent pid @@ -45,8 +46,8 @@ pub struct ScanContext { /// One scan result delivered to the callback. #[derive(Debug, Clone)] -#[allow(missing_docs)] // #362 pub struct ScanOutcome { + /// The file that was scanned. pub path: PathBuf, /// The process that wrote the file, when the request carried one /// ([`ScanQueue::enqueue_for`]). @@ -59,10 +60,10 @@ pub struct ScanOutcome { /// Cumulative scan counters for the queue. `dropped` counts requests that could not be queued /// (queue full or closed). #[derive(Debug, Clone, Copy, Default)] -#[allow(missing_docs)] // #362 pub struct ScanStats { /// Scans fully handled: the match callback, when there was a match, has returned. pub scanned: u64, + /// Requests that could not be queued because the queue was full or closed. pub dropped: u64, } From 87a50bd43bd9d2960b62e71fcf3ef103fda81228 Mon Sep 17 00:00:00 2001 From: SherlockOmss <209794074+SherlockOmss@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:49:20 +0100 Subject: [PATCH 2/2] docs: AlertRecord fields, ServerError message, ScanStats wording (Refs #362) Review of cda763c6: - AlertRecord::technique is an ATT&CK id or an internal finding label (RESPONSE-ESCALATE, BAYES, Sigma, SELF-PROTECTION). - AlertRecord::timestamp_ns is the write time, since the UNIX epoch. - TransportError::ServerError::message says where the text comes from, the 2 KiB read cap, the stripped control/bidi characters and the empty-body fallback. - ScanStats: drop the dropped sentence from the type doc, the field says it. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: SherlockOmss <209794074+SherlockOmss@users.noreply.github.com> --- crates/sinks/src/lib.rs | 5 +++-- crates/transport/src/error.rs | 4 +++- crates/yara/src/queue.rs | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/sinks/src/lib.rs b/crates/sinks/src/lib.rs index 47470985..05e1133f 100644 --- a/crates/sinks/src/lib.rs +++ b/crates/sinks/src/lib.rs @@ -117,9 +117,10 @@ fn needs_tail_repair(path: &Path) -> bool { /// engines emit into this record. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct AlertRecord { - /// Time of the detection, in nanoseconds. + /// When the record was written, in nanoseconds since the UNIX epoch. pub timestamp_ns: u64, - /// ATT&CK technique the detection maps to. + /// ATT&CK technique id, or the label of an internal finding (`RESPONSE-ESCALATE`, `BAYES`, + /// `Sigma`, the watchdog's `SELF-PROTECTION`). pub technique: String, /// Human-readable description of what was detected. pub message: String, diff --git a/crates/transport/src/error.rs b/crates/transport/src/error.rs index c7732ef2..d215225f 100644 --- a/crates/transport/src/error.rs +++ b/crates/transport/src/error.rs @@ -13,7 +13,9 @@ pub enum TransportError { ServerError { /// HTTP status code of the response. status: u16, - /// The server's error message, or the response body when it gave none. + /// The server's `error`, `message` or `reason` string, else the response body, else + /// `http status: N` when the body is empty. The body is read up to 2 KiB, and control and + /// bidi characters are stripped, so a log reader can trust it is one printable line. message: String, }, diff --git a/crates/yara/src/queue.rs b/crates/yara/src/queue.rs index 4be5ac5c..db1134f3 100644 --- a/crates/yara/src/queue.rs +++ b/crates/yara/src/queue.rs @@ -57,8 +57,7 @@ pub struct ScanOutcome { pub matches: Vec, } -/// Cumulative scan counters for the queue. `dropped` counts requests that could not be queued -/// (queue full or closed). +/// Cumulative scan counters for the queue. #[derive(Debug, Clone, Copy, Default)] pub struct ScanStats { /// Scans fully handled: the match callback, when there was a match, has returned.