VulnBuster / test_dependencies.py
zjkarina's picture
Upload 21 files
4801adf verified
#!/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()