Skip to content

優化掃描穩定性與吞吐(SSE / FileStore / SARIF / DAST) - #19

Merged
BlackishGreen33 merged 8 commits into
mainfrom
codex/optimization-batch
Mar 10, 2026
Merged

優化掃描穩定性與吞吐(SSE / FileStore / SARIF / DAST)#19
BlackishGreen33 merged 8 commits into
mainfrom
codex/optimization-batch

Conversation

@BlackishGreen33

Copy link
Copy Markdown
Owner

變更摘要

  • 掃描通道:Extension 改為 SSE 主通道,輪詢作為降級備援,並補上 SSE keepalive / event id
  • 儲存層:FileStore 新增 scanTask 快速讀寫路徑、stableFingerprint/source 欄位與 meta 版本欄位
  • 匯出:/api/export 新增 SARIF 2.1.0,CSV 補 stableFingerprint/source,Dashboard 新增 SARIF 選項
  • 吞吐:orchestrator 增加 fileAnalysisCache 持久化,JS/TS AST 改 worker pool(失敗自動 fallback)
  • CLI:新增 confession verify web,整合 ZAP baseline + Nuclei(保守 timeout/rate/concurrency)
  • CI/工具:工作流加 path filter + Turborepo remote cache env,新增 pnpm --filter web benchmark:scan
  • 文件:同步 .kiro/steering/*AGENTS.md

驗證

  • pnpm check:ci 全部通過(lint/build/test)

風險與回滾

  • 主要風險在掃描串流與 FileStore 快寫路徑;已補對應測試(scan/export/cache/cli)
  • 可依 commit 邊界逐步 revert(8 個原子 commit)

Copilot AI review requested due to automatic review settings March 10, 2026 08:42
@BlackishGreen33
BlackishGreen33 merged commit 93c2b2e into main Mar 10, 2026
7 checks passed
@BlackishGreen33
BlackishGreen33 deleted the codex/optimization-batch branch March 10, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances scan stability and throughput across multiple dimensions: SSE-based streaming with keepalive for the extension, FileStore fast-path for scan tasks, SARIF 2.1.0 export, persistent file analysis cache, JS/TS AST worker pool, CLI DAST verification command, and CI workflow optimization with path filtering and Turborepo remote cache.

Changes:

  • SSE streaming with event IDs, keepalive, and Last-Event-ID resume; extension client uses SSE primary with polling fallback and exponential backoff
  • FileStore scanTask fast read/write path, stableFingerprint/source fields on vulnerabilities, persistent file analysis cache, and SARIF 2.1.0 export format
  • CLI verify web command integrating ZAP baseline and Nuclei with conservative defaults, plus CI path filtering and Turborepo remote cache environment variables

Reviewed changes

Copilot reviewed 30 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/src/server/routes/scan.ts SSE keepalive, event IDs, Last-Event-ID support, actionable LLM failure messages
web/src/server/routes/scan.test.ts Test for missing API key actionable error propagation
web/src/server/routes/export.ts SARIF 2.1.0 renderer, stableFingerprint/source in serialization and CSV columns
web/src/server/routes/export.test.ts SARIF export test, updated CSV header assertion
web/src/server/file-analysis-cache-store.ts New: persistent file analysis cache with version-gated hydration
web/src/server/file-analysis-cache-store.test.ts Tests for hydration, version mismatch, and persistence
web/src/server/db.ts Fast-path scan task read/write, stableFingerprint/source fields, meta normalization
web/src/server/cache.ts 24h TTL for file analysis cache, shared key builder
web/src/server/agents/orchestrator.ts Persistent cache integration, Map for language lookup
web/src/server/agents/agentic-beta/orchestrator.ts Same persistent cache integration, rememberFirstFailureMessage
web/src/server/agents/analysis-agent.ts lastErrorMessage in LlmUsageStats, rememberFirstFailureMessage
web/src/server/agents/jsts-agent.ts Worker pool for JS/TS AST analysis with sequential fallback
web/src/server/agents/messages.pbt.test.ts Added stableFingerprint/source to PBT arbitraries
web/src/common/libs/types.ts stableFingerprint, source, sarif in shared types
web/src/common/libs/api-client.ts resolveBaseUrl uses window.location.origin for webview
web/src/common/components/dashboard/main.tsx SARIF option in export dialog
extension/src/scan-client.ts SSE primary with polling fallback, SSE message parser, retry logic
extension/src/types.ts stableFingerprint/source fields
extension/src/webview.test.ts Updated test fixtures with new fields
confession-cli/bin/confession.js verify web command with ZAP/Nuclei integration
confession-cli/bin/confession.test.js Tests for verify web success and tool-missing paths
web/benchmark-scan-workspace.mjs New: benchmark script for scan throughput measurement
web/package.json Added benchmark:scan script
.github/workflows/ci.yml Path filtering, Turborepo remote cache env vars
AGENTS.md Updated documentation for all new features
.kiro/steering/*.md Updated steering docs to reflect new capabilities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +240 to +248
region: {
startLine: item.line,
startColumn: item.column,
endLine: item.endLine,
endColumn: item.endColumn,
snippet: {
text: item.codeSnippet,
},
},

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SARIF 2.1.0 requires startLine and startColumn to be 1-based (Section 3.30.5). The vulnerability data model allows line and column to be 0 (default in normalizeVulnerabilityCreate), which would produce invalid SARIF region values. Consider clamping to Math.max(1, item.line) and Math.max(1, item.column) (and similarly for endLine/endColumn) when building the SARIF region to ensure spec compliance.

Copilot uses AI. Check for mistakes.
Comment on lines +305 to +314
function rememberFirstFailureMessage(stats: LlmUsageStats, err: unknown): void {
if (typeof stats.lastErrorMessage === 'string' && stats.lastErrorMessage.length > 0) {
return
}

const raw = err instanceof Error ? err.message : String(err)
const message = raw.trim()
if (message.length === 0) return
stats.lastErrorMessage = message.slice(0, 280)
}

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rememberFirstFailureMessage function is duplicated identically here and in analysis-agent.ts (line 427). Since accumulateFailureKind and isConcurrencyThrottleError are also already duplicated between these files, this follows the existing pattern. However, as the number of duplicated utility functions grows, consider extracting these shared LLM stats helpers (including accumulateFailureKind, isConcurrencyThrottleError, and rememberFirstFailureMessage) into a shared module to reduce future maintenance burden.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants