agentleFS
3akat-system3akat-system/nexus-starter/.claude/skills/security-check/SKILL.md

security-check

Skill0 starsChanged 6 months agoMITView on GitHub

Security Agent — полный автоматический аудит безопасности. TRIGGER when: перед деплоем, security review, security audit, проверь безопасность, уязвимости, токен в коде, .env проверка, CORS, SQL injection, auth check, JWT, npm audit, проверить до публикации, готово к продакшн, аудит безопасности, пентест. Contains: secrets scan, npm audit, SSL check, headers check, port scan, dependency analysis, security report.

  • Reads credentials

32 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use learn and code-review.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • genomewalkerSkill

    learn

    Learn from web sources, generate SKILL.md, and store key patterns in soul memory. Trigger keywords: learn, skill-gen, web-learn, documentation, tutorial.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 5 projects that use this

The file

Files
SKILL.md

Security Agent — Полный аудит безопасности

Роль

Ты — Security Agent. Проводишь автоматический аудит безопасности проектов: код, сервер, зависимости, конфигурация. Выдаёшь отчёт с приоритизацией.

Серверы и проекты

ПроектIPSSHПуть (сервер)
Фуджи-мастер155.212.210.165ssh -i ~/.ssh/id_rsa root@155.212.210.165/var/www/fuji-routes/
ПлюсОдин31.128.42.61ssh -i ~/.ssh/id_rsa root@31.128.42.61/var/www/plusone-bot/
NEXUS-Bot v246.226.162.87ssh -i ~/.ssh/vpn_server_key root@46.226.162.87/var/nexus/bot-v2/
nexus-max46.226.162.87(тот же)/var/nexus/nexus-max/
VPN-Bot46.226.162.87(тот же)/root/vpn-bot/
VPN Landing46.226.162.87(тот же)/var/www/vpn-landing/
nexus-system.ru46.226.162.87(тот же)/var/www/nexus-site/

SSH: Всегда полный ssh -i ключ root@IP. Алиасы нестабильны в subagent.

Алгоритм аудита (выполняй ВСЁ)

1. Секреты в коде (КРИТИЧНО)

# Поиск токенов, паролей, ключей в локальном коде
grep -rn "password\|secret\|token\|api_key\|apikey\|private_key" --include="*.js" --include="*.ts" --include="*.json" Projects/ | grep -v node_modules | grep -v package-lock | grep -v ".env.example"

Также проверь:

  • Нет ли .env файлов в git: git ls-files '*.env' '.env*'
  • Нет ли SSH ключей в репо
  • Нет ли хардкод-паролей в vault заметках

2. Зависимости (npm audit)

ssh -i ~/.ssh/id_rsa root@155.212.210.165 "cd /var/www/fuji-routes && npm audit --json 2>/dev/null" | head -100
ssh -i ~/.ssh/vpn_server_key root@46.226.162.87 "cd /var/nexus/bot-v2 && npm audit --json 2>/dev/null" | head -100
ssh -i ~/.ssh/vpn_server_key root@46.226.162.87 "cd /root/vpn-bot && npm audit --json 2>/dev/null" | head -100

Парси JSON: считай critical, high, moderate. Предлагай npm audit fix если безопасно.

3. SSL сертификаты

# Проверить срок и валидность
ssh root@fuji "echo | openssl s_client -servername fujiroutes.ru -connect localhost:443 2>/dev/null | openssl x509 -noout -dates -subject 2>/dev/null || echo 'SSL не настроен'"
ssh root@fuji "certbot certificates 2>/dev/null"

4. Открытые порты

ssh root@fuji "ss -tlnp | grep LISTEN"
ssh nexusvpn "ss -tlnp | grep LISTEN"

Проверяй: должны быть открыты ТОЛЬКО нужные порты (22, 80, 443, 5432 localhost). Если PostgreSQL слушает 0.0.0.0 — это КРИТИЧНО.

5. HTTP заголовки безопасности

ssh root@fuji "curl -sI http://localhost:3000 | head -20"

Проверяй наличие:

  • X-Content-Type-Options: nosniff
  • X-Frame-Options: DENY или SAMEORIGIN
  • Strict-Transport-Security (HSTS)
  • Content-Security-Policy
  • Отсутствие X-Powered-By (утечка информации)

6. Конфигурация Nginx

ssh root@fuji "nginx -T 2>/dev/null | grep -E 'server_tokens|add_header|ssl_|proxy_pass|limit_req'"

Проверяй:

  • server_tokens off (скрыть версию)
  • SSL настройки (TLS 1.2+, strong ciphers)
  • Rate limiting настроен

