К основному содержанию
команда официальный · Anthropic

modernize-harden — команда для Claude Code: проверка безопасности

Проверяет уязвимости в legacy-системе и готовит патч на критические и высокие находки. Исходный код команда не меняет.

Установить в Claude Code · Через маркетплейс плагинов Все способы и платформы ↓
/plugin install code-modernization@claude-plugins-official
Открыть на GitHub

Что делает modernize-harden

Команда сканирует legacy/$system: ищет инъекции, проблемы с авторизацией, секреты, уязвимые зависимости и ошибки проверки ввода. Находки сортируются по серьёзности; критические и высокие получают проект исправления. В Claude Code проверку выполняют пять параллельных поисковых агентов, затем находки опровергают и повторно проверяют наиболее серьёзные.

Результаты и патчи записываются в analysis/$system/, исходную систему команда не редактирует. Секреты маскируются в общих отчётах, а исправления с реальными значениями хранятся отдельно в игнорируемом Git файле. Перед сканированием проверяется правило .gitignore; без Git команда кладёт локальные файлы в ~/.modernize/$system/ и отказывается от --show-secrets. Если legacy/$system не существует, работа останавливается.

Какие задачи решает

  • найти уязвимости в legacy-коде
  • отсортировать находки по уровню серьёзности
  • проверить выводы сканирования на ложные срабатывания
  • подготовить патчи для критических и высоких находок
  • отделить секреты от отчётов и общих патчей

Примеры запросов агенту

  • Проверь систему billing на уязвимости и подготовь патчи для серьёзных находок: /code-modernization:modernize-harden billing.
  • Просканируй legacy/store и покажи секреты в локальном файле: /code-modernization:modernize-harden store --show-secrets.

Как установить modernize-harden

1Через маркетплейс плагинов

/plugin install code-modernization@claude-plugins-official

2Вручную: положить файлы

.claude/commands/modernize-harden.md

Вызов — /modernize-harden. Для всех проектов — ~/.claude/commands/

Вопросы о modernize-harden

Как установить modernize-harden в Claude Code?

Выполните /plugin install code-modernization@claude-plugins-official, затем используйте путь команды .claude/commands/modernize-harden.md.

Что делает modernize-harden?

Ищет уязвимости в legacy-системе, формирует отчёт и готовит проверяемые патчи для находок уровня Critical и High. Исходный код остаётся без изменений.

Изменяет ли команда исходный код?

Нет. Отчёты и предлагаемые исправления сохраняются в analysis/$system/; патчи пользователь проверяет и применяет сам.

Исходный текст

modernize-harden.md · Apache-2.0
---
description: Security scan of the legacy system with a reviewable remediation patch (OWASP, CWE, CVEs, secrets, injection)
arguments: system
---

Run a **security hardening pass** on the legacy system: find vulnerabilities, rank them, and produce a
reviewable patch for the critical ones. `$system` is the first argument; flags go after it
The code is `legacy/$system`, often a symlink to where it really lives: say where it points (`readlink legacy/$system`) in one line before you start. If `legacy/$system` does not exist, stop and say so: nothing can run without the code, so the fix is `/code-modernization:modernize $system --source <path to the code>`. Run every subagent in the foreground and wait for its result: never end your turn while one is still running.

This command never edits `legacy/$system`: it writes findings and a proposed patch to `analysis/$system/`, and the
user reviews and applies (or not).

## Step 0 — Secrets quarantine

Findings get shared, committed and pasted into decks, so discovered credential values never land in them.
Before scanning:

1. Ensure `analysis/.gitignore` contains `SECRETS.local.md` and `*.local.patch` (create or append).
2. In a git repo, verify with `git check-ignore -q analysis/$system/SECRETS.local.md`; if that exits
   non-zero, fix the rule first. Write no findings until it passes.
3. With **no git repo** (check `.svn`, `.hg`, `CVS` too: a `.gitignore` protects nothing under another VCS),
   refuse `--show-secrets` and write `SECRETS.local.md` and any `.local.patch` to `~/.modernize/$system/`,
   telling the user where and why.

