Problem Statement
OpenCodeReview 当前仅支持两种输出格式:text和 json
Proposed Solution
在现有的 --format flag 中新增 sarif 选项:
ocr review --from main --to feature-branch --format sarif > results.sarif
SARIF 输出将 LlmComment 字段映射为 SARIF result 对象:
| LlmComment 字段 |
SARIF result 字段 |
Path |
location.physicalLocation.artifactLocation.uri |
StartLine / EndLine |
location.physicalLocation.region.startLine / endLine |
Content |
message.text |
Category(bug, security, performance, ...) |
ruleId + tool.driver.rules[].id |
Severity(critical, high, medium, low) |
level(critical/high → error, medium → warning, low → note) |
SuggestionCode |
fixes[].artifactChanges[].replacements[].insertedContent.text |
ExistingCode |
fixes[].artifactChanges[].replacements[].deletedRegion |
这是一个纯输出层变更——不涉及审查 Agent、LLM 循环、Diff 解析器或工具系统。实现完全遵循 cmd/opencodereview/output.go 中现有 outputJSON 和 outputText 函数的相同模式。
在 GitHub Actions 工作流中,SARIF 文件可通过标准的 github/codeql-action/upload-sarif action 上传:
- name: Run OCR
run: ocr review --from ${{ env.MERGE_BASE }} --to ${{ env.HEAD_SHA }} --format sarif > ocr-results.sarif
- name: Upload SARIF to Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ocr-results.sarif
这是对现有 PR 评论流程的补充(而非替代)。团队可以同时使用两者:行内评论用于面向开发者的 PR 反馈,SARIF 上传用于 Security tab 中的持久化告警追踪。
Alternatives Considered
No response
Affected Area
CLI / Commands, Output / Formatting
Additional Context
No response
Problem Statement
OpenCodeReview 当前仅支持两种输出格式:
text和jsonProposed Solution
在现有的
--formatflag 中新增sarif选项:ocr review --from main --to feature-branch --format sarif > results.sarifSARIF 输出将
LlmComment字段映射为 SARIFresult对象:Pathlocation.physicalLocation.artifactLocation.uriStartLine/EndLinelocation.physicalLocation.region.startLine/endLineContentmessage.textCategory(bug, security, performance, ...)ruleId+tool.driver.rules[].idSeverity(critical, high, medium, low)level(critical/high →error, medium →warning, low →note)SuggestionCodefixes[].artifactChanges[].replacements[].insertedContent.textExistingCodefixes[].artifactChanges[].replacements[].deletedRegion这是一个纯输出层变更——不涉及审查 Agent、LLM 循环、Diff 解析器或工具系统。实现完全遵循
cmd/opencodereview/output.go中现有outputJSON和outputText函数的相同模式。在 GitHub Actions 工作流中,SARIF 文件可通过标准的
github/codeql-action/upload-sarifaction 上传:这是对现有 PR 评论流程的补充(而非替代)。团队可以同时使用两者:行内评论用于面向开发者的 PR 反馈,SARIF 上传用于 Security tab 中的持久化告警追踪。
Alternatives Considered
No response
Affected Area
CLI / Commands, Output / Formatting
Additional Context
No response