| import gradio as gr |
| import re |
|
|
| def classify_event(log_line): |
|
|
| log = log_line.lower() |
|
|
| |
| event_type = "unknown" |
| risk = "low" |
|
|
| |
| 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" |
|
|
| |
| elif "packet filtered" in log: |
| event_type = "firewall_action" |
| risk = "medium" |
|
|
| elif "port scan" in log: |
| event_type = "reconnaissance_attack" |
| risk = "high" |
|
|
| |
| 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() |