Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/firewall/iptables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/firewall/nftables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/sniff/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/sniff/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading