Skip to content

Commit 1cf2162

Browse files
vsilentCopilot
andcommitted
fix: resolve warnings in tests and examples
- Remove unused imports (AlertSeverity, AlertType, anyhow::Result, SyscallEvent, SyscallType) - Prefix unused variables with underscore - Fix EbpfLoader::default() test (returns value, not Result) - Fix KernelVersionTooLow fields to use String not integer literals - Remove unnecessary mut on enricher variables Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ebf9310 commit 1cf2162

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

examples/usage_examples.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn example_events() {
8484
);
8585

8686
// Convert to SecurityEvent
87-
let security_event: SecurityEvent = execve_event.into();
87+
let _security_event: SecurityEvent = execve_event.into();
8888
println!(" Converted to SecurityEvent variant");
8989

9090
println!(" ✓ Events created successfully\n");

src/events/validation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ impl EventValidator {
117117
#[cfg(test)]
118118
mod tests {
119119
use super::*;
120-
use crate::events::security::{AlertSeverity, AlertType};
121120
use crate::events::syscall::SyscallType;
122121
use chrono::Utc;
123122

tests/collectors/ebpf_loader_test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
#[cfg(target_os = "linux")]
66
mod linux_tests {
7-
use anyhow::Result;
87
use stackdog::collectors::ebpf::loader::{EbpfLoader, LoadError};
98

109
#[test]
@@ -15,8 +14,7 @@ mod linux_tests {
1514

1615
#[test]
1716
fn test_ebpf_loader_default() {
18-
let loader = EbpfLoader::default();
19-
assert!(loader.is_ok(), "EbpfLoader::default() should succeed");
17+
let _loader = EbpfLoader::default();
2018
}
2119

2220
#[test]
@@ -45,8 +43,8 @@ mod linux_tests {
4543
assert!(msg.contains("test_program"));
4644

4745
let error = LoadError::KernelVersionTooLow {
48-
required: 4,
49-
current: 3,
46+
required: "4".to_string(),
47+
current: "3".to_string(),
5048
};
5149
let msg = format!("{}", error);
5250
assert!(msg.contains("4.19"));

tests/collectors/ebpf_syscall_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[cfg(target_os = "linux")]
66
mod linux_tests {
77
use stackdog::collectors::ebpf::syscall_monitor::SyscallMonitor;
8-
use stackdog::events::syscall::{SyscallEvent, SyscallType};
8+
use stackdog::events::syscall::SyscallType;
99
use std::time::Duration;
1010

1111
#[test]
@@ -55,7 +55,7 @@ mod linux_tests {
5555
std::thread::sleep(Duration::from_millis(100));
5656

5757
let events = monitor.poll_events();
58-
let has_connect = events
58+
let _has_connect = events
5959
.iter()
6060
.any(|e| e.syscall_type == SyscallType::Connect);
6161

@@ -90,7 +90,7 @@ mod linux_tests {
9090
// Note: Actually calling ptrace requires special setup
9191
// This test verifies the monitor doesn't crash
9292

93-
let events = monitor.poll_events();
93+
let _events = monitor.poll_events();
9494
assert!(true); // Just verify no panic
9595
}
9696

tests/collectors/event_enrichment_test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn test_event_enricher_creation() {
1515

1616
#[test]
1717
fn test_enrich_adds_timestamp() {
18-
let mut enricher = EventEnricher::new().expect("Failed to create enricher");
18+
let enricher = EventEnricher::new().expect("Failed to create enricher");
1919
let mut event = SyscallEvent::new(1234, 1000, SyscallType::Execve, Utc::now());
2020

2121
enricher.enrich(&mut event).expect("Failed to enrich");
@@ -26,7 +26,7 @@ fn test_enrich_adds_timestamp() {
2626

2727
#[test]
2828
fn test_enrich_preserves_existing_timestamp() {
29-
let mut enricher = EventEnricher::new().expect("Failed to create enricher");
29+
let enricher = EventEnricher::new().expect("Failed to create enricher");
3030
let original_timestamp = Utc::now();
3131
let mut event = SyscallEvent::new(1234, 1000, SyscallType::Execve, original_timestamp);
3232

@@ -104,7 +104,7 @@ fn test_cgroup_parsing() {
104104

105105
#[test]
106106
fn test_process_tree_enrichment() {
107-
let mut enricher = EventEnricher::new().expect("Failed to create enricher");
107+
let enricher = EventEnricher::new().expect("Failed to create enricher");
108108

109109
// Test that we can get parent PID
110110
let ppid = enricher.get_parent_pid(1); // init process
@@ -116,7 +116,7 @@ fn test_process_tree_enrichment() {
116116

117117
#[test]
118118
fn test_process_comm_enrichment() {
119-
let mut enricher = EventEnricher::new().expect("Failed to create enricher");
119+
let enricher = EventEnricher::new().expect("Failed to create enricher");
120120

121121
// Test that we can get process name
122122
let comm = enricher.get_process_comm(std::process::id());
@@ -143,7 +143,7 @@ fn test_timestamp_normalization() {
143143

144144
#[test]
145145
fn test_enrichment_pipeline() {
146-
let mut enricher = EventEnricher::new().expect("Failed to create enricher");
146+
let enricher = EventEnricher::new().expect("Failed to create enricher");
147147
let mut event = SyscallEvent::new(1234, 1000, SyscallType::Execve, Utc::now());
148148

149149
// Run full enrichment pipeline

tests/collectors/ptrace_capture_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#[cfg(target_os = "linux")]
66
mod linux_tests {
77
use stackdog::collectors::ebpf::syscall_monitor::SyscallMonitor;
8-
use stackdog::events::syscall::SyscallType;
98
use std::time::Duration;
109

1110
#[test]

0 commit comments

Comments
 (0)