|
|
import os |
|
|
import streamlit as st |
|
|
from components.dashboard import Dashboard |
|
|
from PurpleTeamIDS import analyze_security_log, API_TOKEN |
|
|
import time |
|
|
|
|
|
|
|
|
st.set_page_config( |
|
|
page_title="Cybersecurity IDS Dashboard", |
|
|
page_icon="🛡️", |
|
|
layout="wide", |
|
|
initial_sidebar_state="expanded" |
|
|
) |
|
|
|
|
|
def main(): |
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
dashboard = Dashboard() |
|
|
|
|
|
|
|
|
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}") |
|
|
|
|
|
|
|
|
dashboard.render_main_content() |
|
|
|
|
|
|
|
|
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" |
|
|
] |
|
|
|
|
|
|
|
|
for log in sample_logs: |
|
|
threat_data = analyze_security_log(log) |
|
|
dashboard.threat_analysis.process_new_threat(threat_data) |
|
|
time.sleep(2) |
|
|
st.experimental_rerun() |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |