mcpField
V
vulnerability-scanning

vulnerability-scanning

github.com/secondskyセキュリティ240522 回インストール5 週間前に更新
リポジトリ

vulnerability-scanning について

コード、依存関係、コンテナを検査するチーム向けの脆弱性スキャンスキルです。コマンドラインのスキャナーと CI/CD の運用を説明し、高または重大な検出結果でビルドを失敗させる方法も扱います。

主な機能

  1. 01依存関係の脆弱性スキャン
  2. 02コンテナとファイルシステムのスキャン
  3. 03Python コード解析
  4. 04GitHub Actions 連携
  5. 05CI/CD の検出結果ポリシー

活用シーン

  1. 01プロジェクト依存関係のスキャン
  2. 02コンテナイメージとファイルシステムの確認
  3. 03CI/CD へのセキュリティチェック追加

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/secondsky/claude-skills --skill vulnerability-scanning

インストール後、Claude Code で/vulnerability-scanningを入力して読み込まれたか確認します。

詳細

脆弱性スキャン

コード、依存関係、コンテナ全体でセキュリティ脆弱性の検出を自動化します。

依存関係のスキャン

# npm audit
npm audit --audit-level=high

# Snyk
snyk test --severity-threshold=high

# Safety (Python)
safety check --full-report

コンテナスキャン(Trivy)

# Scan container image
trivy image myapp:latest --severity HIGH,CRITICAL

# Scan filesystem
trivy fs --scanners vuln,secret .

GitHub Actions との統合

name: Security Scan

on: [push, pull_request]

jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run Trivy vulnerability scanner
        uses: aquasecurity/[email protected]
        with:
          scan-type: 'fs'
          severity: 'CRITICAL,HIGH'
          exit-code: '1'

      - name: Run Snyk
        uses: snyk/actions/node@v3
        env:
          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
        with:
          args: --severity-threshold=high

      - name: npm audit
        run: npm audit --audit-level=high

コード分析(Python 向け Bandit)

bandit -r src/ -ll -ii

Node.js スキャナー

const { execSync } = require('child_process');

function runScan(command) {
  try {
    return JSON.parse(execSync(command, { stdio: ['pipe', 'pipe', 'ignore'] }).toString());
  } catch (err) {
    // A tool may be missing, exit non-zero, or print non-JSON output (e.g.
    // trivy progress text when not on a TTY). Treat that as "no parseable
    // result" rather than crashing the scanner.
    console.warn(`Scan command failed or returned non-JSON: ${command}`);
    return null;
  }
}

function runSecurityScan() {
  const results = {
    npm: runScan('npm audit --json'),
    trivy: runScan('trivy fs --quiet --format json .')
  };

  if (!results.npm || !results.npm.metadata) {
    console.warn('npm audit produced no metadata; skipping npm checks');
  } else {
    const critical = results.npm.metadata?.vulnerabilities?.critical || 0;
    if (critical > 0) {
      console.error(`Found ${critical} critical vulnerabilities`);
      process.exit(1);
    }
  }
}

ベストプラクティス

  • CI/CD パイプラインにスキャンを組み込みます
  • 重大度が高い、またはクリティカルな検出結果があった場合、ビルドを失敗させます
  • 依存関係とコンテナをスキャンします
  • 脆弱性を継続的に追跡します
  • 許容した誤検知を記録します

ツール

  • Trivy(コンテナ、ファイルシステム)
  • Snyk(依存関係、コード)
  • npm audit / yarn audit
  • Bandit(Python)
  • OWASP Dependency-Check

コメント