File size: 3,910 Bytes
4801adf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
"""
Check installation of all required dependencies for Bandit MCP and Detect Secrets MCP
"""

import sys
import subprocess

def check_package(package_name, import_name=None):
    """Checks package installation"""
    if import_name is None:
        import_name = package_name
    
    try:
        __import__(import_name)
        print(f"βœ… {package_name} - installed")
        return True
    except ImportError:
        print(f"❌ {package_name} - NOT installed")
        return False

def check_command(command):
    """Checks command availability in system"""
    try:
        result = subprocess.run([command, "--version"], 
                              capture_output=True, text=True)
        if result.returncode == 0:
            print(f"βœ… {command} - available")
            return True
        else:
            print(f"❌ {command} - unavailable")
            return False
    except FileNotFoundError:
        print(f"❌ {command} - not found")
        return False

def main():
    print("πŸ”’ Checking MCP Dependencies")
    print("=" * 50)
    
    all_good = True
    
    # Check Python packages
    print("\nπŸ“¦ Python packages:")
    packages = [
        ("gradio", "gradio"),
        ("bandit", "bandit"),
        ("smolagents", "smolagents"),
        ("detect_secrets", "detect_secrets")
    ]
    
    for package, import_name in packages:
        if not check_package(package, import_name):
            all_good = False
    
    # Check commands
    print("\nπŸ”§ System commands:")
    commands = ["bandit", "npx", "detect-secrets"]
    
    for command in commands:
        if not check_command(command):
            all_good = False
    
    # Check specific bandit capabilities
    print("\n🎯 Bandit capabilities:")
    try:
        result = subprocess.run(["bandit", "--help"], 
                              capture_output=True, text=True)
        if "-f json" in result.stdout:
            print("βœ… JSON format - supported")
        else:
            print("❌ JSON format - not supported")
            
        if "-b" in result.stdout:
            print("βœ… Baseline - supported")
        else:
            print("❌ Baseline - not supported")
            
        if "-p" in result.stdout:
            print("βœ… Profiles - supported")
        else:
            print("❌ Profiles - not supported")
            
    except Exception as e:
        print(f"❌ Error checking Bandit: {e}")
        all_good = False
    
    # Check specific detect-secrets capabilities
    print("\nπŸ” Detect Secrets capabilities:")
    try:
        result = subprocess.run(["detect-secrets", "scan", "--help"], 
                              capture_output=True, text=True)
        if "--baseline" in result.stdout:
            print("βœ… Baseline - supported")
        else:
            print("❌ Baseline - not supported")
            
        if "--base64-limit" in result.stdout:
            print("βœ… Base64 entropy - supported")
        else:
            print("❌ Base64 entropy - not supported")
            
        if "--hex-limit" in result.stdout:
            print("βœ… Hex entropy - supported")
        else:
            print("❌ Hex entropy - not supported")
            
    except Exception as e:
        print(f"❌ Error checking Detect Secrets: {e}")
        all_good = False
    
    print("\n" + "=" * 50)
    if all_good:
        print("πŸŽ‰ All dependencies are installed correctly!")
        print("πŸ’‘ Now you can run:")
        print("   - python app.py (for Bandit MCP)")
        print("   - python detect_secrets_mcp.py (for Detect Secrets MCP)")
    else:
        print("⚠️  Some dependencies are missing.")
        print("πŸ’‘ Install them with: pip install -r requirements.txt")
        print("πŸ’‘ For npm dependencies: npm install -g npx")
        
    return all_good

if __name__ == "__main__":
    main()