7. SSH безопасность

ssh root@fuji "grep -E 'PermitRootLogin|PasswordAuthentication|Port' /etc/ssh/sshd_config | grep -v '#'"

Рекомендации:

  • PasswordAuthentication no (только ключи)
  • PermitRootLogin prohibit-password (ключи only)
  • Нестандартный порт (опционально)

8. Права файлов

ssh root@fuji "ls -la /var/www/fuji-routes/.env 2>/dev/null"
ssh root@fuji "stat -c '%a %U:%G' /var/www/fuji-routes/.env 2>/dev/null"

.env должен быть 600 или 640, владелец — процесс PM2.

9. Firewall

ssh root@fuji "ufw status 2>/dev/null || iptables -L -n 2>/dev/null | head -20"

10. SQL injection паттерны (в коде)

Проверь все .js/.ts файлы проекта через Grep:

  • Ищи: строковая конкатенация в SQL запросах (`SELECT ... ${var}`)
  • Должно быть: параметризованные запросы ($1, $2)

Формат отчёта

## 🔒 Security Audit — YYYY-MM-DD

### Проект: Фуджи-мастер

| Категория | Статус | Находки |
|-----------|--------|---------|
| Секреты в коде | ✅/❌ | деталь |
| npm audit | ✅/⚠️/❌ | 0 critical, 2 high |
| SSL | ✅/⚠️ | valid until ... |
| Порты | ✅/❌ | список открытых |
| HTTP заголовки | ✅/⚠️ | отсутствуют X, Y |
| Nginx | ✅/⚠️ | server_tokens on |
| SSH | ✅/⚠️ | password auth enabled |
| Права файлов | ✅/❌ | .env 644 (должен 600) |
| Firewall | ✅/❌ | не настроен |
| SQL injection | ✅/❌ | найдено N мест |

### Критичные проблемы (исправить сейчас)
1. ❌ описание + как исправить

### Предупреждения (исправить при случае)
1. ⚠️ описание + как исправить

### Рекомендации
- что улучшить

### Оценка: X/10

Сохранение

Записать отчёт в Agent-Notes/security-audit.md (перезаписать — нужен только последний).

Правила

  1. Выполняй ВСЕ 10 проверок — не пропускай
  2. Приоритизируй: секреты > SQL injection > открытые порты > остальное
  3. Для каждой проблемы давай КОНКРЕТНУЮ команду исправления
  4. Не трогай ничего сам — только отчёт и рекомендации
  5. Если сервер недоступен — проверь хотя бы локальный код

Интеллект агента — автоматическая приоритизация

Decision Tree

Что нашёл?
├─ Секрет в коде (токен, пароль, ключ)
│  ├─ В .js/.ts файле → КРИТИЧНО → показать строку + команду удаления
│  ├─ В vault .md → ПРЕДУПРЕЖДЕНИЕ → предложить перенести в .env
│  └─ В .env.example с реальными данными → КРИТИЧНО → заменить на placeholder
│
├─ npm audit critical
│  └─ Показать CVE → если есть fix → `npm audit fix` → если breaking → предупредить
│
├─ PostgreSQL слушает 0.0.0.0
│  └─ КРИТИЧНО → `pg_hba.conf: host all all 127.0.0.1/32 md5`
│
├─ SSH PasswordAuthentication yes
│  └─ ВАЖНО → `PasswordAuthentication no` + `systemctl reload sshd`
│
├─ .env права 644 или 777
│  └─ ВАЖНО → `chmod 600 .env`
│
├─ Нет firewall
│  └─ ПРЕДУПРЕЖДЕНИЕ → `ufw enable && ufw allow 22,80,443/tcp`
│
├─ SSL < 14 дней
│  └─ ВАЖНО → `certbot renew --dry-run` → если ОК → `certbot renew`
│
└─ Всё чисто
   └─ Оценка 9-10/10, короткий отчёт

Кросс-агентная интеграция

ОбнаруженоДействие
SSL скоро истечёт→ Telegram-алерт
npm critical→ предложить deploy с npm audit fix
Open port (не 22/80/443)→ предложить ufw deny
SQL injection в коде→ предложить fix + deploy

Самообучение

После каждого аудита — дописать в Agent-Notes/security-audit.md (перезаписать):

## YYYY-MM-DD — Оценка: X/10
- Критичных: N | Важных: N | Инфо: N
- Исправлено с прошлого раза: [что]
- Новые проблемы: [что]
- Тренд: [улучшается/стагнация/ухудшается]

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.