
Rust 기반 CLI 도구로, Git 저장소를 재귀적으로 탐색하고 상태 변경을 캡처하며, diff를 생성하고 전체 스니펫과 함께 코드 요소를 추출한 후 코드 리뷰 및 감사 워크플로우를 위한 보안 중심 보고서를 생성합니다.
이 프로젝트가 여러분의 작업에 도움이 된다면, 지속적인 유지보수 및 새로운 기능 개발을 지원해 주세요.
ETH 기부 지갑
0x11282eE5726B3370c8B480e321b3B2aA13686582
QR 코드를 스캔하거나 위의 지갑 주소를 복사하세요.
Git 저장소를 재귀적으로 검색하고, 상태 변경을 캡처하며, 차이(diff)를 생성하고, 전체 코드 조각을 포함한 코드 요소를 추출하며, 코드 리뷰 및 감사 워크플로를 위한 보안 중심 보고서를 생성하는 Rust CLI 도구입니다.
왜 bash만 사용하지 않나요?
ls | while read line; do git -C "$line" diff HEAD~1 HEAD || true; done같은 원라이너는 원시 차이만 보여줍니다. DiffCatcher는 재귀적 탐색, 코드 요소 추출, 보안 패턴 감지, CI/CD를 위한 SARIF 출력, 병렬 처리, 저장소 간 보안 집계를 추가합니다. 아래의 전체 비교를 참조하세요.
git clone https://github.com/Teycir/DiffCatcher.git
cd DiffCatcher
cargo build --release
./target/release/diffcatcher --help
# 디렉터리 내 모든 저장소 스캔 (fetch 전용, 수정 없음)
diffcatcher ~/projects
# 업데이트 pull 및 보안 보고서 생성
diffcatcher ~/projects --pull -o ./report
# 단일 저장소에서 두 브랜치 차이 (PR 리뷰 모드)
diffcatcher ./my-repo --diff main..feature/auth -o ./pr-report
# GitHub Code Scanning용 SARIF 출력 생성
diffcatcher ~/projects --summary-format sarif,json -o ./report
# 스캔할 항목을 확인하는 드라이런
diffcatcher ~/projects --dry-run
# 8개의 병렬 워커로 빠른 스캔
diffcatcher ~/projects -j 8 --quiet
# 기본 설정으로 스캔 (fetch 전용)
diffcatcher <ROOT_DIR>
# 사용자 지정 출력 디렉터리
diffcatcher ~/projects -o ./my-report
# 중첩 저장소 포함 및 심볼릭 링크 따라가기
diffcatcher ~/projects --nested --follow-symlinks
# 숨김 디렉터리 건너뛰기
diffcatcher ~/projects --skip-hidden
# Fetch만 (기본값 - 워킹 트리 변경 없음)
diffcatcher ~/projects
# 실제로 변경 사항 pull
diffcatcher ~/projects --pull
# 더티 저장소에 대해 stash/pop으로 강제 pull
diffcatcher ~/projects --pull --force-pull
# 리베이스 전략 사용
diffcatcher ~/projects --pull --pull-strategy rebase
# fetch/pull 완전히 건너뛰기 (과거 차이만)
diffcatcher ~/projects --no-pull
# 요소 추출 건너뛰기 (원시 차이만)
diffcatcher ~/projects --no-summary-extraction
# 요소는 추출하지만 코드 조각은 건너뛰기
diffcatcher ~/projects --no-snippets
# 조각 컨텍스트 및 제한 조정
diffcatcher ~/projects --snippet-context 10 --max-snippet-lines 300
# 차이당 요소 제한
diffcatcher ~/projects --max-elements 1000
# 보안 태깅 건너뛰기
diffcatcher ~/projects --no-security-tags
# 보안 분석에 테스트 파일 포함
diffcatcher ~/projects --include-test-security
# 사용자 지정 보안 패턴 사용
diffcatcher ~/projects --security-tags-file ./custom-patterns.json
DiffCatcher는 다음 위치에서 프로젝트 로컬 설정을 자동으로 로드할 수 있습니다:
<ROOT_DIR>/.diffcatcher.toml (기본값)--config <FILE>을 통한 사용자 지정 파일--no-config로 비활성화예시:
output = "reports-local"
no_pull = true
history_depth = 2
summary_formats = ["json", "txt"]
no_security_tags = false
[plugins]
security_pattern_files = ["plugins/security-extra.json"]
extractor_files = ["plugins/extractors.json"]
CLI 플래그는 명시적으로 설정될 때 여전히 설정 값을 덮어씁니다.
DiffCatcher는 두 가지 플러그인 유형을 지원합니다:
--security-plugin-file <FILE> (반복 가능)--extractor-plugin-file <FILE> (반복 가능)보안 플러그인 형식은 --security-tags-file JSON(version, mode, tags)과 일치합니다.
추출기 플러그인 형식:
{
"version": 1,
"extractors": [
{
"name": "policy-rule",
"kind": "Config",
"regex": "^policy\\s+([A-Za-z_][A-Za-z0-9_]*)"
}
]
}
# 단일 저장소에서 두 브랜치 차이
diffcatcher ./my-repo --diff main..feature/auth
# 특정 커밋 차이
diffcatcher ./my-repo --diff abc123..def456
# CI 통합용 SARIF 출력으로 차이
diffcatcher ./my-repo --diff origin/main..HEAD --summary-format sarif -o ./pr-report
--diff BASE..HEAD 플래그는 저장소 검색 및 fetch/pull을 건너뜁니다. 두 ref(브랜치, 태그 또는 커밋 SHA)를 직접 비교하고 결과에 대해 전체 추출 + 보안 태깅 파이프라인을 실행합니다.
# 다른 형식과 함께 SARIF 생성
diffcatcher ~/projects --summary-format sarif,json,md
# CI/CD 업로드용 SARIF 전용
diffcatcher ~/projects --summary-format sarif -o ./report
--summary-format에 sarif가 포함되면 results.sarif 파일이 보고서 루트에 생성됩니다. 이 파일은 SARIF 2.1.0 표준을 따르며 GitHub Code Scanning, VS Code SARIF Viewer, Azure DevOps 및 기타 SARIF 호환 도구와 통합됩니다.
# 증분 모드 (변경되지 않은 저장소 건너뛰기)
diffcatcher ~/projects --incremental -o ./report
# 브랜치 패턴으로 필터링
diffcatcher ~/projects --branch-filter "main"
# 과거 깊이 조정
diffcatcher ~/projects --history-depth 5
# CI/CD용 JSON 출력
diffcatcher ~/projects --quiet --json > result.json
# 발견된 경로를 포함한 자세한 출력
diffcatcher ~/projects --verbose
<report_dir>/
├── summary.json # 전체 요약
├── summary.md # Markdown 요약
├── results.sarif # SARIF 2.1.0 출력 (--summary-format sarif일 때)
├── security_overview.json # 저장소 간 보안 집계
├── security_overview.md
├── <repo-name>/
│ ├── status.json # 저장소 상태
│ ├── pull_log.txt
│ └── diffs/
│ ├── diff_N_vs_N-1.patch # 원시 통합 차이
│ ├── changes_N_vs_N-1.txt # 파일 매니페스트
│ ├── summary_N_vs_N-1.json # 요소 추출
│ ├── summary_N_vs_N-1.md
│ └── snippets/
│ ├── 001_validate_token_ADDED.rs
│ ├── 002_check_permissions_BEFORE.rs
│ ├── 002_check_permissions_AFTER.rs
│ └── 002_check_permissions.diff
└── ...
모든 옵션은 diffcatcher --help를 참조하세요.
사용자 지정 패턴을 포함한 JSON 파일을 생성하세요:
{
"version": 1,
"mode": "extend",
"tags": [
{
"tag": "pii-handling",
"description": "PII 데이터 처리",
"severity": "High",
"patterns": ["ssn", "social_security", "passport"]
}
]
}
--security-tags-file ./patterns.json과 함께 사용합니다.
src/
├── cli.rs # 인자 파싱
├── scanner.rs # 저장소 검색
├── git/ # Git 작업
│ ├── commands.rs # Git 래퍼
│ ├── state.rs # 상태 캡처
│ ├── diff.rs # 차이 생성
│ └── file_retrieval.rs
├── extraction/ # 요소 추출
│ ├── parser.rs # 통합 차이 파서
│ ├── elements.rs # 요소 탐지
│ ├── snippets.rs # 코드 조각 추출
│ ├── boundary.rs # 괄호/들여쓰기 추적
│ └── languages/ # 언어별 패턴
├── security/ # 보안 태깅
│ ├── tagger.rs # 패턴 매칭
│ ├── patterns.rs # 내장 패턴
│ └── overview.rs # 저장소 간 집계
└── report/ # 보고서 생성
├── writer.rs # 디렉터리 구조
├── json.rs # JSON 직렬화
├── sarif.rs # SARIF 2.1.0 출력
├── markdown.rs # Markdown 형식화
└── snippet_writer.rs
간단한 bash 원라이너로 차이를 나열할 수 있습니다:
ls | while read line; do git -C "$line" diff HEAD~1 HEAD || true; done
이는 빠른 확인에는 유용하지만, DiffCatcher는 상당한 기능을 추가합니다:
bash 원라이너는 약 100바이트입니다. DiffCatcher는 전체 코드 요소 추출이 포함된 보안 중심 감사 도구입니다.
# 모든 테스트 실행
cargo test
# 특정 테스트 스위트 실행
cargo test security_tagger
# 출력과 함께 실행
cargo test -- --nocapture
테스트 커버리지에는 다음이 포함됩니다:
# 벤치마크 바이너리 컴파일
cargo bench --no-run
# 벤치마크 실행
cargo bench --bench core_bench
벤치마크 소스는 benches/core_bench.rs에 있으며 파서/추출 처리량을 추적합니다.
GitHub Actions 워크플로가 포함되어 있습니다:
.github/workflows/ci.yml: 포맷 확인, clippy, 테스트, 벤치 빌드.github/workflows/release.yml: 태그 기반 릴리스 패키징 및 GitHub 릴리스 게시src/security/patterns.rs 참조)모든 모듈에는 포괄적인 인라인 문서가 포함되어 있습니다. 주요 모듈:
src/extraction/parser.rs - 헝크 추출이 포함된 통합 차이 파서src/extraction/elements.rs - 언어 인식 코드 요소 탐지src/extraction/snippets.rs - 경계 탐지가 포함된 전체 코드 조각 추출src/security/tagger.rs - 보안 패턴 매칭 엔진src/git/commands.rs - Git 작업 래퍼전체 API 문서 생성:
cargo doc --open
#rust #git #security #code-review #diff-analysis #static-analysis #devops #cli-tool #audit #vulnerability-detection #code-quality #snippet-extraction #parallel-processing #security-scanning
기여를 환영합니다! 다음 절차를 따라주세요:
cargo test가 통과하는지 확인합니다.MIT 라이선스 - 자세한 내용은 LICENSE 파일을 참조하세요.
| 플래그 | 기본값 | 설명 |
|---|
-o, --output | ./reports/<timestamp> | 보고서 출력 디렉터리 |
-j, --parallel | 4 | 동시 저장소 처리 |
-t, --timeout | 120 | Git 작업 시간 제한 (초) |
-d, --history-depth | 2 | 차이를 생성할 과거 커밋 수 |
--snippet-context | 5 | 변경 주변 컨텍스트 라인 |
--max-snippet-lines | 200 | 조각당 최대 라인 수 |
--max-elements | 500 | 차이당 최대 요소 수 |
--diff | — | 단일 저장소에서 두 ref 차이 (BASE..HEAD) |
--summary-format | json,md | 출력 형식: json, md, txt, sarif |
| 기능 | Bash 원라이너 | DiffCatcher |
|---|
| 재귀적 탐색 | 최상위 항목만 | 중첩 저장소, 심볼릭 링크, 필터 |
| 상태 추적 | 없음 | 커밋 해시, 더티 감지, pull 로그 |
| 코드 이해 | 원시 차이만 | 10개 이상의 언어에서 함수/구조체/클래스 추출 |
| 코드 조각 | 없음 | 컨텍스트 윈도우를 포함한 전체 전/후 코드 |
| 보안 분석 | 없음 | 18개의 내장 패턴 (인증, 암호화, 비밀, SQLi, XSS) |
| 출력 형식 | 터미널만 | JSON, Markdown, SARIF (GitHub Code Scanning) |
| 저장소 간 보기 | 저장소별만 | 모든 저장소에 걸친 집계 보안 보고서 |
| 성능 | 순차적 | 병렬 워커, LRU 캐싱, 증분 모드 |
| CI/CD 통합 | 없음 | GitHub/Azure DevOps에 SARIF 업로드 |
| 오류 처리 | ` | |
| 경로 처리 | 공백에서 실패 | 모든 경로 이름 올바르게 처리 |
| 과거 컨텍스트 | 고정 HEAD~1 | 구성 가능한 깊이, 상태 추적 |