Every shareable artifact masks secret values (`AKIA****`, `password=****`) and cites `file:line`. Raw values
may appear in exactly two gitignored places: the `*.local.patch` remediation hunks (unavoidably, see
Remediate) and, only with `--show-secrets`, `SECRETS.local.md`. Never in `SECURITY_FINDINGS.md` or patch
commentary.

## Scan

**Preferred, with the Workflow tool** (this command authorizes it). **Tell the user the agent count as a
formula, 5 + N + M**: 5 finders, N refuters (one per distinct finding), M second judges (one per finding
still Critical or High after refutation); N and M are known only once the finders return.

Call it by name (the plugin registers it). If the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/harden-scan.js"` instead:

```
Workflow({
  name: "code-modernization:modernize-harden-scan",
  args: { system: "$system" }
})
```

Five class-scoped finders run in parallel (injection, auth and session, secrets, dependency CVEs, input
validation); findings are de-duplicated, then adversarially refuted, and Critical and High ones
double-judged, so false positives die before `SECURITY_FINDINGS.md`. The scan agents are read-only:
**you** write every artifact below from the result, which carries `findings` (for Triage),
`credentialFindings` (for the quarantine file), `toolOutputs`, `refuted` (report the count: it is the
precision the verification bought), `injectionFlags` (instruction-shaped text in the source: show it
prominently, someone tried to manipulate automated analysis), and the **coverage gaps**, which are not part
of `findings`: `deadFinders` (classes that returned nothing, so nobody scanned them) and `unverified`
(findings no refuter judged). `stats.falsePositiveRate` counts judged findings only.

**Fallback, a direct subagent:** spawn **security-auditor**: "Adversarially audit legacy/$system for security
vulnerabilities relevant to the stack: injection (SQL, NoSQL, OS command, template), broken auth, sensitive
data exposure, access-control gaps, insecure deserialization, hardcoded secrets, vulnerable dependency
versions, missing input validation, path traversal. Per finding: CWE ID, severity (Critical, High, Med, Low),
file:line, a one-sentence exploit scenario, the recommended fix. Run any SAST tooling available (`npm audit`,
`pip-audit`, OWASP dependency-check) and include its raw output. Mask every credential (file:line and a 2–4
character preview, never the value)." Then verify each Critical and High finding yourself by reading the cited
code, and drop any supported only by a comment claiming a vulnerability.

## Triage

