Fix dead code warnings and add Default implementations
This commit is contained in:
@@ -36,7 +36,7 @@ impl std::fmt::Debug for EbpfDetector {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EbpfProgramManager {
|
pub struct EbpfProgramManager {
|
||||||
loaded_programs: HashMap<String, LoadedProgram>,
|
loaded_programs: HashMap<String, LoadedProgram>,
|
||||||
program_definitions: Vec<EbpfProgramDefinition>,
|
_program_definitions: Vec<EbpfProgramDefinition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -78,8 +78,8 @@ pub struct EbpfProgramDefinition {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct EbpfEventProcessor {
|
pub struct EbpfEventProcessor {
|
||||||
event_handlers: HashMap<EventType, Box<dyn EventHandler>>,
|
event_handlers: HashMap<EventType, Box<dyn EventHandler>>,
|
||||||
detection_rules: Vec<EbpfDetectionRule>,
|
_detection_rules: Vec<EbpfDetectionRule>,
|
||||||
process_tracker: ProcessTracker,
|
_process_tracker: ProcessTracker,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -391,9 +391,9 @@ pub enum NetworkPattern {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ProcessTracker {
|
pub struct ProcessTracker {
|
||||||
processes: HashMap<u32, TrackedProcess>,
|
_processes: HashMap<u32, TrackedProcess>,
|
||||||
process_tree: HashMap<u32, Vec<u32>>,
|
_process_tree: HashMap<u32, Vec<u32>>,
|
||||||
injection_timeline: Vec<InjectionEvent>,
|
_injection_timeline: Vec<InjectionEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -446,7 +446,7 @@ pub enum IndicatorType {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EbpfFilterManager {
|
pub struct EbpfFilterManager {
|
||||||
active_filters: HashMap<String, EbpfFilter>,
|
active_filters: HashMap<String, EbpfFilter>,
|
||||||
filter_statistics: HashMap<String, FilterStats>,
|
_filter_statistics: HashMap<String, FilterStats>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -498,11 +498,11 @@ pub struct FilterStats {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EbpfRingBuffer {
|
pub struct EbpfRingBuffer {
|
||||||
buffer: Vec<EbpfEvent>,
|
_buffer: Vec<EbpfEvent>,
|
||||||
read_index: usize,
|
_read_index: usize,
|
||||||
write_index: usize,
|
_write_index: usize,
|
||||||
capacity: usize,
|
_capacity: usize,
|
||||||
lost_events: u64,
|
_lost_events: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -808,6 +808,13 @@ pub enum EbpfError {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct ProcessCreateHandler;
|
pub struct ProcessCreateHandler;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for ProcessCreateHandler {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl ProcessCreateHandler {
|
impl ProcessCreateHandler {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -830,6 +837,13 @@ impl EventHandler for ProcessCreateHandler {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct MemoryMapHandler;
|
pub struct MemoryMapHandler;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for MemoryMapHandler {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl MemoryMapHandler {
|
impl MemoryMapHandler {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -852,6 +866,13 @@ impl EventHandler for MemoryMapHandler {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct MemoryProtectHandler;
|
pub struct MemoryProtectHandler;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for MemoryProtectHandler {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl MemoryProtectHandler {
|
impl MemoryProtectHandler {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -874,6 +895,13 @@ impl EventHandler for MemoryProtectHandler {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub struct InjectionHandler;
|
pub struct InjectionHandler;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for InjectionHandler {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl InjectionHandler {
|
impl InjectionHandler {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@@ -899,7 +927,7 @@ impl EbpfProgramManager {
|
|||||||
pub fn new() -> Result<Self, EbpfError> {
|
pub fn new() -> Result<Self, EbpfError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
loaded_programs: HashMap::new(),
|
loaded_programs: HashMap::new(),
|
||||||
program_definitions: Vec::new(),
|
_program_definitions: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,13 +938,20 @@ impl EbpfProgramManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for EbpfEventProcessor {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl EbpfEventProcessor {
|
impl EbpfEventProcessor {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
event_handlers: HashMap::new(),
|
event_handlers: HashMap::new(),
|
||||||
detection_rules: Vec::new(),
|
_detection_rules: Vec::new(),
|
||||||
process_tracker: ProcessTracker::new(),
|
_process_tracker: ProcessTracker::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,23 +965,37 @@ impl EbpfEventProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for ProcessTracker {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl ProcessTracker {
|
impl ProcessTracker {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
processes: HashMap::new(),
|
_processes: HashMap::new(),
|
||||||
process_tree: HashMap::new(),
|
_process_tree: HashMap::new(),
|
||||||
injection_timeline: Vec::new(),
|
_injection_timeline: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
impl Default for EbpfFilterManager {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
impl EbpfFilterManager {
|
impl EbpfFilterManager {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
active_filters: HashMap::new(),
|
active_filters: HashMap::new(),
|
||||||
filter_statistics: HashMap::new(),
|
_filter_statistics: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,11 +1013,11 @@ impl EbpfFilterManager {
|
|||||||
impl EbpfRingBuffer {
|
impl EbpfRingBuffer {
|
||||||
pub fn new(capacity: usize) -> Self {
|
pub fn new(capacity: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
buffer: Vec::with_capacity(capacity),
|
_buffer: Vec::with_capacity(capacity),
|
||||||
read_index: 0,
|
_read_index: 0,
|
||||||
write_index: 0,
|
_write_index: 0,
|
||||||
capacity,
|
_capacity: capacity,
|
||||||
lost_events: 0,
|
_lost_events: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user