code-pathfinder
Webサイト · ドキュメント · ルールレジストリ · MCPサーバー · ブログ
クイックスタート
インストール:
brew install shivasurya/tap/pathfinderPythonプロジェクトをスキャン(ルールは自動ダウンロード):
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)解析: Tree-sitterがPython、Dockerfile、Docker ComposeファイルのASTを構築
インデックス化: 関数、呼び出しサイト、パラメータ、代入をクエリ可能な呼び出しグラフに抽出
分析: 関数ごとにVDGを構築、プロシージャ間フローを解決、汚染解析を実行
検出: Pythonベースのセキュリティルールがグラフをクエリしてソースからシンクへのパスを発見
報告: 結果をテキスト、JSON、SARIF(GitHub Code Scanning)、CSVとして出力
190のセキュリティルール、すぐに使用可能
ルールはCDNから自動ダウンロードされます。リポジトリをクローンしたり、ルールファイルを管理する必要はありません。
言語 | バンドル | ルール数 | カバレッジ |
django, flask, aws_lambda, cryptography, jwt, lang, deserialization, pyramid | 158 | SQLインジェクション、RCE、SSRF、パストラバーサル、XSS、デシリアライゼーション、暗号の誤用、JWT脆弱性 | |
security, best-practice, performance | 37 | rootユーザー、露出したシークレット、イメージピン留め、マルチステージビルド、レイヤー最適化 | |
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/pathfinderpip
CLIバイナリとルール作成用のPython SDKをインストールします。
pip install codepathfinderDocker
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 . --verboseGitHub 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
入力 | 説明 | デフォルト |
| ローカルのPythonルールファイルまたはディレクトリへのパス | - |
| リモートルールセット、カンマ区切り(例: | - |
| ソースコードへのパス |
|
| 出力形式: |
|
| 出力ファイルパス |
|
| 失敗とする重大度(例: | - |
| 詳細出力を有効化 |
|
| タイムスタンプ付きのデバッグ診断を有効化 |
|
| テストファイルをスキップ |
|
| キャッシュされたルールセットを強制的に更新 |
|
| 匿名使用状況メトリクスを無効化 |
|
| 使用するPythonバージョン |
|
| プルリクエストにサマリーコメントを投稿 |
|
| critical/highの検出結果に対してインラインレビューコメントを投稿 |
|
| GitHubトークン( | - |
| diff対応スキャンを無効化(すべてのファイルをスキャン) |
|
rulesまたはrulesetのいずれかが必要です。
対応言語
言語 | 分析 | ステータス |
Python | ファイル間データフロー、汚染解析、呼び出しグラフ | 安定 |
Dockerfile | 命令分析、セキュリティパターン | 安定 |
Docker Compose | 設定分析、セキュリティパターン | 安定 |
Go | AST分析、呼び出しグラフ | 近日公開予定 |
コントリビューション
コントリビューションを歓迎します。セットアップ手順、ローカルでのテスト実行方法、PRプロセスについてはコントリビューションガイドをお読みください。
製品内アナウンスのプッシュ
製品内アナウンス(ワークショップ、ブログ記事、セキュリティアドバイザリ)は
release/latest.jsonで管理されています。announcements[]にエントリを追加し、
PRを開き、mainにマージされると、公開ワークフローが約60秒以内にマニフェストを
CDNにアップロードします。スキーマとversion_rangeのセマンティクスについては、バージョン更新チェックの技術仕様を参照してください。
すべてのコントリビューターは、プルリクエストがマージされる前にコントリビューターライセンス契約(CLA)に署名する必要があります。
ライセンス
This server cannot be deployed
Maintenance
Related MCP Connectors
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
MCP server for static security analysis of Android source code
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
AlicenseNot gradedqualityAmaintenanceMCP server that gives AI assistants impact analysis, cross-project reference tracking, and code health scoring.4Apache 2.0- FlicenseNot gradedqualityDmaintenanceMCP server for AI-powered code security, quality, and performance review. Enables auditing code directly from VS Code via right-click or MCP tools.-
- FlicenseNot gradedqualityBmaintenanceMCP 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.56 npm10-
- AlicenseNot gradedqualityBmaintenanceA 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.1MIT