|
|
|
|
|
"""
|
|
|
Startup script for the Threat Intelligence Assistant
|
|
|
"""
|
|
|
import os
|
|
|
import sys
|
|
|
import subprocess
|
|
|
import time
|
|
|
from pathlib import Path
|
|
|
|
|
|
def check_dependencies():
|
|
|
"""Check if required dependencies are installed"""
|
|
|
try:
|
|
|
import flask
|
|
|
import requests
|
|
|
import sklearn
|
|
|
import numpy
|
|
|
print("β
All required dependencies are installed")
|
|
|
return True
|
|
|
except ImportError as e:
|
|
|
print(f"β Missing dependency: {e}")
|
|
|
print("Please run: pip install -r requirements.txt")
|
|
|
return False
|
|
|
|
|
|
def check_config():
|
|
|
"""Check if configuration is set up"""
|
|
|
env_file = Path('.env')
|
|
|
if not env_file.exists():
|
|
|
print("β οΈ .env file not found. Creating from template...")
|
|
|
|
|
|
env_content = """# Threat Intelligence Assistant Configuration
|
|
|
ALIENVAULT_API_KEY=your_alienvault_otx_api_key_here
|
|
|
ABUSEIPDB_API_KEY=your_abuseipdb_api_key_here
|
|
|
OPENAI_API_KEY=your_openai_api_key_here
|
|
|
SECRET_KEY=dev-secret-key-change-in-production
|
|
|
FLASK_ENV=development
|
|
|
FLASK_DEBUG=True
|
|
|
"""
|
|
|
with open('.env', 'w') as f:
|
|
|
f.write(env_content)
|
|
|
print("β
Created .env file - Please update with your API keys")
|
|
|
else:
|
|
|
print("β
Configuration file found")
|
|
|
|
|
|
return True
|
|
|
|
|
|
def create_directories():
|
|
|
"""Create necessary directories"""
|
|
|
directories = ['templates', 'static', 'models', 'logs']
|
|
|
for directory in directories:
|
|
|
Path(directory).mkdir(exist_ok=True)
|
|
|
print("β
Created necessary directories")
|
|
|
|
|
|
def main():
|
|
|
"""Main startup function"""
|
|
|
print("π Starting Threat Intelligence Assistant")
|
|
|
print("=" * 50)
|
|
|
|
|
|
|
|
|
if not check_dependencies():
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
check_config()
|
|
|
|
|
|
|
|
|
create_directories()
|
|
|
|
|
|
print("\nπ§ Starting the application...")
|
|
|
print("π± Web interface will be available at: http://localhost:5000")
|
|
|
print("π API endpoint: http://localhost:5000/analyze")
|
|
|
print("β€οΈ Health check: http://localhost:5000/health")
|
|
|
print("\nπ‘ Tip: Press Ctrl+C to stop the application")
|
|
|
print("=" * 50)
|
|
|
|
|
|
try:
|
|
|
|
|
|
from app import app
|
|
|
app.run(debug=True, host='0.0.0.0', port=5000)
|
|
|
except KeyboardInterrupt:
|
|
|
print("\nπ Application stopped by user")
|
|
|
except Exception as e:
|
|
|
print(f"\nβ Error starting application: {str(e)}")
|
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|
|
|
|
|
|
|
|
|
|