test(write): add umask tests for deterministic file permissions#593
Open
HaleTom wants to merge 3 commits into
Open
test(write): add umask tests for deterministic file permissions#593HaleTom wants to merge 3 commits into
HaleTom wants to merge 3 commits into
Conversation
Port umask test coverage from upstream PR #21233, adapted to MiMo-Code Effect-based test patterns. Tests verify base mode 0o666 and various umask values (0o000, 0o022, 0o027, 0o077, 0o777).
Address review feedback: - Check typeof process.umask before calling for runtime compatibility - Make 0o777 test actually write a file instead of just bitwise assertion
Author
Review TransparencyThis code has been reviewed by two passes of gemini-code-assist and Cubic. Full review history, discussion, and resolved threads: HaleTom/MiMo-Code#2 |
97aefc0 to
ab53d06
Compare
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.
Ported from anomalyco/opencode#21233
Issue for this PR
Fixes tool.write should enforce 0644 file mode despite umask #19076
Type of change
What does this PR do?
This keeps the PR surgical and limited to
packages/opencode/test/tool/write.test.ts.It updates the write-permission tests to reflect the actual contract: the write path respects the process umask instead of forcing a fixed
0644file mode.The permission coverage now models the real base mode and masking behavior directly:
0o000confirms the unmasked base mode is0o6660o022confirms the common masked result is0o6440o027covers the corner case where the masked result is0o6400o077confirms a restrictive mask produces0o6000o777is kept as a math-only assertion so the suite documents the full masking boundary without creating an unreadable file in-processThis also avoids the competing approach in fix(write): enforce explicit file mode despite umask #19077, which forces
0644after write and would loosen a user's explicit umask-based security boundary.How did you verify your code works?
packages/opencode/test/tool/write.test.tsis clean under LSP diagnostics.bun installto bootstrap the worktree-local dependencies.bun test test/tool/write.test.ts→ 17 pass, 0 fail.bun typecheckinpackages/opencode→ pass.Screenshots / recordings
N/A — non-UI change.
Checklist