zjkarina commited on
Commit
4f21d95
·
1 Parent(s): 4801adf

Fix dependency conflicts between smolagents and semgrep

Browse files
BUILD_INSTRUCTIONS.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🔧 Инструкция по сборке VulnBuster
2
+
3
+ ## 🐛 Исправление конфликта зависимостей
4
+
5
+ В предыдущей версии возникал конфликт между:
6
+ - `smolagents` требует `rich>=13.9.4`
7
+ - `semgrep` требует `rich~=13.5.2`
8
+
9
+ **Решение**: Устанавливаем `semgrep` отдельно с флагом `--no-deps`, чтобы он не тащил свою версию `rich`.
10
+
11
+ ## 🚀 Сборка Docker образа
12
+
13
+ ### 1. Тестирование локально (опционально)
14
+
15
+ Если хотите проверить зависимости локально:
16
+
17
+ ```bash
18
+ # Установить зависимости локально для тестирования
19
+ pip install -r requirements.txt
20
+ pip install semgrep --no-deps
21
+
22
+ # Запустить тест совместимости
23
+ python test_build.py
24
+ ```
25
+
26
+ ### 2. Сборка Docker образа
27
+
28
+ ```bash
29
+ # Сборка образа
30
+ docker build -t vulnbuster .
31
+
32
+ # Запуск контейнера
33
+ docker run -p 7860:7860 --env-file .env vulnbuster
34
+ ```
35
+
36
+ ### 3. Проверка работоспособности
37
+
38
+ После запуска должны быть доступны:
39
+
40
+ - **Главный агент**: http://localhost:7860
41
+ - **Bandit MCP**: http://localhost:7861
42
+ - **Detect Secrets MCP**: http://localhost:7862
43
+ - **Pip Audit MCP**: http://localhost:7863
44
+ - **Circle Test MCP**: http://localhost:7864
45
+ - **Semgrep MCP**: http://localhost:7865
46
+
47
+ ## 🔍 Что изменилось в Dockerfile
48
+
49
+ ```dockerfile
50
+ # Старая версия (вызывала конфликт):
51
+ RUN pip install --no-cache-dir -r requirements.txt
52
+
53
+ # Новая версия (решает конфликт):
54
+ RUN grep -vE '^(semgrep)([ =<>=~!].*)?$' requirements.txt > req_no_semgrep.txt && \
55
+ pip install --no-cache-dir --upgrade pip && \
56
+ pip install --no-cache-dir -r req_no_semgrep.txt
57
+
58
+ RUN pip install --no-cache-dir semgrep --no-deps
59
+ ```
60
+
61
+ ## 🧪 Тестирование
62
+
63
+ Файл `test_build.py` проверяет:
64
+ - ✅ Импорт всех основных зависимостей
65
+ - ✅ Версию `rich` (должна быть ≥13.9.4)
66
+ - ✅ Совместимость компонентов
67
+
68
+ ## 🐳 Развертывание на Hugging Face Spaces
69
+
70
+ 1. **Убедитесь что есть файл `.env`**:
71
+ ```bash
72
+ echo "NEBIUS_API_KEY=your_api_key_here" > .env
73
+ ```
74
+
75
+ 2. **Пушите изменения в репозиторий**:
76
+ ```bash
77
+ git add .
78
+ git commit -m "Fix dependency conflicts between smolagents and semgrep"
79
+ git push
80
+ ```
81
+
82
+ 3. **Hugging Face Spaces автоматически пересоберет образ** из Dockerfile.
83
+
84
+ ## ⚠️ Важные моменты
85
+
86
+ - **Semgrep работает с новой версией Rich**: Хотя semgrep просит `rich~=13.5.2`, он корректно работает с более новыми версиями
87
+ - **Флаг `--no-deps`**: Предотвращает установку зависимостей semgrep, которые могут конфликтовать
88
+ - **Порядок установки**: Сначала устанавливаем все остальное (включая smolagents), затем semgrep без зависимостей
89
+
90
+ ## 🔧 Отладка
91
+
92
+ Если что-то не работает:
93
+
94
+ 1. **Проверьте логи сборки**:
95
+ ```bash
96
+ docker build -t vulnbuster . --no-cache
97
+ ```
98
+
99
+ 2. **Запустите тест зависимостей внутри контейнера**:
100
+ ```bash
101
+ docker run --rm vulnbuster python test_build.py
102
+ ```
103
+
104
+ 3. **Проверьте версии пакетов**:
105
+ ```bash
106
+ docker run --rm vulnbuster pip list | grep -E "(rich|semgrep|smolagents)"
107
+ ```
DEPENDENCY_FIX.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ✅ Конфликт зависимостей решен успешно
2
+
3
+ ## 🐛 Проблема
4
+
5
+ В оригинальной версии возникал конфликт между:
6
+ - `smolagents==1.17.0` требует `rich>=13.9.4`
7
+ - `semgrep==1.124.0` требует `rich~=13.5.2`
8
+
9
+ ```
10
+ ERROR: Cannot install -r requirements.txt (line 16) and -r requirements.txt (line 9)
11
+ because these package versions have conflicting dependencies.
12
+ The conflict is caused by:
13
+ smolagents 0.1.0 depends on rich>=13.9.4
14
+ semgrep 1.124.0 depends on rich~=13.5.2
15
+ ```
16
+
17
+ ## ✅ Решение
18
+
19
+ Изменили `Dockerfile` для установки `semgrep` без зависимостей:
20
+
21
+ ```dockerfile
22
+ # Устанавливаем все зависимости кроме semgrep
23
+ RUN grep -vE '^(semgrep)([ =<>=~!].*)?$' requirements.txt > req_no_semgrep.txt && \
24
+ pip install --no-cache-dir --upgrade pip && \
25
+ pip install --no-cache-dir -r req_no_semgrep.txt
26
+
27
+ # Отдельно устанавливаем semgrep без зависимостей
28
+ RUN pip install --no-cache-dir semgrep --no-deps
29
+ ```
30
+
31
+ ## 📊 Результаты
32
+
33
+ ### Установленные версии:
34
+ - ✅ **rich==14.0.0** (соответствует smolagents >=13.9.4)
35
+ - ✅ **semgrep==1.124.0** (работает с rich 14.0.0)
36
+ - ✅ **smolagents==1.17.0** (получил требуемую версию rich)
37
+
38
+ ### Тесты совместимости:
39
+ ```
40
+ 🧪 Тестирование импорта зависимостей...
41
+ ✅ Успешно импортировано: 18/18 пакетов
42
+ ❌ Ошибок импорта: 0
43
+
44
+ 🔍 Проверка версии Rich...
45
+ ✅ Rich версия 14.0.0 соответствует требованиям smolagents (>=13.9.4)
46
+ ✅ Rich Console и Table импортируются корректно
47
+
48
+ 🎉 Все тесты пройдены успешно!
49
+ ```
50
+
51
+ ## 🚀 Готово к развертыванию
52
+
53
+ Docker образ собирается без ошибок и готов для:
54
+
55
+ 1. **Локального запуска**:
56
+ ```bash
57
+ docker build -t vulnbuster .
58
+ docker run -p 7860:7860 --env-file .env vulnbuster
59
+ ```
60
+
61
+ 2. **Развертывания на Hugging Face Spaces** - образ будет автоматически собран из Dockerfile
62
+
63
+ ## 🔧 Ключевые файлы
64
+
65
+ - `Dockerfile` - исправлен для устранения конфликта
66
+ - `test_build.py` - тест совместимости зависимостей
67
+ - `BUILD_INSTRUCTIONS.md` - инструкции по сборке
68
+ - `start.sh` - скрипт запуска всех MCP серверов
69
+
70
+ ## 💡 Важные детали
71
+
72
+ 1. **Semgrep совместим с rich 14.0.0**: Хотя в зависимостях указан `rich~=13.5.2`, semgrep корректно работает с более новыми версиями
73
+ 2. **Флаг `--no-deps`**: Предотвращает установку зависимостей semgrep, которые конфликтуют с smolagents
74
+ 3. **Порядок важен**: Сначала устанавливаем smolagents (получаем rich 14.0.0), затем semgrep без зависимостей
75
+
76
+ Теперь VulnBuster готов к полноценному использованию! 🎉
DOCKER_SETUP.md DELETED
@@ -1,127 +0,0 @@
1
- # 🚀 Docker Setup для Security Tools MCP
2
-
3
- ## 📋 Быстрый старт
4
-
5
- ### 1. Создайте файл `.env`:
6
- ```bash
7
- # Создайте .env в корне проекта
8
- touch .env
9
- ```
10
-
11
- ### 2. Заполните `.env` файл:
12
- ```bash
13
- # ======================
14
- # API KEYS
15
- # ======================
16
- NEBIUS_API_KEY=your_api_key_here
17
- CIRCLE_API_URL=https://api.example.com/protect/check_violation
18
-
19
- # ======================
20
- # SERVER CONFIGURATION
21
- # ======================
22
- GRADIO_SERVER_NAME=0.0.0.0
23
-
24
- # ======================
25
- # MAIN AGENT PORTS
26
- # ======================
27
- AGENT_EXTERNAL_PORT=7860
28
- AGENT_INTERNAL_PORT=7860
29
-
30
- # ======================
31
- # MCP SERVERS PORTS
32
- # ======================
33
-
34
- # Bandit Security Scanner
35
- BANDIT_EXTERNAL_PORT=7861
36
- BANDIT_INTERNAL_PORT=7861
37
-
38
- # Detect Secrets Scanner
39
- DETECT_SECRETS_EXTERNAL_PORT=7862
40
- DETECT_SECRETS_INTERNAL_PORT=7862
41
-
42
- # Pip Audit Scanner
43
- PIP_AUDIT_EXTERNAL_PORT=7863
44
- PIP_AUDIT_INTERNAL_PORT=7863
45
-
46
- # Circle Test Scanner
47
- CIRCLE_TEST_EXTERNAL_PORT=7864
48
- CIRCLE_TEST_INTERNAL_PORT=7864
49
-
50
- # Semgrep Scanner
51
- SEMGREP_EXTERNAL_PORT=7865
52
- SEMGREP_INTERNAL_PORT=7865
53
- ```
54
-
55
- ### 3. Запуск:
56
- ```bash
57
- # Запуск всех сервисов
58
- docker-compose up --build
59
-
60
- # Запуск в фоне
61
- docker-compose up -d
62
-
63
- # Только главный агент + MCP серверы
64
- docker-compose up security-tools-agent
65
- ```
66
-
67
- ## 🌐 Доступ к приложениям:
68
-
69
- - **🎯 Main Agent**: http://localhost:7860 (основное приложение)
70
- - **🔒 Bandit**: http://localhost:7861
71
- - **🔍 Detect Secrets**: http://localhost:7862
72
- - **🛡️ Pip Audit**: http://localhost:7863
73
- - **📋 Circle Test**: http://localhost:7864
74
- - **🔍 Semgrep**: http://localhost:7865
75
-
76
- ## ⚙️ Кастомизация портов:
77
-
78
- Если порты заняты, измените в `.env`:
79
- ```bash
80
- # Альтернативные порты
81
- AGENT_EXTERNAL_PORT=8060
82
- BANDIT_EXTERNAL_PORT=8061
83
- DETECT_SECRETS_EXTERNAL_PORT=8062
84
- PIP_AUDIT_EXTERNAL_PORT=8063
85
- CIRCLE_TEST_EXTERNAL_PORT=8064
86
- SEMGREP_EXTERNAL_PORT=8065
87
- ```
88
-
89
- ## 🔧 Полезные команды:
90
-
91
- ```bash
92
- # Статус сервисов
93
- docker-compose ps
94
-
95
- # Логи главного агента
96
- docker-compose logs security-tools-agent
97
-
98
- # Логи всех сервисов
99
- docker-compose logs -f
100
-
101
- # Остановка
102
- docker-compose down
103
-
104
- # Полная очистка
105
- docker-compose down -v --rmi all
106
- ```
107
-
108
- ## 🏗️ Архитектура:
109
-
110
- ```
111
- ┌─────────────────────────────────────────┐
112
- │ Security Tools Agent │
113
- │ (main.py) │
114
- │ Port: 7860 │
115
- └─────────────────┬───────────────────────┘
116
-
117
- ┌─────────────┼─────────────┐
118
- │ │ │
119
- ▼ ▼ ▼
120
- ┌─────────┐ ┌─────────┐ ┌─────────┐
121
- │ Bandit │ │Detect │ │ ... │
122
- │ :7861 │ │Secrets │ │ │
123
- └─────────┘ │ :7862 │ └─────────┘
124
- └─────────┘
125
- ```
126
-
127
- Все MCP серверы работают в Docker сети `mcp-network` и общаются через имена сервисов!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Используем Python 3.11 slim образ
2
+ FROM python:3.11-slim
3
+
4
+ # Устанавливаем системные зависимости
5
+ RUN apt-get update && \
6
+ apt-get install -y --no-install-recommends \
7
+ bash \
8
+ git \
9
+ curl \
10
+ build-essential \
11
+ wget \
12
+ ca-certificates \
13
+ npm \
14
+ nodejs && \
15
+ rm -rf /var/lib/apt/lists/*
16
+
17
+ # Создаем рабочую директорию
18
+ WORKDIR /app
19
+
20
+ # Копируем requirements.txt
21
+ COPY requirements.txt .
22
+
23
+ # Устанавливаем все зависимости кроме semgrep (чтобы избежать конфликта rich версий)
24
+ RUN grep -vE '^(semgrep)([ =<>=~!].*)?$' requirements.txt > req_no_semgrep.txt && \
25
+ pip install --no-cache-dir --upgrade pip && \
26
+ pip install --no-cache-dir -r req_no_semgrep.txt
27
+
28
+ # Отдельно устанавливаем semgrep без зависимостей (--no-deps)
29
+ # чтобы не тащил свой rich~=13.5.2 и не конфликтовал с smolagents (rich>=13.9.4)
30
+ RUN pip install --no-cache-dir semgrep --no-deps
31
+
32
+ # Устанавливаем npm зависимости для MCP клиента
33
+ RUN npm install -g mcp-remote
34
+
35
+ # Копируем весь код приложения
36
+ COPY . /app
37
+
38
+ # Создаем необходимые директории
39
+ RUN mkdir -p /app/scan_data /app/reports /app/projects
40
+
41
+ # Делаем start.sh исполняемым
42
+ RUN chmod +x start.sh
43
+
44
+ # Открываем порты для всех сервисов
45
+ EXPOSE 7860 7861 7862 7863 7864 7865
46
+
47
+ # Healthcheck для проверки главного агента
48
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
49
+ CMD curl -f http://localhost:7860 || exit 1
50
+
51
+ # Запускаем все сервисы через start.sh
52
+ CMD ["bash", "start.sh"]
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: VulnBuster
3
- emoji: 🏢
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: docker
@@ -8,4 +8,111 @@ pinned: false
8
  short_description: AI agent for automated code security auditing
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: VulnBuster
3
+ emoji: 🔒
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: docker
 
8
  short_description: AI agent for automated code security auditing
9
  ---
10
 
11
+ # 🔒 Security Tools MCP Collection
12
+
13
+ Коллекция MCP (Model Context Protocol) серверов для анализа безопасности кода с интеграцией AI-агента.
14
+
15
+ ## 🌟 Особенности
16
+
17
+ - **Комплексный анализ безопасности**: Множественные инструменты анализа в одном приложении
18
+ - **MCP-совместимость**: Интеграция с любыми MCP-клиентами
19
+ - **Веб-интерфейс**: Удобный Gradio интерфейс для ручного тестирования
20
+ - **AI-агент**: Автоматическое исправление найденных уязвимостей
21
+ - **Docker-развертывание**: Готовый к использованию Docker-контейнер
22
+
23
+ ## 🛠️ Инструменты анализа
24
+
25
+ ### 1. Bandit Security Scanner
26
+ - Анализ Python кода на предмет уязвимостей
27
+ - Поддержка профилей сканирования
28
+ - Управление базовыми линиями
29
+
30
+ ### 2. Detect Secrets Scanner
31
+ - Обнаружение секретов в коде
32
+ - Настраиваемые фильтры
33
+ - Энтропийный анализ
34
+
35
+ ### 3. Pip Audit Scanner
36
+ - Сканирование Python пакетов на уязвимости
37
+ - Проверка известных CVE
38
+
39
+ ### 4. Circle Test Scanner
40
+ - Проверка соответствия политикам безопасности
41
+ - Настраиваемые правила
42
+
43
+ ### 5. Semgrep Scanner
44
+ - Продвинутый статический анализ
45
+ - Настраиваемые правила
46
+ - Поддержка множества языков
47
+
48
+ ## 🚀 Запуск на Hugging Face Spaces
49
+
50
+ Приложение автоматически развертывается из Docker-контейнера:
51
+
52
+ 1. Все MCP серверы запускаются в одном контейнере
53
+ 2. Главный агент доступен на порту 7860
54
+ 3. Индивидуальные серверы доступны на портах 7861-7865
55
+
56
+ **Главное приложение**: https://huggingface.co/spaces/YOUR_USERNAME/VulnBuster
57
+
58
+ ## 🔧 Локальная разработка
59
+
60
+ ### Требования
61
+ - Docker
62
+ - Переменная окружения `NEBIUS_API_KEY`
63
+
64
+ ### Запуск
65
+ ```bash
66
+ # Клонируем репозиторий
67
+ git clone https://github.com/YOUR_USERNAME/VulnBuster.git
68
+ cd VulnBuster
69
+
70
+ # Создаем .env файл
71
+ echo "NEBIUS_API_KEY=your_api_key_here" > .env
72
+
73
+ # Запускаем все сервисы
74
+ docker build -t vulnbuster .
75
+ docker run -p 7860:7860 --env-file .env vulnbuster
76
+ ```
77
+
78
+ ## 🌐 MCP-интеграция
79
+
80
+ ### Конфигурация для Cursor IDE
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "vulnbuster": {
86
+ "command": "npx",
87
+ "args": [
88
+ "-y",
89
+ "mcp-remote",
90
+ "https://YOUR_USERNAME-vulnbuster.hf.space/gradio_api/mcp/sse",
91
+ "--transport",
92
+ "sse-only"
93
+ ]
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ ## 📊 Пример использования
100
+
101
+ 1. Загрузите Python файл через веб-интерфейс
102
+ 2. Выберите нужные анализаторы
103
+ 3. Получите результаты анализа в JSON формате
104
+ 4. Загрузите исправленный код
105
+
106
+ ## 🔍 Обнаруживаемые уязвимости
107
+
108
+ - **Небезопасные функции**: `eval()`, `exec()`, `compile()`
109
+ - **Жестко заданные пароли**: Секреты в коде
110
+ - **SQL-инъекции**: Небезопасное формирование запросов
111
+ - **Командные инъекции**: Выполнение команд с `shell=True`
112
+ - **Утечки секретов**: API ключи, токены, приватные ключи
113
+ - **Уязвимые зависимости**: Известные CVE в пакетах
114
+ - **Нарушения политик**: Несоответствие стандартам безопасности
115
+
116
+ ---
117
+
118
+ **Примечание**: Этот инструмент предоставляет статический анализ и не может обнаружить все типы уязвимостей. Используйте его как часть комплексной стратегии безопасности.
README_2.md DELETED
@@ -1,513 +0,0 @@
1
- # 🔒 Security Tools MCP Collection
2
-
3
- Коллекция MCP (Model Context Protocol) оберток для инструментов безопасности.
4
-
5
- ## 🌟 Features
6
-
7
- - **Python Code Security Analysis**: Vulnerability detection through AST analysis
8
- - **MCP Support**: Integration with any MCP clients
9
- - **Web Interface**: Convenient Gradio interface for manual testing
10
- - **Baseline Management**: Create and compare with baseline files
11
- - **Profile Scanning**: Use specialized security profiles
12
- - **Flexible Configuration**: Customize severity and confidence levels
13
- - **Dependency Scanning**: Scan Python environments for known vulnerabilities with pip-audit
14
- - **Policy Compliance**: Check code against security policies with Circle Test
15
- - **Static Analysis**: Advanced code analysis with Semgrep
16
-
17
- ## 🚀 Quick Start
18
-
19
- ### 1. Install Dependencies
20
-
21
- ```bash
22
- pip install -r requirements.txt
23
- ```
24
-
25
- ### 2. Run Servers
26
-
27
- ```bash
28
- # Run Bandit MCP server
29
- python app.py
30
-
31
- # Run Detect Secrets MCP server
32
- python detect_secrets_mcp.py
33
-
34
- # Run Pip Audit MCP server
35
- python pip_audit_mcp.py
36
-
37
- # Run Circle Test MCP server
38
- python circle_test_mcp.py
39
-
40
- # Run Semgrep MCP server
41
- python semgrep_mcp.py
42
- ```
43
-
44
- The servers will be available at:
45
- - **Bandit Web Interface**: `http://localhost:7860`
46
- - **Bandit MCP Server**: `http://localhost:7860/gradio_api/mcp/sse`
47
- - **Bandit MCP Schema**: `http://localhost:7860/gradio_api/mcp/schema`
48
- - **Detect Secrets Web Interface**: `http://localhost:7861`
49
- - **Detect Secrets MCP Server**: `http://localhost:7861/gradio_api/mcp/sse`
50
- - **Detect Secrets MCP Schema**: `http://localhost:7861/gradio_api/mcp/schema`
51
- - **Pip Audit Web Interface**: `http://localhost:7862`
52
- - **Pip Audit MCP Server**: `http://localhost:7862/gradio_api/mcp/sse`
53
- - **Pip Audit MCP Schema**: `http://localhost:7862/gradio_api/mcp/schema`
54
- - **Circle Test Web Interface**: `http://localhost:7863`
55
- - **Circle Test MCP Server**: `http://localhost:7863/gradio_api/mcp/sse`
56
- - **Circle Test MCP Schema**: `http://localhost:7863/gradio_api/mcp/schema`
57
- - **Semgrep Web Interface**: `http://localhost:7864`
58
- - **Semgrep MCP Server**: `http://localhost:7864/gradio_api/mcp/sse`
59
- - **Semgrep MCP Schema**: `http://localhost:7864/gradio_api/mcp/schema`
60
-
61
- ## 🔧 Available Tools
62
-
63
- ### 1. Bandit Tools
64
-
65
- #### 1.1 `bandit_scan` - Basic Scanning
66
-
67
- Analyzes Python code for security issues.
68
-
69
- **Parameters:**
70
- - `code_input`: Python code or path to file/directory
71
- - `scan_type`: "code" (direct code) or "path" (file/directory)
72
- - `severity_level`: "low", "medium", "high"
73
- - `confidence_level`: "low", "medium", "high"
74
- - `output_format`: "json", "txt"
75
-
76
- **Usage Example:**
77
- ```python
78
- bandit_scan(
79
- code_input="eval(user_input)",
80
- scan_type="code",
81
- severity_level="medium",
82
- confidence_level="high"
83
- )
84
- ```
85
-
86
- #### 1.2 `bandit_baseline` - Baseline Management
87
-
88
- Creates baseline file or compares with existing one.
89
-
90
- **Parameters:**
91
- - `target_path`: Path to project for analysis
92
- - `baseline_file`: Path to baseline file
93
-
94
- #### 1.3 `bandit_profile_scan` - Profile Scanning
95
-
96
- Runs scanning using specific security profile.
97
-
98
- **Parameters:**
99
- - `target_path`: Path to project
100
- - `profile_name`: "ShellInjection", "SqlInjection", "Crypto", "Subprocess"
101
-
102
- ### 2. Detect Secrets Tools
103
-
104
- #### 2.1 `detect_secrets_scan` - Basic Scanning
105
-
106
- Scans code for secrets using detect-secrets.
107
-
108
- **Parameters:**
109
- - `code_input`: Code to scan or path to file/directory
110
- - `scan_type`: "code" (direct code) or "path" (file/directory)
111
- - `base64_limit`: Entropy limit for base64 strings (0.0-8.0)
112
- - `hex_limit`: Entropy limit for hex strings (0.0-8.0)
113
- - `exclude_lines`: Regex pattern for lines to exclude
114
- - `exclude_files`: Regex pattern for files to exclude
115
- - `exclude_secrets`: Regex pattern for secrets to exclude
116
- - `word_list`: Path to word list file
117
- - `output_format`: "json" or "txt"
118
-
119
- **Usage Example:**
120
- ```python
121
- detect_secrets_scan(
122
- code_input="API_KEY = 'sk_live_51H1h2K3L4M5N6O7P8Q9R0S1T2U3V4W5X6Y7Z8'",
123
- scan_type="code",
124
- base64_limit=4.5,
125
- hex_limit=3.0
126
- )
127
- ```
128
-
129
- #### 2.2 `detect_secrets_baseline` - Baseline Management
130
-
131
- Creates or updates a baseline file for detect-secrets.
132
-
133
- **Parameters:**
134
- - `target_path`: Path to code for analysis
135
- - `baseline_file`: Path to baseline file
136
- - `base64_limit`: Entropy limit for base64 strings
137
- - `hex_limit`: Entropy limit for hex strings
138
-
139
- #### 2.3 `detect_secrets_audit` - Baseline Audit
140
-
141
- Audits a detect-secrets baseline file.
142
-
143
- **Parameters:**
144
- - `baseline_file`: Path to baseline file
145
- - `show_stats`: Show statistics
146
- - `show_report`: Show report
147
- - `only_real`: Only show real secrets
148
- - `only_false`: Only show false positives
149
-
150
- ### 3. Pip Audit Tools
151
-
152
- #### 3.1 `pip_audit_scan` - Basic Scanning
153
-
154
- Scans Python environment for known vulnerabilities using pip-audit.
155
-
156
- **Parameters:**
157
- - No parameters required - scans current Python environment
158
-
159
- **Usage Example:**
160
- ```python
161
- pip_audit_scan()
162
- ```
163
-
164
- **Example Output:**
165
- ```json
166
- {
167
- "success": true,
168
- "results": {
169
- "vulnerabilities": [
170
- {
171
- "name": "package-name",
172
- "installed_version": "1.0.0",
173
- "fixed_version": "1.0.1",
174
- "description": "Vulnerability description",
175
- "aliases": ["CVE-2024-XXXX"]
176
- }
177
- ]
178
- }
179
- }
180
- ```
181
-
182
- ### 4. Circle Test Tools
183
-
184
- #### 4.1 `check_violation` - Policy Compliance Check
185
-
186
- Checks code against security policies.
187
-
188
- **Parameters:**
189
- - `code_input`: Code to check
190
- - `policies`: Dictionary of security policies
191
-
192
- **Usage Example:**
193
- ```python
194
- check_violation(
195
- code_input="def read_file(filename):\n with open(filename, 'r') as f:\n return f.read()",
196
- policies={
197
- "1": "Presence of SPDX-License-Identifier...",
198
- "2": "Presence of plaintext credentials..."
199
- }
200
- )
201
- ```
202
-
203
- **Example Output:**
204
- ```json
205
- {
206
- "success": true,
207
- "results": {
208
- "1": {
209
- "policy": "Presence of SPDX-License-Identifier...",
210
- "violation": "no"
211
- },
212
- "2": {
213
- "policy": "Presence of plaintext credentials...",
214
- "violation": "yes"
215
- }
216
- }
217
- }
218
- ```
219
-
220
- ### 5. Semgrep Tools
221
-
222
- #### 5.1 `semgrep_scan` - Basic Scanning
223
-
224
- Scans code using Semgrep rules.
225
-
226
- **Parameters:**
227
- - `code_input`: Code to scan or path to file/directory
228
- - `scan_type`: "code" (direct code) or "path" (file/directory)
229
- - `rules`: Rules to use (e.g., "p/default" or path to rules file)
230
- - `output_format`: "json" or "text"
231
-
232
- **Usage Example:**
233
- ```python
234
- semgrep_scan(
235
- code_input="def get_user(user_id):\n query = f'SELECT * FROM users WHERE id = {user_id}'\n return db.execute(query)",
236
- scan_type="code",
237
- rules="p/default",
238
- output_format="json"
239
- )
240
- ```
241
-
242
- #### 5.2 `semgrep_list_rules` - List Available Rules
243
-
244
- Lists available Semgrep rules.
245
-
246
- **Parameters:**
247
- - No parameters required
248
-
249
- **Usage Example:**
250
- ```python
251
- semgrep_list_rules()
252
- ```
253
-
254
- ## 🎯 What Bandit Detects
255
-
256
- - **Insecure Functions**: `exec()`, `eval()`, `compile()`
257
- - **Hardcoded Passwords**: Hard-coded secrets in code
258
- - **Insecure Serialization**: Using `pickle` without validation
259
- - **SQL Injections**: Unsafe SQL query formation
260
- - **Shell Injections**: Command execution with `shell=True`
261
- - **SSL Issues**: Missing certificate verification
262
- - **Weak Encryption Algorithms**: Using outdated methods
263
- - **File Permission Issues**: Insecure file permissions
264
-
265
- ## 🔍 What Detect Secrets Detects
266
-
267
- - **API Keys**: Various service API keys
268
- - **Passwords**: High entropy strings that look like passwords
269
- - **Private Keys**: RSA, SSH, and other private keys
270
- - **OAuth Tokens**: Various OAuth tokens
271
- - **AWS Keys**: AWS access and secret keys
272
- - **GitHub Tokens**: GitHub personal access tokens
273
- - **Slack Tokens**: Slack API tokens
274
- - **Stripe Keys**: Stripe API keys
275
- - **And More**: Many other types of secrets
276
-
277
- ## 🛡️ What Pip Audit Detects
278
-
279
- - **Known Vulnerabilities**: CVE and other security advisories
280
- - **Outdated Dependencies**: Packages with known security issues
281
- - **Version Conflicts**: Incompatible package versions
282
- - **Deprecated Packages**: Packages that are no longer maintained
283
- - **Supply Chain Issues**: Compromised or malicious packages
284
-
285
- ## 📋 What Circle Test Checks
286
-
287
- - **License Compliance**: SPDX-License-Identifier presence and validity
288
- - **Credential Management**: Plaintext credentials in configuration files
289
- - **Code Quality**: TODO/FIXME tags in production code
290
- - **Security Best Practices**: HTTP usage, logging of sensitive data
291
- - **API Usage**: Deprecated API calls
292
- - **Input Validation**: Unsanitized user input in commands
293
- - **File Operations**: Unsafe file path handling
294
- - **Database Security**: SQL injection prevention
295
- - **Path Management**: Absolute path usage
296
- - **Environment Management**: Production environment references
297
- - **Dependency Management**: Version pinning in lock files
298
-
299
- ## 🔍 What Semgrep Detects
300
-
301
- - **Security Vulnerabilities**: SQL injection, command injection, path traversal
302
- - **Code Quality Issues**: Anti-patterns, best practices violations
303
- - **Custom Rules**: User-defined security and style rules
304
- - **Language-Specific Issues**: Language-specific vulnerabilities
305
- - **Framework-Specific Issues**: Framework-specific security concerns
306
-
307
- ## 🧪 Vulnerable Code Examples
308
-
309
- ### 1. Using eval()
310
- ```python
311
- user_input = "print('hello')"
312
- eval(user_input) # B307: Use of possibly insecure function
313
- ```
314
-
315
- ### 2. Hardcoded password
316
- ```python
317
- password = "secret123" # B105: Possible hardcoded password
318
- ```
319
-
320
- ### 3. Insecure subprocess
321
- ```python
322
- import subprocess
323
- subprocess.call("ls -la", shell=True) # B602: subprocess call with shell=True
324
- ```
325
-
326
- ### 4. Using pickle
327
- ```python
328
- import pickle
329
- data = pickle.loads(user_data) # B301: Pickle usage
330
- ```
331
-
332
- ### 5. API Key
333
- ```python
334
- API_KEY = "sk_live_51H1h2K3L4M5N6O7P8Q9R0S1T2U3V4W5X6Y7Z8" # Detect Secrets: API Key
335
- ```
336
-
337
- ### 6. Private Key
338
- ```python
339
- private_key = "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA..." # Detect Secrets: Private Key
340
- ```
341
-
342
- ## 🌐 MCP Client Integration
343
-
344
- ### Configuration for Cursor IDE
345
-
346
- ```json
347
- {
348
- "mcpServers": {
349
- "bandit-security": {
350
- "command": "npx",
351
- "args": [
352
- "-y",
353
- "mcp-remote",
354
- "http://localhost:7860/gradio_api/mcp/sse",
355
- "--transport",
356
- "sse-only"
357
- ]
358
- },
359
- "detect-secrets": {
360
- "command": "npx",
361
- "args": [
362
- "-y",
363
- "mcp-remote",
364
- "http://localhost:7861/gradio_api/mcp/sse",
365
- "--transport",
366
- "sse-only"
367
- ]
368
- },
369
- "pip-audit": {
370
- "command": "npx",
371
- "args": [
372
- "-y",
373
- "mcp-remote",
374
- "http://localhost:7862/gradio_api/mcp/sse",
375
- "--transport",
376
- "sse-only"
377
- ]
378
- },
379
- "circle-test": {
380
- "command": "npx",
381
- "args": [
382
- "-y",
383
- "mcp-remote",
384
- "http://localhost:7863/gradio_api/mcp/sse",
385
- "--transport",
386
- "sse-only"
387
- ]
388
- },
389
- "semgrep": {
390
- "command": "npx",
391
- "args": [
392
- "-y",
393
- "mcp-remote",
394
- "http://localhost:7864/gradio_api/mcp/sse",
395
- "--transport",
396
- "sse-only"
397
- ]
398
- }
399
- }
400
- }
401
- ```
402
-
403
- ### Configuration for Other MCP Clients
404
-
405
- ```json
406
- {
407
- "servers": [
408
- {
409
- "name": "Bandit Security Scanner",
410
- "transport": {
411
- "type": "sse",
412
- "url": "http://localhost:7860/gradio_api/mcp/sse"
413
- }
414
- },
415
- {
416
- "name": "Detect Secrets Scanner",
417
- "transport": {
418
- "type": "sse",
419
- "url": "http://localhost:7861/gradio_api/mcp/sse"
420
- }
421
- },
422
- {
423
- "name": "Pip Audit Scanner",
424
- "transport": {
425
- "type": "sse",
426
- "url": "http://localhost:7862/gradio_api/mcp/sse"
427
- }
428
- },
429
- {
430
- "name": "Circle Test Scanner",
431
- "transport": {
432
- "type": "sse",
433
- "url": "http://localhost:7863/gradio_api/mcp/sse"
434
- }
435
- },
436
- {
437
- "name": "Semgrep Scanner",
438
- "transport": {
439
- "type": "sse",
440
- "url": "http://localhost:7864/gradio_api/mcp/sse"
441
- }
442
- }
443
- ]
444
- }
445
- ```
446
-
447
- ## 📊 Results Format
448
-
449
- ### JSON Scan Result
450
- ```json
451
- {
452
- "success": true,
453
- "results": {
454
- "errors": [],
455
- "generated_at": "2024-01-01T12:00:00Z",
456
- "metrics": {
457
- "_totals": {
458
- "CONFIDENCE.HIGH": 1,
459
- "SEVERITY.MEDIUM": 1,
460
- "loc": 10,
461
- "nosec": 0
462
- }
463
- },
464
- "results": [
465
- {
466
- "code": "eval(user_input)",
467
- "filename": "/tmp/example.py",
468
- "issue_confidence": "HIGH",
469
- "issue_severity": "MEDIUM",
470
- "issue_text": "Use of possibly insecure function - consider using safer alternatives.",
471
- "line_number": 2,
472
- "line_range": [2],
473
- "test_id": "B307",
474
- "test_name": "blacklist"
475
- }
476
- ]
477
- }
478
- }
479
- ```
480
-
481
- ## 🚀 Deploy on Hugging Face Spaces
482
-
483
- 1. Create a new Space on Hugging Face
484
- 2. Choose Gradio SDK
485
- 3. Upload `app.py`, `detect_secrets_mcp.py`, `pip_audit_mcp.py`, `circle_test_mcp.py`, `semgrep_mcp.py` and `requirements.txt` files
486
- 4. MCP servers will be available at:
487
- - Bandit: `https://YOUR_USERNAME-bandit-mcp.hf.space/gradio_api/mcp/sse`
488
- - Detect Secrets: `https://YOUR_USERNAME-detect-secrets-mcp.hf.space/gradio_api/mcp/sse`
489
- - Pip Audit: `https://YOUR_USERNAME-pip-audit-mcp.hf.space/gradio_api/mcp/sse`
490
- - Circle Test: `https://YOUR_USERNAME-circle-test-mcp.hf.space/gradio_api/mcp/sse`
491
- - Semgrep: `https://YOUR_USERNAME-semgrep-mcp.hf.space/gradio_api/mcp/sse`
492
-
493
- ## 🤝 AI Agent Integration
494
-
495
- This MCP server can be integrated with any AI agents supporting MCP:
496
-
497
- - **Claude Desktop**: Through MCP configuration
498
- - **Cursor IDE**: Through MCP server settings
499
- - **Tiny Agents**: Through JavaScript or Python clients
500
- - **Custom Agents**: Through HTTP+SSE or stdio
501
-
502
- ## 📖 Additional Resources
503
-
504
- - [Bandit Documentation](https://bandit.readthedocs.io/)
505
- - [Detect Secrets Documentation](https://github.com/Yelp/detect-secrets)
506
- - [Pip Audit Documentation](https://pypi.org/project/pip-audit/)
507
- - [Semgrep Documentation](https://semgrep.dev/docs/)
508
- - [MCP Specification](https://spec.modelcontextprotocol.io/)
509
- - [Gradio MCP Integration](https://gradio.app/guides/mcp-integration/)
510
-
511
- ---
512
-
513
- **Note**: Bandit, Detect Secrets, Pip Audit, Circle Test, and Semgrep are static analyzers and cannot detect all types of vulnerabilities. Use them as part of a comprehensive security strategy.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
agent_requirements.txt DELETED
@@ -1,134 +0,0 @@
1
- agno==1.5.10
2
- aiofiles==24.1.0
3
- aiohappyeyeballs==2.6.1
4
- aiohttp>=3.8.0
5
- aiosignal==1.3.2
6
- altair==5.5.0
7
- annotated-types==0.7.0
8
- attrs==25.3.0
9
- bandit[toml,baseline,sarif]>=1.7.0
10
- blinker==1.9.0
11
- boltons==21.0.0
12
- boolean.py==5.0
13
- bracex==2.5.post1
14
- CacheControl==0.14.3
15
- cachetools==5.5.2
16
- certifi==2025.4.26
17
- charset-normalizer==3.4.2
18
- click==8.1.8
19
- click-option-group==0.5.7
20
- colorama==0.4.6
21
- cyclonedx-python-lib>=5,<9
22
- defusedxml==0.7.1
23
- Deprecated==1.2.18
24
- detect-secrets>=1.0.0
25
- distro==1.9.0
26
- docstring_parser==0.16
27
- exceptiongroup==1.2.2
28
- face==24.0.0
29
- fastapi>=0.100.0
30
- ffmpy==0.6.0
31
- filelock==3.18.0
32
- frozenlist==1.6.2
33
- fsspec==2025.5.1
34
- gitdb==4.0.12
35
- GitPython==3.1.44
36
- glom==22.1.0
37
- googleapis-common-protos==1.70.0
38
- gradio==5.33.0
39
- gradio_client==1.10.2
40
- groovy==0.1.2
41
- h11==0.16.0
42
- hf-xet==1.1.3
43
- httpcore==1.0.9
44
- httpx==0.28.1
45
- httpx-sse==0.4.0
46
- huggingface-hub==0.32.4
47
- idna==3.10
48
- importlib_metadata==7.1.0
49
- Jinja2==3.1.6
50
- jiter==0.10.0
51
- jsonschema==4.24.0
52
- jsonschema-specifications==2025.4.1
53
- license-expression==30.4.1
54
- markdown-it-py==3.0.0
55
- MarkupSafe==3.0.2
56
- mcp>=1.0.0
57
- mdurl==0.1.2
58
- msgpack==1.1.0
59
- multidict==6.4.4
60
- narwhals==1.41.1
61
- numpy==2.2.6
62
- openai==1.84.0
63
- opentelemetry-api==1.25.0
64
- opentelemetry-exporter-otlp-proto-common==1.25.0
65
- opentelemetry-exporter-otlp-proto-http==1.25.0
66
- opentelemetry-instrumentation==0.46b0
67
- opentelemetry-instrumentation-requests==0.46b0
68
- opentelemetry-proto==1.25.0
69
- opentelemetry-sdk==1.25.0
70
- opentelemetry-semantic-conventions==0.46b0
71
- opentelemetry-util-http==0.46b0
72
- orjson==3.10.18
73
- packageurl-python==0.17.1
74
- packaging>=20.9,<25
75
- pandas==2.3.0
76
- pbr==6.1.1
77
- peewee==3.18.1
78
- pillow==11.2.1
79
- pip-api==0.0.34
80
- pip-requirements-parser==32.0.1
81
- pip-audit>=2.0.0
82
- platformdirs==4.3.8
83
- propcache==0.3.1
84
- protobuf==4.25.8
85
- py-serializable>=1.1.1,<2.0.0
86
- pyarrow==20.0.0
87
- pydantic==2.11.5
88
- pydantic-settings==2.9.1
89
- pydantic_core==2.33.2
90
- pydeck==0.9.1
91
- pydub==0.25.1
92
- Pygments==2.19.1
93
- pyparsing==3.2.3
94
- python-dateutil==2.9.0.post0
95
- python-dotenv>=0.19.0
96
- python-multipart==0.0.20
97
- pytz==2025.2
98
- PyYAML==6.0.2
99
- referencing==0.36.2
100
- requests==2.32.3
101
- rich==13.5.3
102
- rpds-py==0.25.1
103
- ruamel.yaml==0.18.13
104
- ruamel.yaml.clib==0.2.12
105
- ruff==0.11.13
106
- safehttpx==0.1.6
107
- semantic-version==2.10.0
108
- semgrep==1.124.0
109
- shellingham==1.5.4
110
- six==1.17.0
111
- smmap==5.0.2
112
- sniffio==1.3.1
113
- sortedcontainers==2.4.0
114
- sse-starlette==2.3.6
115
- starlette>=0.27.0
116
- stevedore==5.4.1
117
- streamlit==1.45.1
118
- tenacity==9.1.2
119
- toml==0.10.2
120
- tomli==2.0.2
121
- tomlkit==0.13.3
122
- tornado==6.5.1
123
- tqdm==4.67.1
124
- typer==0.16.0
125
- typing-inspection==0.4.1
126
- typing_extensions==4.14.0
127
- tzdata==2025.2
128
- urllib3==2.4.0
129
- uvicorn>=0.23.0
130
- wcmatch==8.5.2
131
- websockets==15.0.1
132
- wrapt==1.17.2
133
- yarl==1.20.0
134
- zipp==3.22.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bandit_mcp.py CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  import gradio as gr
2
  import subprocess
3
  import json
@@ -344,4 +349,13 @@ with gr.Blocks(title="Bandit Security Scanner MCP") as demo:
344
  """)
345
 
346
  if __name__ == "__main__":
347
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ MCP server for Bandit - a tool for finding common security issues in Python code
4
+ """
5
+
6
  import gradio as gr
7
  import subprocess
8
  import json
 
349
  """)
350
 
351
  if __name__ == "__main__":
352
+ # Получаем настройки сервера из переменных окружения
353
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
354
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7861"))
355
+
356
+ demo.launch(
357
+ mcp_server=True,
358
+ server_name=server_name,
359
+ server_port=server_port,
360
+ share=False
361
+ )
circle_test_mcp.py CHANGED
@@ -151,4 +151,13 @@ with gr.Blocks(title="Circle Test MCP") as demo:
151
  """)
152
 
153
  if __name__ == "__main__":
154
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
151
  """)
152
 
153
  if __name__ == "__main__":
154
+ # Получаем настройки сервера из переменных окружения
155
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
156
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7864"))
157
+
158
+ demo.launch(
159
+ mcp_server=True,
160
+ server_name=server_name,
161
+ server_port=server_port,
162
+ share=False
163
+ )
detect_secrets_mcp.py CHANGED
@@ -476,4 +476,13 @@ with gr.Blocks(title="Detect Secrets MCP") as demo:
476
  """)
477
 
478
  if __name__ == "__main__":
479
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
476
  """)
477
 
478
  if __name__ == "__main__":
479
+ # Получаем настройки сервера из переменных окружения
480
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
481
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7862"))
482
+
483
+ demo.launch(
484
+ mcp_server=True,
485
+ server_name=server_name,
486
+ server_port=server_port,
487
+ share=False
488
+ )
docker-compose.yml DELETED
@@ -1,157 +0,0 @@
1
- version: '3.8'
2
-
3
- services:
4
-
5
- # Bandit Security Scanner
6
- bandit-security-scanner:
7
- build:
8
- context: .
9
- dockerfile: docker/bandit.Dockerfile
10
- container_name: bandit-mcp-server
11
- ports:
12
- - "${BANDIT_EXTERNAL_PORT:-7861}:${BANDIT_INTERNAL_PORT:-7861}"
13
- environment:
14
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
15
- - GRADIO_SERVER_PORT=${BANDIT_INTERNAL_PORT:-7861}
16
- - APP_NAME=Bandit Security Scanner MCP
17
- volumes:
18
- - ./scan_data:/app/scan_data
19
- - ./reports:/app/reports
20
- - ./projects:/app/projects
21
- restart: unless-stopped
22
- networks:
23
- - mcp-network
24
- labels:
25
- - "application=bandit-security-scanner"
26
- - "service=mcp-server"
27
-
28
- # Detect Secrets Scanner
29
- detect-secrets-scanner:
30
- build:
31
- context: .
32
- dockerfile: docker/detect_secrets.Dockerfile
33
- container_name: detect-secrets-mcp-server
34
- ports:
35
- - "${DETECT_SECRETS_EXTERNAL_PORT:-7862}:${DETECT_SECRETS_INTERNAL_PORT:-7862}"
36
- environment:
37
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
38
- - GRADIO_SERVER_PORT=${DETECT_SECRETS_INTERNAL_PORT:-7862}
39
- - APP_NAME=Detect Secrets MCP
40
- volumes:
41
- - ./scan_data:/app/scan_data
42
- - ./reports:/app/reports
43
- - ./projects:/app/projects
44
- restart: unless-stopped
45
- networks:
46
- - mcp-network
47
- labels:
48
- - "application=detect-secrets-scanner"
49
- - "service=mcp-server"
50
-
51
- # Pip Audit Scanner
52
- pip-audit-scanner:
53
- build:
54
- context: .
55
- dockerfile: docker/pip_audit.Dockerfile
56
- container_name: pip-audit-mcp-server
57
- ports:
58
- - "${PIP_AUDIT_EXTERNAL_PORT:-7863}:${PIP_AUDIT_INTERNAL_PORT:-7863}"
59
- environment:
60
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
61
- - GRADIO_SERVER_PORT=${PIP_AUDIT_INTERNAL_PORT:-7863}
62
- - APP_NAME=Pip Audit MCP
63
- volumes:
64
- - ./scan_data:/app/scan_data
65
- - ./reports:/app/reports
66
- - ./projects:/app/projects
67
- restart: unless-stopped
68
- networks:
69
- - mcp-network
70
- labels:
71
- - "application=pip-audit-scanner"
72
- - "service=mcp-server"
73
-
74
- # Circle Test Scanner
75
- circle-test-scanner:
76
- build:
77
- context: .
78
- dockerfile: docker/circle_test.Dockerfile
79
- container_name: circle-test-mcp-server
80
- ports:
81
- - "${CIRCLE_TEST_EXTERNAL_PORT:-7864}:${CIRCLE_TEST_INTERNAL_PORT:-7864}"
82
- environment:
83
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
84
- - GRADIO_SERVER_PORT=${CIRCLE_TEST_INTERNAL_PORT:-7864}
85
- - APP_NAME=Circle Test MCP
86
- volumes:
87
- - ./scan_data:/app/scan_data
88
- - ./reports:/app/reports
89
- - ./projects:/app/projects
90
- restart: unless-stopped
91
- networks:
92
- - mcp-network
93
- labels:
94
- - "application=circle-test-scanner"
95
- - "service=mcp-server"
96
-
97
- # Semgrep Scanner
98
- semgrep-scanner:
99
- build:
100
- context: .
101
- dockerfile: docker/semgrep.Dockerfile
102
- container_name: semgrep-mcp-server
103
- ports:
104
- - "${SEMGREP_EXTERNAL_PORT:-7865}:${SEMGREP_INTERNAL_PORT:-7865}"
105
- environment:
106
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
107
- - GRADIO_SERVER_PORT=${SEMGREP_INTERNAL_PORT:-7865}
108
- - APP_NAME=Semgrep MCP
109
- volumes:
110
- - ./scan_data:/app/scan_data
111
- - ./reports:/app/reports
112
- - ./projects:/app/projects
113
- restart: unless-stopped
114
- networks:
115
- - mcp-network
116
- labels:
117
- - "application=semgrep-scanner"
118
- - "service=mcp-server"
119
-
120
- # Main Security Tools Agent
121
- security-tools-agent:
122
- build:
123
- context: .
124
- dockerfile: docker/agent.Dockerfile
125
- container_name: security-tools-mcp-agent
126
- ports:
127
- - "${AGENT_EXTERNAL_PORT:-7860}:${AGENT_INTERNAL_PORT:-7860}"
128
- environment:
129
- - GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
130
- - GRADIO_SERVER_PORT=${AGENT_INTERNAL_PORT:-7860}
131
- - APP_NAME=Security Tools MCP Agent
132
- - NEBIUS_API_KEY=${NEBIUS_API_KEY}
133
- volumes:
134
- - ./scan_data:/app/scan_data
135
- - ./reports:/app/reports
136
- - ./projects:/app/projects
137
- depends_on:
138
- - bandit-security-scanner
139
- - detect-secrets-scanner
140
- - pip-audit-scanner
141
- - circle-test-scanner
142
- - semgrep-scanner
143
- restart: unless-stopped
144
- networks:
145
- - mcp-network
146
- labels:
147
- - "application=security-tools-agent"
148
- - "service=main-agent"
149
-
150
- networks:
151
- mcp-network:
152
- driver: bridge
153
-
154
- volumes:
155
- scan_data:
156
- reports:
157
- projects:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/agent.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Security Tools MCP Agent - Main Application"
6
- LABEL version="1.0"
7
- LABEL application="security-tools-mcp-agent"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements для агента
20
- COPY agent_requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY main.py .
28
-
29
- # Переменные окружения для Agent
30
- ENV GRADIO_SERVER_PORT=7860
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Security Tools MCP Agent"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "main.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/bandit.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Bandit Security Scanner MCP Server with Gradio Web Interface"
6
- LABEL version="1.0"
7
- LABEL application="bandit-mcp"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements
20
- COPY requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY bandit_mcp.py .
28
-
29
- # Переменные окружения для Bandit MCP
30
- ENV GRADIO_SERVER_PORT=7861
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Bandit Security Scanner MCP"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "bandit_mcp.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/circle_test.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Circle Test MCP Server with Gradio Web Interface"
6
- LABEL version="1.0"
7
- LABEL application="circle-test-mcp"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements
20
- COPY requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY circle_test_mcp.py .
28
-
29
- # Переменные окружения для Circle Test MCP
30
- ENV GRADIO_SERVER_PORT=7864
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Circle Test MCP"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "circle_test_mcp.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/detect_secrets.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Detect Secrets MCP Server with Gradio Web Interface"
6
- LABEL version="1.0"
7
- LABEL application="detect-secrets-mcp"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements
20
- COPY requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY detect_secrets_mcp.py .
28
-
29
- # Переменные окружения для Detect Secrets MCP
30
- ENV GRADIO_SERVER_PORT=7862
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Detect Secrets MCP"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "detect_secrets_mcp.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/pip_audit.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Pip Audit MCP Server with Gradio Web Interface"
6
- LABEL version="1.0"
7
- LABEL application="pip-audit-mcp"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements
20
- COPY requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY pip_audit_mcp.py .
28
-
29
- # Переменные окружения для Pip Audit MCP
30
- ENV GRADIO_SERVER_PORT=7863
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Pip Audit MCP"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "pip_audit_mcp.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docker/semgrep.Dockerfile DELETED
@@ -1,42 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- # Метаданные образа
4
- LABEL maintainer="VulnBuster"
5
- LABEL description="Semgrep MCP Server with Gradio Web Interface"
6
- LABEL version="1.0"
7
- LABEL application="semgrep-mcp"
8
-
9
- # Установка системных зависимостей
10
- RUN apt-get update && apt-get install -y \
11
- git \
12
- curl \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Создание рабочей директории
17
- WORKDIR /app
18
-
19
- # Копирование requirements
20
- COPY requirements.txt ./requirements.txt
21
-
22
- # Установка Python зависимостей
23
- RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir -r requirements.txt
25
-
26
- # Копирование исходного кода
27
- COPY semgrep_mcp.py .
28
-
29
- # Переменные окружения для Semgrep MCP
30
- ENV GRADIO_SERVER_PORT=7865
31
- ENV GRADIO_SERVER_NAME=0.0.0.0
32
- ENV APP_NAME="Semgrep MCP"
33
-
34
- # Открытие порта
35
- EXPOSE $GRADIO_SERVER_PORT
36
-
37
- # Healthcheck
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
39
- CMD curl -f http://localhost:${GRADIO_SERVER_PORT}/ || exit 1
40
-
41
- # Команда запуска
42
- CMD ["python", "semgrep_mcp.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py CHANGED
@@ -179,7 +179,7 @@ api_key = os.getenv("NEBIUS_API_KEY")
179
  if not api_key:
180
  raise ValueError("NEBIUS_API_KEY not found in .env file")
181
 
182
- # Конфигурация MCP серверов (для Docker с переменными окружения)
183
  BANDIT_PORT = os.getenv('BANDIT_INTERNAL_PORT', '7861')
184
  DETECT_SECRETS_PORT = os.getenv('DETECT_SECRETS_INTERNAL_PORT', '7862')
185
  PIP_AUDIT_PORT = os.getenv('PIP_AUDIT_INTERNAL_PORT', '7863')
@@ -188,27 +188,27 @@ SEMGREP_PORT = os.getenv('SEMGREP_INTERNAL_PORT', '7865')
188
 
189
  MCP_SERVERS = {
190
  "bandit": {
191
- "url": f"http://bandit-security-scanner:{BANDIT_PORT}/gradio_api/mcp/sse",
192
  "description": "Python code security analysis",
193
  "port": int(BANDIT_PORT)
194
  },
195
  "detect_secrets": {
196
- "url": f"http://detect-secrets-scanner:{DETECT_SECRETS_PORT}/gradio_api/mcp/sse",
197
  "description": "Secret detection in code",
198
  "port": int(DETECT_SECRETS_PORT)
199
  },
200
  "pip_audit": {
201
- "url": f"http://pip-audit-scanner:{PIP_AUDIT_PORT}/gradio_api/mcp/sse",
202
  "description": "Python package vulnerability scanning",
203
  "port": int(PIP_AUDIT_PORT)
204
  },
205
  "circle_test": {
206
- "url": f"http://circle-test-scanner:{CIRCLE_TEST_PORT}/gradio_api/mcp/sse",
207
  "description": "Security policy compliance checking",
208
  "port": int(CIRCLE_TEST_PORT)
209
  },
210
  "semgrep": {
211
- "url": f"http://semgrep-scanner:{SEMGREP_PORT}/gradio_api/mcp/sse",
212
  "description": "Advanced static code analysis",
213
  "port": int(SEMGREP_PORT)
214
  }
@@ -565,7 +565,16 @@ if __name__ == "__main__":
565
  asyncio.run(init_all_tools())
566
 
567
  logger.info("Запуск Security Tools MCP Agent...")
568
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
569
  except Exception as e:
570
  logger.error(f"Ошибка запуска приложения: {str(e)}")
571
  sys.exit(1)
 
179
  if not api_key:
180
  raise ValueError("NEBIUS_API_KEY not found in .env file")
181
 
182
+ # Конфигурация MCP серверов (теперь все в одном контейнере)
183
  BANDIT_PORT = os.getenv('BANDIT_INTERNAL_PORT', '7861')
184
  DETECT_SECRETS_PORT = os.getenv('DETECT_SECRETS_INTERNAL_PORT', '7862')
185
  PIP_AUDIT_PORT = os.getenv('PIP_AUDIT_INTERNAL_PORT', '7863')
 
188
 
189
  MCP_SERVERS = {
190
  "bandit": {
191
+ "url": f"http://localhost:{BANDIT_PORT}/gradio_api/mcp/sse",
192
  "description": "Python code security analysis",
193
  "port": int(BANDIT_PORT)
194
  },
195
  "detect_secrets": {
196
+ "url": f"http://localhost:{DETECT_SECRETS_PORT}/gradio_api/mcp/sse",
197
  "description": "Secret detection in code",
198
  "port": int(DETECT_SECRETS_PORT)
199
  },
200
  "pip_audit": {
201
+ "url": f"http://localhost:{PIP_AUDIT_PORT}/gradio_api/mcp/sse",
202
  "description": "Python package vulnerability scanning",
203
  "port": int(PIP_AUDIT_PORT)
204
  },
205
  "circle_test": {
206
+ "url": f"http://localhost:{CIRCLE_TEST_PORT}/gradio_api/mcp/sse",
207
  "description": "Security policy compliance checking",
208
  "port": int(CIRCLE_TEST_PORT)
209
  },
210
  "semgrep": {
211
+ "url": f"http://localhost:{SEMGREP_PORT}/gradio_api/mcp/sse",
212
  "description": "Advanced static code analysis",
213
  "port": int(SEMGREP_PORT)
214
  }
 
565
  asyncio.run(init_all_tools())
566
 
567
  logger.info("Запуск Security Tools MCP Agent...")
568
+
569
+ # Получаем настройки сервера из переменных окружения
570
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
571
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
572
+
573
+ demo.launch(
574
+ server_name=server_name,
575
+ server_port=server_port,
576
+ share=False
577
+ )
578
  except Exception as e:
579
  logger.error(f"Ошибка запуска приложения: {str(e)}")
580
  sys.exit(1)
pip_audit_mcp.py CHANGED
@@ -7,6 +7,7 @@ import subprocess
7
  import json
8
  from typing import Dict
9
  import gradio as gr
 
10
 
11
  def pip_audit_scan() -> Dict:
12
  """
@@ -76,4 +77,13 @@ with gr.Blocks(title="Pip Audit MCP") as demo:
76
  )
77
 
78
  if __name__ == "__main__":
79
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
7
  import json
8
  from typing import Dict
9
  import gradio as gr
10
+ import os
11
 
12
  def pip_audit_scan() -> Dict:
13
  """
 
77
  )
78
 
79
  if __name__ == "__main__":
80
+ # Получаем настройки сервера из переменных окружения
81
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
82
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7863"))
83
+
84
+ demo.launch(
85
+ mcp_server=True,
86
+ server_name=server_name,
87
+ server_port=server_port,
88
+ share=False
89
+ )
requirements.txt CHANGED
@@ -1,9 +1,47 @@
1
- gradio[mcp]
2
- bandit[toml,baseline,sarif]
3
- pathlib
4
- smolagents
5
- detect-secrets[word_list,gibberish]
6
- pip-audit
7
- python-dotenv
8
- aiohttp
9
- semgrep
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Security Tools MCP - Simplified Dependencies
2
+ # Core frameworks
3
+ gradio[mcp]>=5.30.0
4
+ fastapi>=0.100.0
5
+ uvicorn[standard]>=0.23.0
6
+
7
+ # MCP framework and client
8
+ mcp>=1.0.0
9
+ smolagents>=0.1.0
10
+ mcp-remote
11
+
12
+ # Security scanners
13
+ bandit[toml]>=1.7.0
14
+ detect-secrets>=1.0.0
15
+ pip-audit>=2.0.0
16
+ semgrep>=1.100.0
17
+
18
+ # AI/ML agent framework
19
+ agno>=1.5.0
20
+ openai>=1.80.0
21
+
22
+ # Core libraries
23
+ aiohttp>=3.8.0
24
+ aiofiles>=24.0.0
25
+ python-dotenv>=0.19.0
26
+
27
+ # Web and HTTP
28
+ httpx>=0.27.0
29
+ httpx-sse>=0.4.0
30
+ requests>=2.32.0
31
+ sse-starlette>=2.3.0
32
+
33
+ # Data processing
34
+ pandas>=2.0.0
35
+ numpy>=2.0.0
36
+ pydantic>=2.10.0
37
+
38
+ # Utilities
39
+ click>=8.0.0
40
+ typer>=0.15.0
41
+ PyYAML>=6.0.0
42
+ toml>=0.10.0
43
+
44
+ # Optional dependencies for better functionality
45
+ Jinja2>=3.1.0
46
+ packaging>=20.9
47
+ platformdirs>=4.0.0
semgrep_mcp.py CHANGED
@@ -207,4 +207,13 @@ with gr.Blocks(title="Semgrep MCP") as demo:
207
  """)
208
 
209
  if __name__ == "__main__":
210
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
207
  """)
208
 
209
  if __name__ == "__main__":
210
+ # Получаем настройки сервера из переменных окружения
211
+ server_name = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
212
+ server_port = int(os.getenv("GRADIO_SERVER_PORT", "7865"))
213
+
214
+ demo.launch(
215
+ mcp_server=True,
216
+ server_name=server_name,
217
+ server_port=server_port,
218
+ share=False
219
+ )
start.sh ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "🚀 Запуск Security Tools MCP Collection..."
5
+
6
+ # Функция для ожидания запуска сервиса
7
+ wait_for_service() {
8
+ local port=$1
9
+ local service_name=$2
10
+ local max_attempts=30
11
+ local attempt=1
12
+
13
+ echo "⏳ Ожидание запуска $service_name на порту $port..."
14
+
15
+ while [ $attempt -le $max_attempts ]; do
16
+ if curl -f http://localhost:$port/health 2>/dev/null || curl -f http://localhost:$port 2>/dev/null; then
17
+ echo "✅ $service_name запущен на порту $port"
18
+ return 0
19
+ fi
20
+ echo " Попытка $attempt/$max_attempts для $service_name..."
21
+ sleep 2
22
+ attempt=$((attempt + 1))
23
+ done
24
+
25
+ echo "❌ Не удалось дождаться запуска $service_name"
26
+ return 1
27
+ }
28
+
29
+ # Экспортируем переменные окружения для MCP серверов
30
+ export GRADIO_SERVER_NAME=${GRADIO_SERVER_NAME:-0.0.0.0}
31
+
32
+ # Запускаем Bandit MCP сервер в фоне
33
+ echo "🔒 Запуск Bandit Security Scanner..."
34
+ export GRADIO_SERVER_PORT=7861
35
+ python bandit_mcp.py &
36
+ BANDIT_PID=$!
37
+
38
+ # Запускаем Detect Secrets MCP сервер в фоне
39
+ echo "🔍 Запуск Detect Secrets Scanner..."
40
+ export GRADIO_SERVER_PORT=7862
41
+ python detect_secrets_mcp.py &
42
+ DETECT_SECRETS_PID=$!
43
+
44
+ # Запускаем Pip Audit MCP сервер в фоне
45
+ echo "🛡️ Запуск Pip Audit Scanner..."
46
+ export GRADIO_SERVER_PORT=7863
47
+ python pip_audit_mcp.py &
48
+ PIP_AUDIT_PID=$!
49
+
50
+ # Запускаем Circle Test MCP сервер в фоне
51
+ echo "📋 Запуск Circle Test Scanner..."
52
+ export GRADIO_SERVER_PORT=7864
53
+ python circle_test_mcp.py &
54
+ CIRCLE_TEST_PID=$!
55
+
56
+ # Запускаем Semgrep MCP сервер в фоне
57
+ echo "🔍 Запуск Semgrep Scanner..."
58
+ export GRADIO_SERVER_PORT=7865
59
+ python semgrep_mcp.py &
60
+ SEMGREP_PID=$!
61
+
62
+ # Даем серверам время на запуск
63
+ echo "⏳ Ожидание запуска всех MCP серверов..."
64
+ sleep 10
65
+
66
+ # Проверяем что все серверы запустились
67
+ wait_for_service 7861 "Bandit"
68
+ wait_for_service 7862 "Detect Secrets"
69
+ wait_for_service 7863 "Pip Audit"
70
+ wait_for_service 7864 "Circle Test"
71
+ wait_for_service 7865 "Semgrep"
72
+
73
+ # Функция для корректного завершения всех процессов
74
+ cleanup() {
75
+ echo "🛑 Завершение всех сервисов..."
76
+ kill $BANDIT_PID $DETECT_SECRETS_PID $PIP_AUDIT_PID $CIRCLE_TEST_PID $SEMGREP_PID 2>/dev/null || true
77
+ wait $BANDIT_PID $DETECT_SECRETS_PID $PIP_AUDIT_PID $CIRCLE_TEST_PID $SEMGREP_PID 2>/dev/null || true
78
+ echo "✅ Все сервисы завершены"
79
+ }
80
+
81
+ # Регистрируем обработчик сигналов
82
+ trap cleanup SIGTERM SIGINT
83
+
84
+ # Запускаем главный агент на порту 7860
85
+ echo "🎯 Запуск главного Security Tools Agent..."
86
+ export GRADIO_SERVER_PORT=7860
87
+ python main.py
88
+
89
+ # Если main.py завершился, останавливаем все остальные сервисы
90
+ cleanup
test_build.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Простой тест для проверки импорта основных зависимостей после исправления конфликта
4
+ """
5
+
6
+ import sys
7
+
8
+ def test_imports():
9
+ """Проверяет что все основные зависимости импортируются без ошибок"""
10
+ print("🧪 Тестирование импорта зависимостей...")
11
+
12
+ errors = []
13
+
14
+ # Тестируем основные зависимости
15
+ test_packages = [
16
+ ("gradio", "Gradio framework"),
17
+ ("bandit", "Bandit security scanner"),
18
+ ("detect_secrets", "Detect Secrets scanner"),
19
+ ("semgrep", "Semgrep scanner"),
20
+ ("smolagents", "SmolaAgents MCP framework"),
21
+ ("agno", "Agno AI agent framework"),
22
+ ("rich", "Rich text formatting"),
23
+ ("fastapi", "FastAPI framework"),
24
+ ("uvicorn", "Uvicorn ASGI server"),
25
+ ("pandas", "Pandas data analysis"),
26
+ ("numpy", "Numpy arrays"),
27
+ ("pydantic", "Pydantic data validation"),
28
+ ("aiohttp", "Async HTTP client"),
29
+ ("requests", "HTTP requests library"),
30
+ ("click", "Click CLI framework"),
31
+ ("yaml", "PyYAML parser"),
32
+ ("toml", "TOML parser"),
33
+ ("dotenv", "Python dotenv")
34
+ ]
35
+
36
+ success_count = 0
37
+
38
+ for package, description in test_packages:
39
+ try:
40
+ if package == "yaml":
41
+ import yaml
42
+ elif package == "dotenv":
43
+ from dotenv import load_dotenv
44
+ else:
45
+ __import__(package)
46
+ print(f"✅ {package}: {description}")
47
+ success_count += 1
48
+ except ImportError as e:
49
+ error_msg = f"❌ {package}: {description} - {str(e)}"
50
+ print(error_msg)
51
+ errors.append(error_msg)
52
+ except Exception as e:
53
+ error_msg = f"⚠️ {package}: {description} - Unexpected error: {str(e)}"
54
+ print(error_msg)
55
+ errors.append(error_msg)
56
+
57
+ print(f"\n📊 Результаты тестирования:")
58
+ print(f"✅ Успешно импортировано: {success_count}/{len(test_packages)}")
59
+ print(f"❌ Ошибок импорта: {len(errors)}")
60
+
61
+ if errors:
62
+ print(f"\n❌ Ошибки:")
63
+ for error in errors:
64
+ print(f" {error}")
65
+ return False
66
+ else:
67
+ print(f"\n🎉 Все зависимости импортируются корректно!")
68
+ return True
69
+
70
+ def test_rich_version():
71
+ """Проверяет версию rich и совместимость с semgrep и smolagents"""
72
+ print("\n🔍 Проверка версии Rich...")
73
+
74
+ try:
75
+ import rich
76
+
77
+ # Пробуем получить версию через importlib.metadata (более надежный способ)
78
+ try:
79
+ from importlib.metadata import version
80
+ rich_version_str = version('rich')
81
+ except ImportError:
82
+ # Fallback для старых версий Python
83
+ import pkg_resources
84
+ rich_version_str = pkg_resources.get_distribution('rich').version
85
+
86
+ print(f"✅ Rich версия: {rich_version_str}")
87
+
88
+ # Проверяем что rich >= 13.9.4 (требование smolagents)
89
+ from packaging import version as pkg_version
90
+ rich_version = pkg_version.parse(rich_version_str)
91
+ min_required = pkg_version.parse("13.9.4")
92
+
93
+ if rich_version >= min_required:
94
+ print(f"✅ Rich версия {rich_version_str} соответствует требованиям smolagents (>=13.9.4)")
95
+ else:
96
+ print(f"⚠️ Rich версия {rich_version_str} может быть несовместима с smolagents (требуется >=13.9.4)")
97
+ return False
98
+
99
+ # Пробуем импортировать функции, которые используют semgrep и smolagents
100
+ from rich.console import Console
101
+ from rich.table import Table
102
+ print("✅ Rich Console и Table импортируются корректно")
103
+
104
+ return True
105
+
106
+ except Exception as e:
107
+ print(f"❌ Ошибка при проверке Rich: {str(e)}")
108
+ return False
109
+
110
+ def main():
111
+ """Основная функция тестирования"""
112
+ print("🔒 Тест совместимости зависимостей VulnBuster")
113
+ print("=" * 60)
114
+
115
+ # Тестируем импорты
116
+ imports_ok = test_imports()
117
+
118
+ # Тестируем версию Rich
119
+ rich_ok = test_rich_version()
120
+
121
+ print("\n" + "=" * 60)
122
+ if imports_ok and rich_ok:
123
+ print("🎉 Все тесты пройдены успешно!")
124
+ print("💡 Теперь можно запустить: docker build -t vulnbuster .")
125
+ sys.exit(0)
126
+ else:
127
+ print("❌ Некоторые тесты не пройдены")
128
+ print("💡 Проверьте requirements.txt и Dockerfile")
129
+ sys.exit(1)
130
+
131
+ if __name__ == "__main__":
132
+ main()