File size: 1,743 Bytes
e080f90
44540ba
 
 
 
 
 
 
 
 
 
 
 
 
 
e080f90
44540ba
 
e080f90
44540ba
 
 
 
e080f90
44540ba
 
 
 
 
 
 
e080f90
 
 
 
 
 
44540ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e080f90
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
54
55
56
57
58
import os
import streamlit as st
from components.dashboard import Dashboard
from PurpleTeamIDS import analyze_security_log, API_TOKEN
import time

# Must be the first Streamlit command
st.set_page_config(
    page_title="Cybersecurity IDS Dashboard",
    page_icon="🛡️",
    layout="wide",
    initial_sidebar_state="expanded"
)

def main():
    # Get API token from environment or sidebar securely
    api_token = st.sidebar.text_input(
        "Hugging Face API Token",
        value=os.getenv("HUGGING_FACE_API_TOKEN", API_TOKEN),
        type="password",
        key="huggingface_api_token"
    )

    if not api_token or api_token == "your_huggingface_api_token_here":
        st.warning("Please enter your Hugging Face API token in the sidebar.")
        st.stop()

    # Initialize dashboard
    dashboard = Dashboard()

    # Load custom CSS
    css_path = "styles/custom.css"
    try:
        with open(css_path) as f:
            st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
    except FileNotFoundError:
        st.error(f"CSS file not found: {css_path}")

    # Render main content
    dashboard.render_main_content()

    # Simulate real-time log analysis
    sample_logs = [
        "Failed SSH login attempt from IP 192.168.1.10",
        "Multiple port scan detected from IP 10.0.0.5",
        "Suspicious outbound connection to known malicious IP",
        "Brute force attack detected on admin portal"
    ]

    # Process sample logs
    for log in sample_logs:
        threat_data = analyze_security_log(log)
        dashboard.threat_analysis.process_new_threat(threat_data)
        time.sleep(2)  # Simulate real-time updates
        st.experimental_rerun()

if __name__ == "__main__":
    main()