ACA050 commited on
Commit
fb52aa0
Β·
verified Β·
1 Parent(s): a0baf54

Upload 7 files

Browse files
Files changed (7) hide show
  1. .dockerignore +15 -0
  2. Dockerfile +19 -0
  3. LICENSE +0 -0
  4. README.md +128 -8
  5. app.py +22 -0
  6. docker-compose.yml +13 -0
  7. requirements.txt +22 -0
.dockerignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .coverage
6
+ htmlcov/
7
+ data/raw/*
8
+ data/processed/*
9
+ data/predictions/*
10
+ !data/raw/.gitkeep
11
+ !data/processed/.gitkeep
12
+ !data/predictions/.gitkeep
13
+ models/*
14
+ artifacts/*
15
+ .env
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Non-root user
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH \
10
+ PYTHONPATH=/home/user/app
11
+ WORKDIR $HOME/app
12
+
13
+ COPY --chown=user requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
16
+ COPY --chown=user . .
17
+
18
+ EXPOSE 7860
19
+ CMD ["python", "app.py"]
LICENSE ADDED
File without changes
README.md CHANGED
@@ -1,11 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: SentinelAI
3
- emoji: 🐠
4
- colorFrom: gray
5
- colorTo: gray
6
- sdk: static
7
- pinned: false
8
- short_description: AI-Powered Behavioral Threat Detection Platform
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # πŸ›‘οΈ SentinelAI: Enterprise Security Intelligence Platform
2
+
3
+ ![SentinelAI](https://img.shields.io/badge/Status-Hackathon_Ready-00E676?style=for-the-badge)
4
+ ![Python](https://img.shields.io/badge/Python-3.10+-blue?style=for-the-badge)
5
+ ![Streamlit](https://img.shields.io/badge/Streamlit-Dark_Theme-FF4B4B?style=for-the-badge)
6
+
7
+ SentinelAI is an end-to-end, multi-stage AI security platform designed to move beyond simple anomaly detection. It actively learns normal behavior, detects deviations using an ensemble of models, accurately classifies attack vectors, and explains its reasoning in human-readable terms on a premium analyst dashboard.
8
+
9
+ ### πŸ–ΌοΈ Dashboard Previews
10
+ | Global Telemetry | Threat Hunting | Deep Investigation |
11
+ | :---: | :---: | :---: |
12
+ | ![Global Telemetry](https://via.placeholder.com/400x200.png?text=Global+Telemetry) | ![Threat Queue](https://via.placeholder.com/400x200.png?text=Threat+Hunting+Queue) | ![Investigation Console](https://via.placeholder.com/400x200.png?text=Deep+Investigation) |
13
+
14
+ ---
15
+
16
+ ## πŸ† How We Meet the Evaluation Criteria
17
+
18
+ This project was specifically architected to address the complex requirements of modern enterprise security. **We did not just train an Isolation Forest; we built a comprehensive intelligence pipeline.**
19
+
20
+ | Evaluation Criteria | How SentinelAI Solves It |
21
+ | :--- | :--- |
22
+ | **Behavior Profiling** | **Phase 2 Pipeline** generates passive statistical baselines for devices and users to understand "normal" before scoring deviations. |
23
+ | **Detect Deviations** | **Phase 3 Pipeline** utilizes a Detection Aggregator combining deterministic rules, statistical deviations, and an Isolation Forest. |
24
+ | **Attack Classification** | **Phase 4 Pipeline** feeds aggregated anomalies into an `XGBoostClassifier` to identify specific threat vectors (e.g., Credential Stuffing, Brute Force). |
25
+ | **Explain Why (XAI)** | **Phase 5 Pipeline** uses `SHAP` for feature importance and a `NaturalLanguageGenerator` to output actionable, human-readable executive summaries. |
26
+ | **Low False Positives** | Our **Risk Fusion Engine** acts as a filter. By ensembling multiple distinct engines (Rules + Stats + IF), we suppress noisy, single-engine alerts. |
27
+ | **Imbalanced Data** | `XGBoost` naturally handles severe class imbalance via weight scaling, while our `Isolation Forest` operates as an unsupervised outlier detector. |
28
+ | **Cold Start Handling** | New users have no profile. Our **Rule Engine** covers the cold start phase with strict heuristics until the statistical engines gather enough data to take over. |
29
+ | **Concept Drift** | The modular `orchestrator.py` architecture allows passive models to be periodically retrained on new parquet chunks without taking the detection rules offline. |
30
+ | **Scalability** | The entire backend operates on highly optimized `parquet` files using Pandas/PyArrow, ready for distributed processing. |
31
+ | **Dashboard Usability** | We built a responsive, premium Streamlit dashboard featuring custom CSS, dark mode, and interactive Plotly visualizations for rapid threat investigation. |
32
+
33
+ ---
34
+
35
+ ## 🧠 Core Architecture Pipeline
36
+
37
+ SentinelAI operates on a strict, 5-phase execution pipeline to ensure maximum fidelity and explainability.
38
+
39
+ ```mermaid
40
+ graph TD
41
+ A[Synthetic Data Generation] --> B[Feature Engineering]
42
+ B --> C[Behavior Profiling]
43
+ C --> D[Isolation Forest]
44
+ C --> E[Rule Engine]
45
+ D --> F[Risk Fusion Engine]
46
+ E --> F
47
+ F --> G[XGBoost Classifier]
48
+ G --> H[SHAP Explainability]
49
+ H --> I[SOC Analyst Dashboard]
50
+
51
+ style I fill:#2196F3,stroke:#333,stroke-width:2px,color:#fff
52
+ ```
53
+
54
+ 1. **Data Ingestion & Generation:** Bootstraps baseline enterprise logs and injects precise threat scenarios (e.g. Impossible Travel).
55
+ 2. **Feature Engineering & Profiling:** Temporal and behavioral feature extraction.
56
+ 3. **Detection Core (The Ensemble):**
57
+ - **Rule Engine:** Deterministic checks (e.g., impossible travel, mass failures).
58
+ - **Statistical Engine:** Checks against established user/device baselines.
59
+ - **Isolation Forest:** High-dimensional anomaly detection.
60
+ 4. **Risk Fusion & Classification:** Normalizes inputs into an enterprise 0-100 risk score and uses XGBoost to classify the exact threat context.
61
+ 5. **Explainability Engine:** Generates SHAP values, risk breakdowns, and natural language audit trails.
62
+
63
+ ---
64
+
65
+ ## πŸš€ How to Run the Project (For Judges)
66
+
67
+ We've made reproducibility our top priority. You can run the entire pipeline and view the dashboard with just a few commands.
68
+
69
+ ### 1. Setup Environment
70
+ ```bash
71
+ python -m venv venv
72
+ source venv/Scripts/activate # On Windows
73
+ pip install -r requirements.txt
74
+ ```
75
+
76
+ ### 2. Local Execution (Analyst Dashboard)
77
+ Our Streamlit app is the primary interface for the platform.
78
+ ```bash
79
+ streamlit run src/ui/app.py
80
+ ```
81
+
82
+ ### 3. Final Demo Mode (Execute Pipeline)
83
+ You can trigger the entire end-to-end AI pipeline (Phases 1 through 5) directly from the **sidebar of the Streamlit Dashboard** by clicking **"πŸš€ Execute AI Pipeline"**.
84
+
85
+ Alternatively, you can run it headless from the terminal:
86
+ ```bash
87
+ python -m src.runtime.orchestrator
88
+ ```
89
+
90
+ ### 4. Docker Execution
91
+ To run SentinelAI in an isolated container:
92
+ ```bash
93
+ docker-compose up --build
94
+ ```
95
+ The dashboard will be accessible at `http://localhost:8501`.
96
+
97
+ ### 5. Hugging Face Deployment
98
+ To deploy to Hugging Face Spaces:
99
+ 1. Create a new Space (choose Streamlit as the SDK).
100
+ 2. Upload the repository files.
101
+ 3. Hugging Face will automatically install `requirements.txt` and run `app.py`.
102
+
103
+ ---
104
+
105
+ ## πŸ› οΈ Configuration & Troubleshooting
106
+
107
+ - **Configuration:** Environment settings are stored in the `config/` directory. You can toggle feature flags in `config/feature_flags/`.
108
+ - **Troubleshooting:**
109
+ - *No Data Displayed:* Ensure you click "Execute AI Pipeline" in the sidebar to generate data.
110
+ - *ModuleNotFoundError:* Ensure your `PYTHONPATH` includes the project root, or always run scripts as modules (e.g., `python -m src.ui.app`).
111
+
112
  ---
113
+
114
+ ## πŸ“ Repository Structure
115
+
116
+ ```text
117
+ SentinelAI/
118
+ β”œβ”€β”€ src/
119
+ β”‚ β”œβ”€β”€ ai/ # Core Intelligence (Detection, Classification, XAI)
120
+ β”‚ β”œβ”€β”€ data/ # Data Generation & Validation
121
+ β”‚ β”œβ”€β”€ runtime/ # Pipeline Orchestrators (Phases 2-5)
122
+ β”‚ └── ui/ # Streamlit Dashboard & Plotly Visualizations
123
+ β”œβ”€β”€ data/ # Raw, Processed, and Prediction parquets
124
+ β”œβ”€β”€ docs/ # Enterprise Documentation & Final Submission Reports
125
+ β”œβ”€β”€ models/ # Serialized models (XGBoost, Isolation Forest)
126
+ β”œβ”€β”€ .streamlit/ # Premium UI Configurations
127
+ └── README.md # You are here!
128
+ ```
129
+
130
  ---
131
 
 
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import sys
4
+
5
+ def main():
6
+ os.environ["STREAMLIT_CONFIG_DIR"] = os.path.join(os.getcwd(), ".streamlit")
7
+ os.environ["STREAMLIT_BROWSER_GATHER_USAGE_STATS"] = "false"
8
+ os.environ["STREAMLIT_HEADLESS"] = "true"
9
+ os.environ["PYTHONPATH"] = os.getcwd()
10
+ print("Starting SentinelAI Application via Hugging Face Entrypoint...")
11
+
12
+ # 1. Run Pipeline Orchestrator if data doesn't exist
13
+ if not os.path.exists("data/predictions/explanations.parquet"):
14
+ print("Running pipeline to generate data...")
15
+ subprocess.run([sys.executable, "-m", "src.runtime.orchestrator"], check=True)
16
+
17
+ # 2. Launch Streamlit
18
+ print("Launching Streamlit Dashboard...")
19
+ subprocess.run([sys.executable, "-m", "streamlit", "run", "src/ui/app.py", "--server.port=7860", "--server.address=0.0.0.0", "--browser.gatherUsageStats=false", "--server.headless=true"])
20
+
21
+ if __name__ == "__main__":
22
+ main()
docker-compose.yml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ sentinelai:
5
+ build: .
6
+ ports:
7
+ - "7860:7860"
8
+ environment:
9
+ - PYTHONUNBUFFERED=1
10
+ volumes:
11
+ - ./data:/home/user/app/data
12
+ - ./artifacts:/home/user/app/artifacts
13
+ - ./models:/home/user/app/models
requirements.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data and Persistence
2
+ pandas>=2.1.0
3
+ numpy>=1.26.0
4
+ pyarrow>=14.0.0
5
+ fastparquet>=2023.10.0
6
+
7
+ # AI and Machine Learning
8
+ scikit-learn>=1.3.0
9
+ xgboost>=2.0.0
10
+ shap>=0.44.0
11
+
12
+ # Dashboard and Visualization
13
+ streamlit>=1.30.0
14
+ plotly>=5.18.0
15
+
16
+ # Utilities
17
+ pyyaml>=6.0
18
+ python-dotenv>=1.0.0
19
+ faker>=22.0.0
20
+
21
+ # Testing
22
+ pytest>=7.4.0