Add SARIF reporting support#1
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughStrix에 SARIF 2.1.0 보고 기능을 추가합니다. 취약점 데이터를 SARIF로 변환·작성하는 telemetry 모듈과 CLI 옵션( ChangesSARIF 지원 추가
Sequence DiagramsequenceDiagram
actor User
participant CLI as strix CLI
participant Tracer as Tracer
participant SARIF as SARIF Module
participant FS as File System
User->>CLI: 실행 (--sarif / --sarif-output)
CLI->>CLI: 인자 파싱
CLI->>Tracer: 취약점 수집 요청
Tracer-->>CLI: 취약점 보고서 반환
CLI->>SARIF: build_sarif_report(reports)
SARIF->>SARIF: 규칙/결과 생성, 위치 검증 및 드롭
SARIF-->>CLI: SARIF 문서(딕셔너리)
CLI->>SARIF: write_sarif_report(path, reports)
SARIF->>FS: 부모 디렉터리 생성
SARIF->>FS: SARIF JSON 파일 작성
FS-->>SARIF: 작성 성공
SARIF-->>CLI: 완료
CLI-->>User: 완료 메시지 표시
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile Summary
Confidence Score: 5/5Safe to merge; only P2 findings present. All findings are P2 (partial SARIF on interrupt and a misleading help string). Core logic — URI sanitisation, location validation, rule deduplication, and OSError handling — is correct and well-tested. strix/interface/main.py — KeyboardInterrupt flow and --sarif-output help text. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI as strix CLI (main.py)
participant Scan as run_cli / run_tui
participant Tracer as GlobalTracer
participant SARIF as sarif.py
participant FS as Filesystem
participant GH as GitHub Code Scanning
User->>CLI: strix --sarif-output results.sarif
CLI->>Scan: asyncio.run(run_cli/run_tui)
Scan->>Tracer: record vulnerability_reports
Scan-->>CLI: complete (or KeyboardInterrupt)
CLI->>Tracer: get_global_tracer()
Tracer-->>CLI: vulnerability_reports
CLI->>SARIF: write_sarif_report(output_path, reports)
SARIF->>SARIF: build_sarif_report()
Note over SARIF: validate URIs, map severity,<br/>separate locationless findings
SARIF->>FS: output_path.open(w) json.dump
FS-->>CLI: OK (or OSError warning printed)
CLI->>User: display_completion_message()
CLI->>CLI: sys.exit(2) if findings and non-interactive
User->>GH: upload-sarif action (if: always())
Reviews (2): Last reviewed commit: "Fix SARIF review edge cases" | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@strix/telemetry/sarif.py`:
- Around line 165-168: 현재 로직이 end_line이 없으면 전체 위치를 드롭하고 있어 SARIF 2.1.0 규격(선택적
region.endLine)을 위반합니다; 수정방법은 strix/telemetry/sarif.py에서 region, start_line,
end_line, dropped_location_count를 찾아 기존 if 블록을 바꿔서 end_line이 정수이고 end_line >=
start_line인 경우에만 region["endLine"] = end_line을 설정하고 계속 처리하며, end_line이 없거나 유효하지
않으면 region에서 endLine을 아예 설정하지 않고 continue(드롭)하지 않도록 하며 필요시
dropped_location_count는 오직 완전히 무효한 위치(예: start_line 자체가 유효하지 않은 경우)에서만 증가시키도록
조정하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7b1929e-d74b-4935-9ab9-253ab4685e02
📒 Files selected for processing (5)
README.mdstrix/interface/main.pystrix/telemetry/sarif.pytests/interface/test_sarif_cli.pytests/telemetry/test_sarif.py
Summary
--sarif/--sarif-outputCLI flags and write SARIF before non-interactive exit code2so CI uploads can run withif: always().Validation
uv run pytest -q→ 118 passed, 4 warningsuv run mypy strix/telemetry/sarif.py strix/interface/main.py→ successuv run pyright strix/telemetry/sarif.py→ 0 errorsuv run ruff check strix/telemetry/sarif.py strix/interface/main.py tests/telemetry/test_sarif.py tests/interface/test_sarif_cli.py→ all checks passedNotes