Repository navigation
test(opencode): make write-tool permission test umask-independent - #1
Merged
Merged
Conversation
The "sets file permissions when writing sensitive data" test asserted a fixed 0644 mode, but the write tool never chmods — a written file's mode is the OS default (0666) filtered by the process umask. The test only passed under a 0022 umask (CI's default); under a stricter local umask (0002 → 0664, 0077 → 0600) it failed, even though the tool behaved correctly. Enforcing 0644 in the tool was proposed and rejected upstream (anomalyco#19076, anomalyco#19077) as a security regression: programmatically loosening a umask-077 user's boundary would make agent-written files (incl. .env, keys) world-readable. The recommended direction was a test-side fix. Pin process.umask(0o022) around the write so the expected mode is deterministic regardless of the developer's environment, and restore it afterwards. Verified: passes under umask 0002, 0022, and 0077; full packages/opencode test/tool suite (341) green; typecheck clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
tool.write"sets file permissions" test asserted a fixed0644mode, but the write tool never chmods — a written file's mode is the OS default (0666) minus the process umask. So it passed only under a0022umask (CI's default) and failed on a stricter local umask (0002→0664,0077→0600), even though the tool was behaving correctly.Enforcing
0644in the tool was proposed and rejected upstream (anomalyco#19076 / anomalyco#19077) as a security regression — it would loosen aumask 077user's boundary. The recommended direction was a test-side fix, which this is: pinprocess.umask(0o022)around the write and restore it after.Verified
Passes under umask
0002,0022, and0077; fullpackages/opencodetest/toolsuite (341) green; typecheck clean.