Skip to main content
Glama
shivasurya

code-pathfinder

by shivasurya

Webサイト · ドキュメント · ルールレジストリ · MCPサーバー · ブログ

Build GitHub Release Apache-2.0 License GitHub Stars Ask DeepWiki


クイックスタート

インストール:

brew install shivasurya/tap/pathfinder

Pythonプロジェクトをスキャン(ルールは自動ダウンロード):

pathfinder scan --ruleset python/all --project .

Dockerfileをスキャン:

pathfinder scan --ruleset docker/all --project .

設定ファイル、APIキー、クラウドアカウントは不要。数秒で結果がターミナルに表示されます。


Related MCP server: CodeAudit Agent

Code Pathfinderとは?

Code Pathfinderは、コードベースのグラフを構築し、データがどのように流れるかを追跡するオープンソースの静的解析エンジンです。ソースコードを抽象構文木に解析し、ファイル間で呼び出しグラフを構築し、汚染解析を実行して、複数のファイルや関数の境界をまたがるソースからシンクへの脆弱性を発見します。

v2.0では、ファイル間データフロー分析を導入:あるファイルのHTTPハンドラからのユーザー入力を、ヘルパー関数を通り、別のファイルのSQLクエリまで追跡します。これは、パターンマッチングツールでは完全に見逃される種類の分析です。

ファイル間汚染解析

ほとんどのオープンソースSASTツールは単一ファイルで動作します。Code Pathfinder v2.0は、ファイルの境界を越えて汚染データを追跡します:

app.py:5    user_input = request.get("query")     ← Source: user-controlled input
  ↓ calls
db.py:12    cursor.execute(query)                  ← Sink: SQL execution

エンジンは関数ごとに変数依存グラフ(VDG)を構築し、それらをプロシージャ間汚染転送サマリーで接続します。user_inputが別のファイルの関数パラメータに流れると、汚染は呼び出しグラフを通じてシンクに伝播します。

仕組み

Source Code → Tree-sitter AST → Call Graph → Variable Dependency Graph → Taint Analysis → Findings
                                     ↓
                              Inter-procedural
                              Taint Summaries
                              (cross-file flows)
  1. 解析: Tree-sitterがPython、Dockerfile、Docker ComposeファイルのASTを構築

  2. インデックス化: 関数、呼び出しサイト、パラメータ、代入をクエリ可能な呼び出しグラフに抽出

  3. 分析: 関数ごとにVDGを構築、プロシージャ間フローを解決、汚染解析を実行

  4. 検出: Pythonベースのセキュリティルールがグラフをクエリしてソースからシンクへのパスを発見

  5. 報告: 結果をテキスト、JSON、SARIF(GitHub Code Scanning)、CSVとして出力

190のセキュリティルール、すぐに使用可能

ルールはCDNから自動ダウンロードされます。リポジトリをクローンしたり、ルールファイルを管理する必要はありません。

言語

バンドル

ルール数

カバレッジ

Python

django, flask, aws_lambda, cryptography, jwt, lang, deserialization, pyramid

158

SQLインジェクション、RCE、SSRF、パストラバーサル、XSS、デシリアライゼーション、暗号の誤用、JWT脆弱性

Docker

security, best-practice, performance

37

rootユーザー、露出したシークレット、イメージピン留め、マルチステージビルド、レイヤー最適化

Docker Compose

security, networking

10

特権モード、ソケット露出、権限昇格、ネットワーク分離

# Scan with a specific bundle
pathfinder scan --ruleset python/django --project .

# Scan with multiple bundles
pathfinder scan --ruleset python/flask --ruleset python/jwt --project .

# Scan a single rule
pathfinder scan --ruleset python/PYTHON-DJANGO-SEC-001 --project .

# Scan all rules for a language
pathfinder scan --ruleset python/all --project .

すべてのルールを例とテストケースとともにルールレジストリで参照できます。

AIコーディングアシスタント向けMCPサーバー

Code PathfinderはMCPサーバーとして動作し、Claude Code、Cursor、Cline、その他のAIアシスタントに呼び出しグラフ、データフロー、セキュリティ分析へのアクセスを提供します。LSPよりも多くのコンテキストを提供し、セキュリティとコード構造に焦点を当てています。

pathfinder serve --project .

MCPサーバーはコードグラフをクエリするためのツールを公開:呼び出し元/呼び出し先の検索、データフローの追跡、パターンの検索、セキュリティルールの実行 — これらすべてがコードレビューや開発中にAIアシスタントから利用可能です。

カスタムルールの作成

セキュリティルールはPathFinder SDKを使用したPythonスクリプトです。ソース、シンク、サニタイザーを定義すれば、データフローエンジンが分析を処理します。

以下はリポジトリからの実際のルール(PYTHON-DJANGO-SEC-001)で、DjangoのSQLインジェクションを検出します:

from codepathfinder import calls, flows, QueryType
from codepathfinder.presets import PropagationPresets

class DBCursor(QueryType):
    fqns = ["sqlite3.Cursor", "psycopg2.extensions.cursor"]
    match_subclasses = True

@python_rule(
    id="PYTHON-DJANGO-SEC-001",
    name="Django SQL Injection via cursor.execute()",
    severity="CRITICAL",
    cwe="CWE-89",
)
def detect_django_cursor_sqli():
    return flows(
        from_sources=[
            calls("request.GET.get"),
            calls("request.POST.get"),
        ],
        to_sinks=[
            DBCursor.method("execute").tracks(0),
            calls("cursor.execute"),
        ],
        sanitized_by=[calls("escape"), calls("escape_string")],
        propagates_through=PropagationPresets.standard(),
        scope="global",  # cross-file taint analysis
    )
