initial commit: Threat Engine Agent
This commit is contained in:
commit
848a29543d
7 files changed
+283
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# threat-engine-agent/agent.py
|
||||
|
||||
import time
|
||||
import logging
|
||||
from auditor import FirewallAuditor
|
||||
from reporter import LocalStateReporter
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
filename='/home/patrick/threat-engine-agent/logs/threat-agent.log'
|
||||
)
|
||||
|
||||
def main():
|
||||
"""
|
||||
The Orchestrator: Links Audit findings to the State Reporter.
|
||||
"""
|
||||
auditor = FirewallAuditor()
|
||||
reporter = LocalStateReporter()
|
||||
|
||||
CHECK_INTERVAL = 600
|
||||
logging.info("Threat Engine Agent initialized on Triton.")
|
||||
|
||||
while True:
|
||||
try:
|
||||
is_synced, count = auditor.reconcile()
|
||||
|
||||
reporter.update_status(is_synced, count)
|
||||
|
||||
if not is_synced:
|
||||
logging.warning(f"Desync detected ({count} IPs in kernel). Healing...")
|
||||
auditor.heal()
|
||||
reporter.log_heal_event(count) # Record the event in history
|
||||
else:
|
||||
logging.info(f"Audit Success: {count} IPs in sync.")
|
||||
|
||||
time.sleep(CHECK_INTERVAL)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Agent shutting down manually.")
|
||||
break
|
||||
except Exception as e:
|
||||
logging.error(f"Main loop error: {e}")
|
||||
# Ensure the reporter notes the error state
|
||||
try:
|
||||
reporter.update_status(False, 0, last_error=str(e))
|
||||
except:
|
||||
pass
|
||||
time.sleep(60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user