pub fn judge_application_firewall(
global_state: &str,
apps: &str,
executable: &Path,
) -> FirewallObservationExpand description
Judge the macOS application firewall against the executable the server runs as: off is inactive; on, the executable must be listed as allowed.
use std::path::Path;
use majordomus_cli::mesh::firewall::{judge_application_firewall, FirewallObservationState};
let exe = Path::new("/opt/majordomus");
assert_eq!(judge_application_firewall("Firewall is disabled. (State = 0)", "", exe).state, FirewallObservationState::Inactive);
let apps = "ALF: total number of apps = 1 \n\n1 : /opt/majordomus \n \t ( Allow incoming connections ) \n";
assert_eq!(judge_application_firewall("Firewall is enabled. (State = 1)", apps, exe).state, FirewallObservationState::Present);
let other = "1 : /opt/other \n \t ( Allow incoming connections ) \n";
assert_eq!(judge_application_firewall("Firewall is enabled. (State = 1)", other, exe).state, FirewallObservationState::Missing);
let blocked = "1 : /opt/majordomus \n \t ( Block incoming connections ) \n";
assert_eq!(judge_application_firewall("Firewall is enabled. (State = 1)", blocked, exe).state, FirewallObservationState::Missing);