# Run your custom rules
pathfinder scan --rules ./my_rules/ --project .

rules/ディレクトリにある190のルールすべてを探索するか、ルールレジストリを参照してください。独自のルールを作成するには、ルール作成ガイドデータフロードキュメントを参照してください。

詳細については、ルール作成ガイドデータフロードキュメントを参照してください。

インストール

Homebrew(推奨)

brew install shivasurya/tap/pathfinder

pip

CLIバイナリとルール作成用のPython SDKをインストールします。

pip install codepathfinder

Docker

docker pull shivasurya/code-pathfinder:stable-latest

docker run --rm -v "$(pwd):/src" \
  shivasurya/code-pathfinder:stable-latest \
  scan --ruleset python/all --project /src

プリビルドバイナリ

GitHub ReleasesからLinux(amd64、arm64)、macOS(Intel、Apple Silicon)、Windows(x64)用をダウンロードしてください。

ソースから

git clone https://github.com/shivasurya/code-pathfinder
cd code-pathfinder/sast-engine
gradle buildGo
./build/go/pathfinder --help

使用方法

# Scan with text output (default)
pathfinder scan --ruleset python/all --project .

# JSON output
pathfinder scan --ruleset python/all --project . --output json --output-file results.json

# SARIF output (GitHub Code Scanning)
pathfinder scan --ruleset python/all --project . --output sarif --output-file results.sarif

# CSV output
pathfinder scan --ruleset python/all --project . --output csv --output-file results.csv

# Fail CI on critical/high findings
pathfinder scan --ruleset python/all --project . --fail-on=critical,high

# MCP server mode
pathfinder serve --project .

# Verbose output with statistics
pathfinder scan --ruleset python/all --project . --verbose

GitHub Action

name: Code Pathfinder Security SAST Scan

on:
  pull_request:

permissions:
  security-events: write
  contents: read
  pull-requests: write

jobs:
  security-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Run Security Scan
        uses: shivasurya/code-pathfinder@v2.1.1
        with:
          ruleset: python/all, docker/all, docker-compose/all
          verbose: true
          pr-comment: ${{ github.event_name == 'pull_request' }}
          pr-inline: ${{ github.event_name == 'pull_request' }}
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload SARIF
        uses: github/codeql-action/upload-sarif@v4
        if: always()
        with:
          sarif_file: pathfinder-results.sarif

完全な例を参照:.github/workflows/code-pathfinder-scan.yml

入力

説明

デフォルト

rules

ローカルのPythonルールファイルまたはディレクトリへのパス

-

ruleset

リモートルールセット、カンマ区切り(例:python/alldocker/security

-

project

ソースコードへのパス

.

output

出力形式:sarifjson、またはcsv

sarif

output-file

出力ファイルパス

pathfinder-results.sarif

fail-on

失敗とする重大度(例:critical,high

-

verbose

詳細出力を有効化

false

debug

タイムスタンプ付きのデバッグ診断を有効化

false

skip-tests

テストファイルをスキップ

true

refresh-rules

キャッシュされたルールセットを強制的に更新

false

disable-metrics

匿名使用状況メトリクスを無効化

false

python-version

使用するPythonバージョン

3.12

pr-comment

プルリクエストにサマリーコメントを投稿

false

pr-inline

critical/highの検出結果に対してインラインレビューコメントを投稿

false

github-token

GitHubトークン(pr-commentまたはpr-inlineが有効な場合に必須)

-

no-diff

diff対応スキャンを無効化(すべてのファイルをスキャン)

false

rulesまたはrulesetのいずれかが必要です。

対応言語

言語

分析

ステータス

Python

ファイル間データフロー、汚染解析、呼び出しグラフ

安定

Dockerfile

命令分析、セキュリティパターン

安定

Docker Compose

設定分析、セキュリティパターン

安定

Go

AST分析、呼び出しグラフ

近日公開予定

コントリビューション

コントリビューションを歓迎します。セットアップ手順、ローカルでのテスト実行方法、PRプロセスについてはコントリビューションガイドをお読みください。

製品内アナウンスのプッシュ

製品内アナウンス(ワークショップ、ブログ記事、セキュリティアドバイザリ)は release/latest.jsonで管理されています。announcements[]にエントリを追加し、 PRを開き、mainにマージされると、公開ワークフローが約60秒以内にマニフェストを CDNにアップロードします。スキーマとversion_rangeのセマンティクスについては、バージョン更新チェックの技術仕様を参照してください。

すべてのコントリビューターは、プルリクエストがマージされる前にコントリビューターライセンス契約(CLA)に署名する必要があります。

ライセンス

Apache-2.0

A
license - permissive license
-
quality - not tested
-
maintenance - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    C
    maintenance
    MCP server for AI coding agents that builds a complete code structure graph and semantic vector index, enabling fast querying of code entities, relationships, and impact analysis.
    78
    8
  • A
    license
    -
    quality
    A
    maintenance
    A production-ready MCP server that enables AI assistants to intelligently understand, analyze, edit, navigate, and review software projects with multi-workspace support, Git integration, and semantic search.
    MIT

View all related MCP servers

Related MCP Connectors

  • Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.

  • Hosted MCP server for structured code review passes on human- and AI-written code. Free tier.

  • Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shivasurya/code-pathfinder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server