NewsCrawler.org

Startup check for dependency vulnerabilities in Claude Code, built after comparing tools

Claude Code の起動時に依存パッケージの脆弱性を調べるハーネスを、既製品と比べたうえで自作した話
SessionStart フックの判定の流れ。新規起動するとフックが裏で動き、git リポジトリの外なら何もしない。中なら手元の脅威DBで通信なしに照合し、使う言語の脅威DBがすべて今日確認済みならそのまま結果へ進む。そうでなければ脅威DBを更新してから照合し直し、失敗したら最初の結果に日付を添えて使う。脆弱性が見つかったときだけ Claude に渡す
Image: zenn.dev

The author wrote a startup check for Claude Code. When a session starts, a SessionStart hook[1] compares the repository's dependencies (for example, those listed in package-lock.json) with a database of known vulnerabilities using osv-scanner[2]. If it finds any, Claude reports them in its first reply. The database is updated at most once a day for each language (npm, PyPI), and later checks that day use the local copy without a network connection.

Before building this, the author reviewed existing tools: the built-in /security-review, the security-guidance plugin, the claude-code-security-review GitHub Action, and CVE Sentinel. CVE Sentinel was the closest, but it queries online every time and does not check for secrets. The author kept osv-scanner for matching and wrote about 400 lines of Python standard-library code to handle when the database is updated and how results are passed to Claude.

A separate skill, /security-fullscan, also searches for leaked secrets with gitleaks[3] and writes a report. In git repositories, only the commit history is checked, and Claude receives the file name, line number and secret type, but not the secret value. The author also found that when the network fails during a database update, the result is empty and looks like "no vulnerabilities", so the script checks against the local database first.

Read the original zenn.dev

Sources

  • Zenn JA

    Claude Code の起動時に依存パッケージの脆弱性を調べるハーネスを、既製品と比べたうえで自作した話

    4 likes0 bookmarks0 comments

Published: First seen: Читать по-русски

Open as a page