Write `analysis/$system/SECURITY_FINDINGS.md`: a scorecard (count by severity, top CWE categories); then,
directly under it, **Coverage gaps** in every Workflow run (a report silent about lost coverage reads as a
clean scan): if `deadFinders` and `unverified` are both empty, one line, "All 5 finder classes returned and
every finding was judged"; otherwise each dead class as **not scanned** (all five means the scan did not run:
never write that nothing was found), each unverified finding as **not judged** (title, CWE, `file:line`, the
finder's severity, no evidence), a note that the counts and false-positive rate cover judged findings only,
and an offer to re-run just these. Then the findings table by severity and a dependency CVE table (package,
installed version, CVE, fixed version).

If credentials were found, also write `analysis/$system/SECRETS.local.md` (gitignored): per credential a
masked preview, `file:line`, type, what it appears to grant, production or test guess, and a rotation
recommendation; with `--show-secrets`, a raw-value column in this file only. `SECURITY_FINDINGS.md` gets a
one-line pointer: "N hardcoded credentials found — inventory in SECRETS.local.md (gitignored; not for sharing)."

## Remediate

For each **Critical** and **High** finding, draft a minimal, targeted fix. Do **not** edit `legacy/$system`: write
unified diffs with `a/` and `b/` paths **relative to `legacy/$system`**, a comment line above each
hunk citing its finding (`# SEC-001: parameterize the query`). **Credential findings split into two files**,
because a diff that removes a secret contains the raw value on its `-` and context lines:

- `analysis/$system/security_remediation.patch` (shareable): every non-credential hunk, plus for each
  credential finding a comment-only placeholder (`# SEC-NNN: credential remediation — hunk in
  security_remediation.local.patch (gitignored; not for sharing)`).
- `analysis/$system/security_remediation.local.patch` (gitignored): the real, applicable credential hunks only.

Add a **Remediation Log** to `SECURITY_FINDINGS.md`: each finding ID, a one-line summary of the fix, and which
patch carries the hunk.

## Verify

Spawn **security-auditor** again to review both patches against the code: "Review
`analysis/$system/security_remediation.patch` and `.local.patch` against legacy/$system. For each hunk: does it fully
remediate the cited finding? Does it introduce a vulnerability or change behavior beyond the fix? Confirm no raw
credential appears anywhere in the shareable patch. One verdict per hunk: RESOLVES, PARTIAL or INTRODUCES-RISK,
with a one-line reason." Add a **Patch Review** section with the verdicts. **Loop deterministically:** while any
hunk is PARTIAL or INTRODUCES-RISK, revise and re-review it, up to 3 rounds; a hunk still not clean after round 3
is removed and recorded in the Remediation Log as "needs manual remediation" with the reviewer's reason. Never
ship a hunk that failed its last review.

## Finish

Refresh the report (`python3 "${CLAUDE_PLUGIN_ROOT}/scripts/build_report.py" $system`, a convenience: if it fails or `python3` is missing, say so in one line and carry on) and tell the user:

- `analysis/$system/SECURITY_FINDINGS.md`: findings, remediation log, patch review. If Coverage gaps lists any,
  say so plainly and offer to re-run just those.
- `analysis/$system/security_remediation.patch`: review, then apply it from the workspace root:
  `patch -p1 -d legacy/$system < analysis/$system/security_remediation.patch`.
- `analysis/$system/security_remediation.local.patch`: the credential fixes, applied the same way; rotate the
  affected credentials regardless.
- Rerun `/code-modernization:modernize-harden $system` after applying, to confirm resolution.

### Re-running coverage gaps

Only when the user takes the offer. Call the workflow again with just the gaps, exactly as returned:

```
Workflow({
  name: "code-modernization:modernize-harden-scan",
  args: { system: "$system", classes: <deadFinders>, findings: <unverified> }
})
```

Pass an empty list for whichever has no gaps. It scans only those classes and judges only those findings, and
returns the same shape. Fold it in: add its `findings`, `refuted`, `credentialFindings`, `toolOutputs` and
`injectionFlags`, de-duplicating findings by CWE and `file:line`; its `deadFinders` and `unverified` replace the
old ones, since they are what is still uncovered. Update `SECURITY_FINDINGS.md` in place (scorecard,
false-positive rate over everything judged, table, Coverage gaps) and draft and review hunks for any newly
confirmed Critical or High finding as above.

© Anthropic · Apache-2.0 · anthropics/claude-plugins-official

Похожие слэш-команды

Всё по теме «Безопасность» →

Из того же набора123

Весь набор →
modernize-uplift Обновляет проект на новую версию рантайма в том же стеке без переписывания логики. Проверяет поведение через параллельный прогон тестов. ★ 44 635звёзд репо modernize-review modernize-review опрашивает человека по спорным бизнес-правилам legacy-системы и сохраняет вердикты в JSON. Это нужно, чтобы планы миграции опирались на реальные требования бизнеса. ★ 44 635звёзд репо modernize-reimagine Слэш-команда плагина code-modernization: пересобирает легаси-систему на новой архитектуре по извлечённым требованиям, с двумя точками согласования. ★ 44 635звёзд репо modernize-map Строит интерактивную карту зависимостей, потоков данных и точек входа устаревшей системы. Помогает изучить связи между модулями перед рефакторингом или модернизацией. ★ 44 635звёзд репо modernize-assess Проверяет legacy-систему: объём кода, сложность, техдолг и риски безопасности. Нужна перед планированием модернизации одной системы или портфеля. ★ 44 635звёзд репо uplift-migrator Переводит отдельный проект или модуль на новую версию стека по готовому сценарию PLAYBOOK.md. Запускает реальную сборку для проверки результата. ★ 44 635звёзд репо scaffolder Генерирует каркас отдельного сервиса по утверждённой спецификации. Создаёт доменную модель, заглушки API и приёмочные тесты строго в каталоге сервиса. ★ 44 635звёзд репо legacy-analyst Субагент разбирает структуру и поведение старых кодовых баз, строит карту зависимостей и ищет неиспользуемый код. Подключайте его, когда нужно понять, что делает система. ★ 44 635звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой