2020-12-21 15:38:52 +01:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Node.js https://nodejs.org/api/fs.html[``++fs++``]
|
2020-12-21 15:38:52 +01:00
|
|
|
|
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
fs.chmodSync("/tmp/fs", 0o777); // Sensitive
|
|
|
|
----
|
|
|
|
|
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
const fsPromises = fs.promises;
|
|
|
|
|
|
|
|
fsPromises.chmod("/tmp/fsPromises", 0o777); // Sensitive
|
|
|
|
----
|
|
|
|
|
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
const fsPromises = fs.promises
|
|
|
|
|
|
|
|
async function fileHandler() {
|
|
|
|
let filehandle;
|
|
|
|
try {
|
|
|
|
filehandle = fsPromises.open('/tmp/fsPromises', 'r');
|
|
|
|
filehandle.chmod(0o777); // Sensitive
|
|
|
|
} finally {
|
|
|
|
if (filehandle !== undefined)
|
|
|
|
filehandle.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Node.js https://nodejs.org/api/process.html#process_process_umask_mask[``++process.umask++``]
|
2020-12-21 15:38:52 +01:00
|
|
|
|
|
|
|
----
|
|
|
|
const process = require('process');
|
|
|
|
|
|
|
|
process.umask(0o000); // Sensitive
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Node.js https://nodejs.org/api/fs.html[``++fs++``]
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
fs.chmodSync("/tmp/fs", 0o770); // Compliant
|
|
|
|
----
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
const fsPromises = fs.promises;
|
|
|
|
|
|
|
|
fsPromises.chmod("/tmp/fsPromises", 0o770); // Compliant
|
|
|
|
----
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
const fs = require('fs');
|
|
|
|
const fsPromises = fs.promises
|
|
|
|
|
|
|
|
async function fileHandler() {
|
|
|
|
let filehandle;
|
|
|
|
try {
|
|
|
|
filehandle = fsPromises.open('/tmp/fsPromises', 'r');
|
|
|
|
filehandle.chmod(0o770); // Compliant
|
|
|
|
} finally {
|
|
|
|
if (filehandle !== undefined)
|
|
|
|
filehandle.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-01-27 13:42:22 +01:00
|
|
|
Node.js https://nodejs.org/api/process.html#process_process_umask_mask[``++process.umask++``]
|
2020-12-21 15:38:52 +01:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2020-12-21 15:38:52 +01:00
|
|
|
----
|
|
|
|
const process = require('process');
|
|
|
|
|
|
|
|
process.umask(0o007); // Compliant
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|