Commit 60c4c2b 1 parent 75ee5b2 commit 60c4c2b Copy full SHA for 60c4c2b
File tree 5 files changed +33
-4
lines changed
5 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -2635,16 +2635,16 @@ modules is unsupported.
2635
2635
It is deprecated in favor of [`require.main`][], because it serves the same
2636
2636
purpose and is only available on CommonJS environment.
2637
2637
2638
- <a id="DEP0XXX "></a>
2639
- ### DEP0XXX : `process.umask()` with no arguments
2638
+ <a id="DEP0139 "></a>
2639
+ ### DEP0139 : `process.umask()` with no arguments
2640
2640
<!-- YAML
2641
2641
changes:
2642
2642
- version: REPLACEME
2643
2643
pr-url: https://github.com/nodejs/node/pull/32499
2644
- description: Documentation-only deprecation.
2644
+ description: Runtime deprecation.
2645
2645
-->
2646
2646
2647
- Type: Documentation-only
2647
+ Type: Runtime
2648
2648
2649
2649
Calling `process.umask()` with no arguments causes the process-wide umask to be
2650
2650
written twice. This introduces a race condition between threads, and is a
Original file line number Diff line number Diff line change @@ -910,6 +910,14 @@ void Environment::set_filehandle_close_warning(bool on) {
910
910
emit_filehandle_warning_ = on;
911
911
}
912
912
913
+ bool Environment::emit_insecure_umask_warning () const {
914
+ return emit_insecure_umask_warning_;
915
+ }
916
+
917
+ void Environment::set_emit_insecure_umask_warning (bool on) {
918
+ emit_insecure_umask_warning_ = on;
919
+ }
920
+
913
921
inline uint64_t Environment::thread_id () const {
914
922
return thread_id_;
915
923
}
Original file line number Diff line number Diff line change @@ -1065,6 +1065,8 @@ class Environment : public MemoryRetainer {
1065
1065
1066
1066
inline bool filehandle_close_warning () const ;
1067
1067
inline void set_filehandle_close_warning (bool on);
1068
+ inline bool emit_insecure_umask_warning () const ;
1069
+ inline void set_emit_insecure_umask_warning (bool on);
1068
1070
1069
1071
inline void ThrowError (const char * errmsg);
1070
1072
inline void ThrowTypeError (const char * errmsg);
@@ -1285,6 +1287,7 @@ class Environment : public MemoryRetainer {
1285
1287
bool emit_env_nonstring_warning_ = true ;
1286
1288
bool emit_err_name_warning_ = true ;
1287
1289
bool emit_filehandle_warning_ = true ;
1290
+ bool emit_insecure_umask_warning_ = true ;
1288
1291
size_t async_callback_scope_depth_ = 0 ;
1289
1292
std::vector<double > destroy_async_id_list_;
1290
1293
Original file line number Diff line number Diff line change @@ -245,6 +245,17 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
245
245
246
246
uint32_t old;
247
247
if (args[0 ]->IsUndefined ()) {
248
+ if (env->emit_insecure_umask_warning ()) {
249
+ env->set_emit_insecure_umask_warning (false );
250
+ if (ProcessEmitDeprecationWarning (
251
+ env,
252
+ " Calling process.umask() with no arguments is prone to race "
253
+ " conditions and is a potential security vulnerability." ,
254
+ " DEP0139" ).IsNothing ()) {
255
+ return ;
256
+ }
257
+ }
258
+
248
259
old = umask (0 );
249
260
umask (static_cast <mode_t >(old));
250
261
} else {
Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ if (common.isWindows) {
40
40
mask = '0664' ;
41
41
}
42
42
43
+ common . expectWarning (
44
+ 'DeprecationWarning' ,
45
+ 'Calling process.umask() with no arguments is prone to race conditions ' +
46
+ 'and is a potential security vulnerability.' ,
47
+ 'DEP0139'
48
+ ) ;
49
+
43
50
const old = process . umask ( mask ) ;
44
51
45
52
assert . strictEqual ( process . umask ( old ) , parseInt ( mask , 8 ) ) ;
You can’t perform that action at this time.
0 commit comments