File size: 1,137 Bytes
b7439d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import gradio as gr
import re
def classify_event(log_line):
log = log_line.lower()
# DEFAULT
event_type = "unknown"
risk = "low"
# AUTH / NETWORK
if "authenticated" in log:
event_type = "authentication"
risk = "low"
elif "dhcp" in log:
event_type = "network_management"
risk = "low"
elif "handshake" in log:
event_type = "connection_established"
risk = "low"
# SECURITY EVENTS
elif "packet filtered" in log:
event_type = "firewall_action"
risk = "medium"
elif "port scan" in log:
event_type = "reconnaissance_attack"
risk = "high"
# OUTPUT STRUCTURE
return {
"raw_log": log_line,
"event_type": event_type,
"risk_level": risk,
"status": "analyzed"
}
def nexus_security(input_text):
lines = input_text.split("\n")
return [classify_event(line) for line in lines]
gr.Interface(
fn=nexus_security,
inputs=gr.Textbox(lines=10, label="Security Logs"),
outputs=gr.JSON(label="Security Analysis"),
title="Nexus Security Dashboard"
).launch() |