dcata004 commited on
Commit
0d6eac3
·
verified ·
1 Parent(s): da5f5c2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import plotly.graph_objects as go
5
+ import time
6
+
7
+ # --- CONFIGURATION ---
8
+ st.set_page_config(page_title="Veritas SCADA Simulator", layout="wide")
9
+
10
+ # --- SIDEBAR (Compliance) ---
11
+ st.sidebar.image("https://img.icons8.com/color/96/000000/shield.png", width=50)
12
+ st.sidebar.header("🛡️ Veritas Sentinel")
13
+ st.sidebar.markdown("**System Status:** ✅ ONLINE")
14
+ st.sidebar.markdown("---")
15
+ st.sidebar.subheader("NIST AI RMF Controls")
16
+ st.sidebar.checkbox("Map-1.3: Asset Inventory", value=True)
17
+ st.sidebar.checkbox("Manage-2.4: Incident Response", value=True)
18
+ st.sidebar.checkbox("Gov-3.1: Human Oversight", value=True)
19
+
20
+ # --- MAIN DASHBOARD ---
21
+ st.title("🌊 Water Treatment Plant #4 - SCADA Monitor")
22
+ st.markdown("Real-time telemetry monitoring for **Cyber-Physical Anomalies**.")
23
+
24
+ # --- SIMULATION LOGIC ---
25
+ # Create placeholders for the live graph
26
+ placeholder = st.empty()
27
+ alert_box = st.empty()
28
+
29
+ # Button to trigger "Attack"
30
+ if st.button('⚠️ SIMULATE RANSOMWARE ATTACK'):
31
+ attack_mode = True
32
+ else:
33
+ attack_mode = False
34
+
35
+ # Generate Data
36
+ seconds = 0
37
+ data = []
38
+
39
+ # --- LIVE LOOP (Simulated) ---
40
+ # In a real app, this would run indefinitely. For the demo, we show a snapshot.
41
+ for i in range(50):
42
+ seconds += 1
43
+
44
+ # Normal Pressure is 60-80 PSI. Attack spikes to 150 PSI.
45
+ if attack_mode and i > 25:
46
+ pressure = np.random.randint(140, 160)
47
+ status_color = "red"
48
+ alert_box.error("🚨 CRITICAL ALERT: PLC CONTROL FAILURE DETECTED. MANUAL OVERRIDE REQUIRED.")
49
+ else:
50
+ pressure = np.random.randint(60, 80)
51
+ status_color = "#00ff00" # Neon Green
52
+ if not attack_mode:
53
+ alert_box.success("System Normal. AI Governance Active.")
54
+
55
+ data.append(pressure)
56
+
57
+ # Draw Graph
58
+ fig = go.Figure()
59
+ fig.add_trace(go.Scatter(y=data, mode='lines+markers', line=dict(color=status_color, width=3)))
60
+ fig.update_layout(
61
+ title="Main Pump Discharge Pressure (PSI)",
62
+ yaxis_range=[0, 200],
63
+ template="plotly_dark",
64
+ height=400
65
+ )
66
+
67
+ placeholder.plotly_chart(fig, use_container_width=True)
68
+ time.sleep(0.1)