fix(cli): create self-heal temp files exclusively - #593
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Current exact authority
developmental@2fa92012bcf80acc1f921a4bafea76b3b1424b46800f584c639e2eee81fc0e95c2b78e81a858d40bpackages/cli/src/lib/event-sender.ts,packages/cli/src/lib/event-sender.test.tsFinding and RED
The original change replaced
Math.random()with 128-bitcrypto.randomBytes(). That removes practical name prediction, but unpredictability alone is not the filesystem admission boundary:writeFileSync(..., 'utf8')can open an already-existing pathname and follow a pre-created symlink. The temp-file create itself must be exclusive.Focused RED
33d00bb84b7ccec968fdc5d26ee8ae7578da6e89first required exclusive creation. The later test refinement5f15cf47a1579b1eb661e25a2ab4ed32990f999cnarrows the contract to the causal invariant only:flag: 'wx'. It deliberately drops the earlier0o600assertion because changing the replacement file's mode was not necessary to close the pathname race and could change existing project-file permission behavior.Minimal causal repair and intervening-delta adoption
The current source keeps the cryptographic suffix and writes the adjacent temporary file with
{ encoding: 'utf8', flag: 'wx' }before the existing rename. A pathname that already exists therefore fails closed instead of being opened or followed, while the prior default mode/umask semantics remain unchanged.After exact
91dba856c07fa15c9b8367108ad24a21a0647776, normal descendant9f3eae6bffdec765eb5c10e009ba5193c24cb403reintroduced the prior non-exclusive write, removed the focused regression, restored unrelated.trivyignoreCVE suppressions, and restored branch-local Sentinel doctrine. It remains in ancestry; normal childc9dd7ccd389ac55d7737af8d3d9cf1cdeb6a5a44re-adopted the reviewed tree without force update. Current descendants then removed the non-causal mode change while preserving the exclusive-create boundary. No distinct valid semantic delta from the intervening commit was discarded.The security scanner has already shown that the removed suppressions conceal real transitive dependency findings; those need causal package-graph repair rather than an ignore file. That dependency repair stays separate from this filesystem-boundary slice.
Gate
Keep Draft. Exact-current repository tests/lint, Security/SAST/CodeQL and qualifying independent current-head review must all be terminal and acceptable before promotion. Earlier run results do not transfer across the latest descendant. Do not merge by suppressing dependency findings, synthesizing status, or weakening the exclusive-create invariant.