From 104a6d165f46465ad1316f524599ac4f680bfc10 Mon Sep 17 00:00:00 2001 From: Vasili Pascal Date: Mon, 16 Nov 2026 14:53:28 +0200 Subject: [PATCH 1/2] fix(firewall): treat a missing chain as an empty rule list On a fresh box stackdog firewall list died with a backtrace: both backends shelled out to list rules for a table/chain that does not exist yet and bailed on the error. Nothing being banned is an empty list, not a failure. Caught while scripting a lab demo on a clean container; the production box never showed it because its rules already existed. --- src/firewall/iptables.rs | 15 +++++++++++---- src/firewall/nftables.rs | 11 +++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/firewall/iptables.rs b/src/firewall/iptables.rs index db73884..0a0da29 100644 --- a/src/firewall/iptables.rs +++ b/src/firewall/iptables.rs @@ -289,10 +289,17 @@ impl IptablesBackend { .context("Failed to list iptables rules")?; if !output.status.success() { - anyhow::bail!( - "Failed to list rules: {}", - String::from_utf8_lossy(&output.stderr) - ); + let stderr = String::from_utf8_lossy(&output.stderr); + // A fresh box has no stackdog chain yet: nothing is banned, + // which is an empty list, not an error. + if stderr.contains("No chain/target/match by that name") + || stderr.contains("No chain matches") + || stderr.contains("does not exist") + || stderr.contains("No such file or directory") + { + return Ok(Vec::new()); + } + anyhow::bail!("Failed to list rules: {}", stderr); } let stdout = String::from_utf8_lossy(&output.stdout); diff --git a/src/firewall/nftables.rs b/src/firewall/nftables.rs index c4b125b..e1f240b 100644 --- a/src/firewall/nftables.rs +++ b/src/firewall/nftables.rs @@ -414,10 +414,13 @@ impl NfTablesBackend { .context("Failed to list nftables rules")?; if !output.status.success() { - anyhow::bail!( - "Failed to list rules: {}", - String::from_utf8_lossy(&output.stderr) - ); + let stderr = String::from_utf8_lossy(&output.stderr); + // A fresh box has no stackdog table or chain yet: nothing is + // banned, which is an empty list, not an error. + if stderr.contains("No such file or directory") || stderr.contains("does not exist") { + return Ok(Vec::new()); + } + anyhow::bail!("Failed to list rules: {}", stderr); } let stdout = String::from_utf8_lossy(&output.stdout); From bfde3c37ad3174104c6e386d62daee5862fe1e7f Mon Sep 17 00:00:00 2001 From: Vasili Pascal Date: Mon, 16 Nov 2026 14:53:28 +0200 Subject: [PATCH 2/2] style: silence clippy::double_must_use from async-trait The macro expands to #[must_use] fns returning Result; rustc 1.99's clippy flags the duplication. Scoped allow on the two traits. --- src/sniff/analyzer.rs | 3 +++ src/sniff/reader.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/sniff/analyzer.rs b/src/sniff/analyzer.rs index 8120228..4dc9f60 100644 --- a/src/sniff/analyzer.rs +++ b/src/sniff/analyzer.rs @@ -68,6 +68,9 @@ impl std::fmt::Display for AnomalySeverity { } /// Trait for AI-powered log analysis +// async-trait expands to #[must_use] fns returning Result; newer clippy +// flags that Result already implies must_use. +#[allow(clippy::double_must_use)] #[async_trait] pub trait LogAnalyzer: Send + Sync { /// Summarize a batch of log entries diff --git a/src/sniff/reader.rs b/src/sniff/reader.rs index 8029226..51b3c2b 100644 --- a/src/sniff/reader.rs +++ b/src/sniff/reader.rs @@ -21,6 +21,9 @@ pub struct LogEntry { } /// Trait for reading log entries from a source +// async-trait expands to #[must_use] fns returning Result; newer clippy +// flags that Result already implies must_use. +#[allow(clippy::double_must_use)] #[async_trait] pub trait LogReader: Send + Sync { /// Read new entries since the last read position