Skip to content
Open
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
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() {
println!("cargo:rustc-link-lib=dylib=EndpointSecurity");
println!("cargo:rustc-link-lib=dylib=bsm");
}
}
20 changes: 12 additions & 8 deletions examples/process_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[macro_use] extern crate log;
#[macro_use]
extern crate log;

use endpointsecurity::*;
use crossbeam_channel::unbounded as channel;
use endpointsecurity::*;

fn main() {
env_logger::init();
Expand All @@ -16,7 +17,10 @@ fn main() {
}
};

if !client.set_subscriptions_to(&vec![SupportedEsEvent::NotifyExec, SupportedEsEvent::NotifyFork]) {
if !client.set_subscriptions_to(&vec![
SupportedEsEvent::NotifyExec,
SupportedEsEvent::NotifyFork,
]) {
error!("Could not subscribe to NotifyExec event (not sure why)");
return;
}
Expand All @@ -34,20 +38,20 @@ fn main() {
EsEvent::NotifyExec(event) => {
match serde_json::to_string(&event) {
Ok(json) => println!("{}", json),
Err(e) => error!("Error serializing event: {}", e)
Err(e) => error!("Error serializing event: {}", e),
}
//println!("Type: Exec, PID: {}, Path: {}, CDHash: {}, Args: {}", event.target.pid, event.target.executable.path, event.target.cdhash, event.args.join(" "));
},
}
EsEvent::NotifyFork(event) => {
match serde_json::to_string(&event) {
Ok(json) => println!("{}", json),
Err(e) => error!("Error serializing event: {}", e)
Err(e) => error!("Error serializing event: {}", e),
}
//println!("Type: Fork, PID: {}, Path: {}, CDHash: {}", event.child.pid, event.child.executable.path, event.child.cdhash);
},
}
_ => {
continue;
}
}
}
}
}
17 changes: 11 additions & 6 deletions examples/signal_intercept.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[macro_use] extern crate log;
#[macro_use]
extern crate log;

use endpointsecurity::*;
use crossbeam_channel::unbounded as channel;
use endpointsecurity::*;

fn main() {
env_logger::init();
Expand Down Expand Up @@ -39,7 +40,11 @@ fn main() {
// Backout of all signals that don't affect EsClients as quickly as possible
// to reduce impact to system responsiveness
if !event.target.is_es_client {
client.respond_to_auth_event(&message, &EsAuthResult::Allow, &EsCacheResult::No);
client.respond_to_auth_event(
&message,
&EsAuthResult::Allow,
&EsCacheResult::No,
);
continue;
}

Expand All @@ -48,13 +53,13 @@ fn main() {
println!("Received a signal to my EsClient, disallowing that!");
client.respond_to_auth_event(&message, &EsAuthResult::Deny, &EsCacheResult::No);
}

// This is a signal to someone else's EsClient. Don't touch it
client.respond_to_auth_event(&message, &EsAuthResult::Allow, &EsCacheResult::No);
},
}
_ => {
continue;
}
}
}
}
}
Loading