Spaces:
Sleeping
Sleeping
| #!/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() |