Secret masking runs all lines under one 1 s regex budget, so large log indexes fail with a misleading error

未关闭
#347 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
performance

调研方向

Start with src/utils/ocr.ts and trace regexRanges, REGEX_BUDGET_MS, and the DEFAULT_SECRET_PATTERN; then read how maskSecrets is called from src/utils/bugReport.ts and the indexing paths named in the issue. Run the relevant tests with npm test, including the 50k-line masking case and a caller-supplied catastrophic regex. Done means default-pattern masking handles the specified input and custom regexes still stop at the budget.

由索引模型根据 Issue 内容生成。

描述

effort: small performance priority: medium

Summary

regexRanges runs every text in a single runInNewContext(REGEX_SCAN, { texts, query }, { timeout: REGEX_BUDGET_MS }) call with a 1,000 ms budget. Each text is scanned three times against the 8-alternative DEFAULT_SECRET_PATTERN. index_recording masks every log line in one call (up to 50,000 lines of up to 2,000 chars), and searchIndex masks every item again on each query. The budget therefore caps the total volume of text, not a pathological pattern.

Where

  • src/utils/ocr.ts:141, 166-182 (REGEX_BUDGET_MS, the single vm call at :173)
  • src/utils/bugReport.ts:124 (maskSecrets)
  • src/tools/indexRecording.ts:167, src/utils/recordingIndex.ts:419

Impact

A long recording with chatty logs can exceed 1 s on a slower machine. index_recording then fails, or search_recording fails on every query, with an error blaming nested quantifiers in "your" regex, although the pattern is the built-in secret pattern. The exact tipping size depends on line length and the machine and was not measured.

Suggested fix

Run the built-in DEFAULT_SECRET_PATTERN directly, without the vm budget, or chunk texts into batches that each get their own budget. Keep the shared budget only for caller-supplied regexes.

Acceptance criteria

  • Masking 50k synthetic 1 KB log lines with the default pattern does not throw.
  • A caller-supplied catastrophic regex is still stopped by the budget.

Getting started

  • Relevant files: src/utils/ocr.ts, src/utils/bugReport.ts
  • How to run tests: npm test

Filed by repo-audit/full-audit at b9b94fa. Severity: medium. Effort: S. audit-key: performance|src/utils/ocr.ts|regexRanges

主要语言
TypeScript
星标
1
派生
4
平均合并
14 小时 8 分钟
30 天内合并 PR
48

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/screencast-mcp 的其他 Issue

查看 TMHSDigital/screencast-mcp 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。