[mimosa 1.0.4] git-gate 钩子 spawnSync maxBuffer 64MiB:大仓 deep 扫描 JSON ≈116MiB 必现 ENOBUFS 失败开放(黑盒根因取证 + 修复建议)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 44/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js
- Área
- security
Línea de trabajo
The issue identifies the git-gate hook's spawnSync call for cli.js scan <dir> --deep --no-deps --json as the failure point; start by locating that hook and comparing it with the file-writing security-scan run path. Check how the hook consumes scan output and whether it needs the full call graph and evidence fields. Done means the reported large-repository scan no longer hits ENOBUFS and gate decisions still use the required findings and coverage.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
插件与版本
- 插件:mimosa(Code Security Protection)1.0.4,官方市场安装,macOS,node v24
- 官方市场 2026-10-12 最新即 1.0.4(CDN marketplace.json 核对),无修复版可升
- 场景:大型仓库(约 1,900 个被选中的真实业务源文件),
MIMOSA_GIT_GATE_FAILURE_MODE保持默认open - 1.0.3 时期已有同类症状报告(#17 现象二);本 issue 在 1.0.4 上黑盒定位到根因,并给出修复选项
现象
大仓里每一次 git commit(与提交内容无关),mimosa L3 git-gate(PreToolUse/Bash)都报:
Mimosa L3:git commit 前深度扫描为 INCONCLUSIVE(scanner_enobufs);不能视为安全。当前兼容模式失败开放。
稳定复现率 100%,提交一律被降级放行——大仓场景下这道门禁实际失效。
根因(黑盒取证,2026-10-12)
钩子链用 spawnSync 收集 cli.js scan <dir> --deep --no-deps --json 的全量 stdout,maxBuffer 上限 64 MiB(67,108,864 B)。以 NODE_OPTIONS --require 一次性探针包裹 child_process 实测钩子内部的 spawnSync 调用:
spawnSync git -C <worktree> diff --cached --name-only --diff-filter=ACMR maxBuffer=8388608 err=null
spawnSync git -C <worktree> log --format=%H --name-only --no-renames maxBuffer=131072 err=null
spawnSync node <cli.js> scan <worktree> --deep --no-deps --json maxBuffer=67108864 err=ENOBUFS stdoutLen=66318284
第三行即故障点:子进程 stdout 在 66,318,284 B 处被截断、子进程被杀,error.code === "ENOBUFS"——这是 Node 对「spawnSync 子进程输出超 maxBuffer」的标准错误码(独立对照:spawnSync 一个输出 2 MB 的子进程即可稳定复现同码,与磁盘/物理内存无关)。
同一命令把 stdout 重定向到文件,得全量输出 121,988,881 B ≈ 116.3 MiB——约为上限的 1.8 倍。体积构成(按文件内原始字节跨度切分,与总大小逐字节对账):
| 部分 | 原始字节 | 占比 |
|---|---|---|
callGraph.factsV1.edges(45,204 条调用边,来自 1,610 个 caller 文件) |
96,159,597 B | 78.8% |
businessLogicEvidence(主体为 .graph) |
25,813,821 B | 21.2% |
| 其余全部顶层字段(coverage / files / findings 等) | < 20,000 B | ~0% |
| 合计 | 121,988,881 B | 100% |
两个关键结论:
- 超限元凶是调用图导出 + 业务证据图(合计 99%+ 字节),finding 本身极小;且元凶是真实业务源码的正当产物,不是垃圾文件——仓库只会增长,任何大仓的 deep 扫描输出都必然超过 64 MiB。
- 只有走管道的钩子链路被卡死:同一仓库的密封扫描链路(
security-scan run,结果写文件)全程正常、seal 校验 ALL OK。钩子拿到的其实只是 findings/coverage 级别的判定输入,却被迫在管道里搬运全量调用图。
影响
- 大仓
git commit门禁 100% 降级为 fail-open(默认MIMOSA_GIT_GATE_FAILURE_MODE=open),安全闸失效且用户难以区分「无风险」与「工具故障」; - 若用户为求拦截而切
strict,则大仓变成 100% 无法提交——两个模式在大仓下都不可用。
建议(任一即可消除故障;③ 可与 ①/② 叠加)
- 加大 / 支持配置
maxBuffer(如默认 256 MiB 或允许环境变量覆盖)。注意输出体积随仓库规模线性增长,固定上限只是推迟复发,长期仍建议配合 ③。 - 扫描结果写临时文件而非管道:
spawnSync收集改为落临时文件、钩子按需读取。密封链路security-scan run已经是写文件做法,可直接参照。 - 给钩子链路提供裁剪版 JSON 输出(如
--json-summary或按调用方声明裁剪):callGraph.factsV1.edges+businessLogicEvidence占 99%+ 字节,而 git-gate 判定只需要 findings / coverage 汇总;全量调用图保留给密封链路即可。
English summary
mimosa 1.0.4's git-gate hook (PreToolUse/Bash) collects the full scan --deep --no-deps --json output through spawnSync with maxBuffer capped at 64 MiB. On a ~1,900-source-file repository the JSON output is 121,988,881 B (~116.3 MiB, ~1.8× the cap) — 78.8% is callGraph.factsV1.edges (45,204 edges), 21.2% businessLogicEvidence, while the findings themselves are <20 KB — so every git commit deterministically dies with ENOBUFS (Node's standard maxBuffer-exceeded error; verified with a one-shot child_process probe: maxBuffer=67108864 err=ENOBUFS stdoutLen=66318284) and the gate fails open under the default MIMOSA_GIT_GATE_FAILURE_MODE=open. The sealed scan path (security-scan run, which writes output to files) works fine on the same repository — only the pipe-bound hook path is affected. Suggested fixes (any one unblocks; #3 composes with the others): (1) raise / make maxBuffer configurable; (2) write scan output to a temp file like the sealed path already does; (3) offer a trimmed summary JSON for the hook path — call graph + evidence graph are 99%+ of the bytes and not needed for gate decisions. Related symptom report on 1.0.3: #17.
- Lenguaje dominante
- Python
- Estrellas
- 95
- Forks
- 57
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de zai-org/zcode-plugins
-
video-agent-kit (0.4.3): hooks invoke python3, which doesn't exist on Windows — SessionStart/UserPromptSubmit/Stop hooks fail on every triggerPosiblemente ocupada @dvd233 la tomó hace 22 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
zai-org/zcode-plugins#14 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
zai-org/zcode-plugins#88 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
zai-org/zcode-plugins#86 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
zai-org/zcode-plugins#80 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 43/100
zai-org/zcode-plugins#76 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de zai-org/zcode-plugins
Issues similares
-
documentation good first issue
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
sujithputta02/Esapay#13 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishAbiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
gke-labs/kube-agents#3277 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jbacalso24/mimry#291 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 Menos de una hora Aptitud para principiantes 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Los mantenedores suelen responder en 1 día