Rithvickkr commited on
Commit
a0231c5
·
1 Parent(s): 6db773f

Initial deployment with app, requirements, license, and README

Browse files
Files changed (4) hide show
  1. LICENSE +19 -0
  2. README.md +90 -14
  3. app.py +45 -0
  4. requirements.txt +2 -0
LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright 2025 Rithvick Kumar
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
README.md CHANGED
@@ -1,14 +1,90 @@
1
- ---
2
- title: Ai Cybersecurity Agent
3
- emoji: 👀
4
- colorFrom: green
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.32.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- short_description: AI Cybersecurity Agent is an intelligent threat detection ch
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ title: AI Cybersecurity Agentemoji:
3
+ 🔒colorFrom: greencolorTo: graysdk: gradiosdk_version: 4.0.0app_file: app.pypinned: falselicense: apache-2.0short_description: An intelligent AI-driven cybersecurity agent enhancing DSATP for IoT threat detection in distributed networks.
4
+ AI Cybersecurity Agent
5
+ Welcome to the AI Cybersecurity Agent, a Gradio-based application developed for the Gradio/Hugging Face Hackathon. This project enhances DSATP (Decentralized Swarm AI Threat Prediction), an open-source cybersecurity system, by integrating it with a powerful AI-driven "Security Analyst" persona. The agent leverages Large Language Models (LLMs), log parsing, and file scanning to detect and respond to threats in IoT and distributed networks, all through a sleek Gradio interface.
6
+ 🚀 Project Overview
7
+ The AI Cybersecurity Agent transforms DSATP into an interactive, user-friendly tool for real-time threat detection and response. Key features include:
8
+
9
+ A Gradio-powered chatbot interface for natural-language queries.
10
+ Integration with DSATP’s LLM-based threat analysis and YARA rule scanning.
11
+ Support for log file parsing and JSON-based threat severity outputs.
12
+ A planned multi-pane UI with network graphs and real-time threat dashboards.
13
+
14
+ This project showcases innovation, technical depth, and usability, addressing the pressing need for decentralized cybersecurity in IoT environments.
15
+ 🌟 Features
16
+
17
+ Chatbot Interface: Interact with an AI "Security Analyst" to analyze suspicious logs or alerts.
18
+ Threat Analysis: Uses DSATP’s mock threat detection (currently sentiment-based, soon LLM-driven) to assess risks.
19
+ JSON Outputs: Displays threat severity scores and remediation suggestions in a structured format.
20
+ MCP Compatibility: Exposes DSATP functions as MCP tools for agentic LLM integration.
21
+ Planned Enhancements (in progress):
22
+ File upload for log parsing and YARA-based malware scanning.
23
+ Network topology graph visualizing DSATP’s peer-to-peer swarm.
24
+ Real-time threat severity charts.
25
+ Dark-themed, high-tech cybersecurity UI.
26
+
27
+
28
+
29
+ 🛠️ Setup
30
+ Prerequisites
31
+
32
+ Python 3.10+
33
+ Git
34
+ Hugging Face account (for Spaces deployment)
35
+
36
+ Local Installation
37
+
38
+ Clone the repository:git clone https://huggingface.co/spaces/YOUR_USERNAME/ai-cybersecurity-agent
39
+ cd ai-cybersecurity-agent
40
+
41
+
42
+ Create and activate a virtual environment:python -m venv venv
43
+ source venv/bin/activate # On Windows: venv\Scripts\activate
44
+
45
+
46
+ Install dependencies:pip install -r requirements.txt
47
+
48
+
49
+ Run the app:python app.py
50
+
51
+
52
+ Open http://localhost:7860 in your browser to test the app.
53
+
54
+ Hugging Face Spaces
55
+ The app is deployed on Hugging Face Spaces at: YOUR_SPACE_URL (update with your Space URL after deployment). Simply visit the URL to interact with the chatbot and test threat detection.
56
+ 📖 Usage
57
+
58
+ Open the Gradio app (locally or on Hugging Face Spaces).
59
+ Enter a log message or alert in the textbox (e.g., “Critical error: Unauthorized access detected in server logs. System compromised!”).
60
+ Click Analyze to receive a threat analysis from the Security Analyst.
61
+ View the conversation in the chatbot and detailed results in the JSON output.
62
+
63
+ Example Inputs:
64
+
65
+ Positive: The system is running smoothly with no errors detected. All services are operational.
66
+ Negative: Critical error: Unauthorized access detected in server logs. System compromised!
67
+ Neutral: System log entry: User logged in at 14:30. No further details available.
68
+
69
+ 🔐 License
70
+ This project is licensed under the Apache License 2.0. See the LICENSE file for details.
71
+ 🤝 Contributing
72
+ We welcome contributions! Please:
73
+
74
+ Fork the repository.
75
+ Create a feature branch (git checkout -b feature-name).
76
+ Commit changes (git commit -m 'Add feature').
77
+ Push to the branch (git push origin feature-name).
78
+ Open a Pull Request.
79
+
80
+ For issues or suggestions, open an issue on the Space repository.
81
+ 🙌 Acknowledgments
82
+
83
+ DSATP for the open-source cybersecurity framework.
84
+ Hugging Face for hosting and Gradio for the intuitive UI framework.
85
+ The Gradio/Hugging Face Hackathon for inspiring this project.
86
+
87
+ 📬 Contact
88
+ For questions or feedback, reach out via the Hugging Face Space or open an issue.
89
+
90
+ Happy hacking, and stay secure! 🔒
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from textblob import TextBlob
3
+
4
+ # Placeholder DSATP function
5
+ def mock_dsatp_scan(text: str) -> dict:
6
+ """Mock vulnerability scan using sentiment analysis as a placeholder."""
7
+ blob = TextBlob(text)
8
+ sentiment = blob.sentiment
9
+ return {
10
+ "vulnerability_score": round(sentiment.polarity, 2),
11
+ "details": "Positive sentiment suggests low risk; negative suggests high risk."
12
+ }
13
+
14
+ # Chatbot function
15
+ def chatbot_response(user_input, history):
16
+ """Basic chatbot response with mock DSATP integration."""
17
+ if history is None:
18
+ history = [] # Initialize history if None
19
+ scan_result = mock_dsatp_scan(user_input)
20
+ response = f"Security Analyst: Analyzed input. Vulnerability score: {scan_result['vulnerability_score']}. Details: {scan_result['details']}"
21
+ # Append new message tuple to history
22
+ updated_history = history + [(user_input, response)]
23
+ return updated_history, scan_result # Return updated history and scan_result
24
+
25
+ # Gradio interface
26
+ with gr.Blocks() as demo:
27
+ gr.Markdown("# AI Cybersecurity Agent")
28
+ with gr.Row():
29
+ with gr.Column():
30
+ chatbot = gr.Chatbot(label="Security Analyst Chat")
31
+ user_input = gr.Textbox(placeholder="Enter text to analyze (e.g., log data)...")
32
+ submit_btn = gr.Button("Analyze")
33
+ with gr.Column():
34
+ gr.Markdown("### Placeholder for Network Graph and Charts")
35
+ output_json = gr.JSON(label="Scan Results")
36
+
37
+ submit_btn.click(
38
+ fn=chatbot_response,
39
+ inputs=[user_input, chatbot],
40
+ outputs=[chatbot, output_json]
41
+ )
42
+
43
+ # Launch the app with MCP server
44
+ if __name__ == "__main__":
45
+ demo.launch(mcp_server=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]>=4.0.0
2
+ textblob