Repository navigation
fix(fs): require sys permission for umask - #36222
Conversation
bartlomieju
left a comment
There was a problem hiding this comment.
LGTM. Well-scoped permission fix — gating umask at the shared op_fs_umask op is the right depth, since both Deno.umask() and process.umask() route through it, so there's no per-API duplication and no unchecked path to the syscall. Verified the descriptor wiring ("umask" added to SysDescriptor::parse matches the check_sys("umask", ...) string), and that PermissionCheckError surfaces as NotCapable.
Confirmed the change has no collateral breakage: op_fs_umask is only called from the two user-facing umask APIs — no mkdir/open/makeTemp op or runtime bootstrap invokes it — so common mode-setting FS operations are unaffected. The test-permission additions are all legitimate (those tests call Deno.umask() in their mode & ~Deno.umask() assertions), and rename_test.ts was correctly left alone because its assertDirectory guards the umask call behind mode !== undefined and every call passes no mode. Good coverage on Deno/Node query+set, the denied case, and worker propagation.
Worth calling out in the release notes (not a code issue): this is an intentional breaking change — Deno.umask() and process.umask() previously required no permission and now throw NotCapable without allow-sys=umask, which will also affect Node-compat code calling process.umask(). Documented in the d.ts and the process.ts comment, so just a heads-up for the changelog.
## Summary - add `umask` as a scoped `allow-sys` permission - require that permission when querying or changing the process umask - document the requirement for both `Deno.umask()` and the shared Node operation - add coverage for Deno and Node query/set behavior, including worker permissions ## Testing - `cargo fmt --all -- --check` - `./tools/format.js --check cli/tsc/dts/lib.deno.ns.d.ts ext/fs/ops.rs ext/node/polyfills/process.ts runtime/permissions/lib.rs tests/unit/umask_test.ts` - `cargo build -p deno` - `cargo test -p deno_permissions` - `cargo test -p unit_tests --test unit -- umask_test` - direct `process.umask()` query/set checks with `--allow-sys=umask` and `--deny-sys=umask`
Summary
umaskas a scopedallow-syspermissionDeno.umask()and the shared Node operationTesting
cargo fmt --all -- --check./tools/format.js --check cli/tsc/dts/lib.deno.ns.d.ts ext/fs/ops.rs ext/node/polyfills/process.ts runtime/permissions/lib.rs tests/unit/umask_test.tscargo build -p denocargo test -p deno_permissionscargo test -p unit_tests --test unit -- umask_testprocess.umask()query/set checks with--allow-sys=umaskand--deny-sys=umask