Context
Follow-up hardening items identified during review of #2077 (feat(policy): support custom preset files via --from-file / --from-dir), which implements the custom preset surface requested in #2039.
These were intentionally deferred from #2077 to keep scope focused on the core feature. None are blockers — all are defense-in-depth or developer-experience improvements.
Items
From PR review (suggestions)
From CodeRabbit review (deferred)
References
Context
Follow-up hardening items identified during review of #2077 (
feat(policy): support custom preset files via --from-file / --from-dir), which implements the custom preset surface requested in #2039.These were intentionally deferred from #2077 to keep scope focused on the core feature. None are blockers — all are defense-in-depth or developer-experience improvements.
Items
From PR review (suggestions)
loadPresetFromFile— add astatSync(abs).sizecheck with a reasonable limit (e.g. 1 MB) beforereadFileSyncto avoid reading unexpectedly large files.writeTmphelper intest/policies.test.tscreates temp directories but never cleans them up. AddafterEachcleanup orvi.onTestFinished.--from-dir—readdirSync+.ya?mlfilter picks up files like.hidden-preset.yaml. Add.filter(f => !f.startsWith('.'))to match typical directory-scan behavior.loadPresetFromFile—loadPresetFromFileusesfs.statSyncwhich follows symlinks. Low blast radius since the user already has filesystem access, but worth noting for defense-in-depth (built-inloadPresethas path traversal protection).From CodeRabbit review (deferred)
--dry-runmerged-policy diff renderer — currently--dry-runprints endpoints that would be opened/removed. A real policy-diff renderer (structured YAML diff, colorization, tombstone handling on remove) should improve--dry-runfor allpolicy-addandpolicy-removepaths, not just--from-file/--from-dir.NEMOCLAW_OPENSHELL_BINenv handling in tests — thedelete process.env.NEMOCLAW_OPENSHELL_BINidiom predates feat(policy): support custom preset files via --from-file / --from-dir (closes #2039) #2077 and affects multiple test call sites. Introduce a sharedwithEnvhelper in a singlechore(test)sweep.References