File size: 2,680 Bytes
d8a3b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
"""

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...")
        # Create basic .env file
        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)
    
    # Check dependencies
    if not check_dependencies():
        sys.exit(1)
    
    # Check configuration
    check_config()
    
    # Create directories
    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:
        # Import and run the Flask app
        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()