Spaces:
Running
Running
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() |