Bound diagnostic config file read with size cap#110591
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 5:43 PM ET / 21:43 UTC. Summary PR surface: Source +8, Tests +46. Total +54 across 2 files. Reproducibility: yes. from source and supplied proof: the former path synchronously read the configured file without a byte limit, while the branch exercises the real export with an 8 MiB-plus-one-byte file and confirms a completed archive. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the 8 MiB limit scoped to diagnostic export, retain the graceful Do we have a high-confidence way to reproduce the issue? Yes from source and supplied proof: the former path synchronously read the configured file without a byte limit, while the branch exercises the real export with an 8 MiB-plus-one-byte file and confirms a completed archive. Is this the best way to solve the issue? Yes: reusing the existing bounded regular-file primitive at the diagnostic-only read boundary is narrower and more maintainable than adding a separate reader or a general config-file policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fa9ae68c3423. Label changesLabel justifications:
Evidence reviewedPR surface: Source +8, Tests +46. Total +54 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (7 earlier review cycles)
|
Behavior ProofCode Changes
Local Verification
CI (latest commit)All relevant CI checks pass:
Risk AssessmentThis change replaces an unbounded |
PR openclaw#110591 — Add focused regression coverage for the bounded diagnostic config read: - Test: normal config file (<8MB) produces parseOk: true in config/shape.json - Test: oversized config file (>8MB) produces parseOk: false with graceful error handling - Both tests verify the support bundle zip is still written with all expected contents
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
Co-authored-by: 陈宪彪0668000387 <[email protected]>
|
Merged via squash.
|
* Bound diagnostic config read with size cap * fix: use buffer.toString for readRegularFileSync result in diagnostic export * test: verify normal and oversized diagnostic config export behavior PR openclaw#110591 — Add focused regression coverage for the bounded diagnostic config read: - Test: normal config file (<8MB) produces parseOk: true in config/shape.json - Test: oversized config file (>8MB) produces parseOk: false with graceful error handling - Both tests verify the support bundle zip is still written with all expected contents * refactor(logging): clarify support export config limit Co-authored-by: 陈宪彪0668000387 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
readConfigExportin the diagnostic support export path callsfs.readFileSync(options.configPath, "utf8")on the user's config file with no size limit. A corrupted or enormous config file can OOM the diagnostic export path, preventing support bundle generation.Why This Change Was Made
PR #101472 established the bounded-read pattern. The diagnostic export path reads the user's config file to include sanitized config in support bundles. Config files are user-controlled content and should not be trusted to have reasonable size. Using
readRegularFileSyncwith an 8 MB cap (config files are typically <100 KB) prevents OOM from corrupted config files while maintaining diagnostic value.User Impact
No user-visible change under normal conditions. Config files under 8 MB export identically to before. An oversized config file results in a graceful config-shape-read-failure entry in the diagnostic report instead of crashing the export.
Evidence
Code changes
src/logging/diagnostic-support-export.ts:348-350: Replacedfs.readFileSync(options.configPath, "utf8")withreadRegularFileSync({ filePath: options.configPath, maxBytes: DIAGNOSTIC_CONFIG_MAX_BYTES }).buffer.toString("utf8")src/logging/diagnostic-support-export.ts:41: AddedDIAGNOSTIC_CONFIG_MAX_BYTES = 8 * 1024 * 1024constantreadRegularFileSyncimport from../infra/regular-file.jsBehavioral proof — real diagnostic export (via
writeDiagnosticSupportExport)Both scenarios call the actual
writeDiagnosticSupportExportfunction with real temp directories, real config files, and real zip output validated by decompression and content inspection.Test 1: Normal config file (~100 bytes) — accepted, parseOk: true
The config is read through
readRegularFileSyncwith the 8 MB cap, parsed as JSON5, and included in the support bundle withparseOk: trueand all config values correctly present.Test 2: Oversized config file (8 MB + 1 byte) — rejected, parseOk: false, bundle still complete
The oversized file is rejected at the stat-check stage by
readRegularFileSyncwithFile exceeds 8388608 bytes. The bundle still containsdiagnostics.json,manifest.json, and the standard support footer.Unit tests
src/logging/diagnostic-support-export.test.ts:✓ reads a normal-size config file and reports parseOk: true(752ms)✓ handles an oversized config file exceeding the 8 MB read cap gracefully(30ms)Proof command
Related
readRegularFileSyncbounded-read pattern insrc/cron/store.ts)