Skip to content

Commit 0291022

Browse files
committed
Address review comments second round
1 parent c6ad123 commit 0291022

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

javascript/frameworks/cap/src/sensitive-exposure/SensitiveExposureHeuristicSource.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ If sensitive information is written to a log entry using the CAP Node.js logging
44

55
Data that may expose system information such as full path names, system information, usernames and passwords should not be logged.
66

7+
This query is similar to `js/cap-sensitive-log` in that the sinks are CAP logging facilities. The sources however are the same (exclusively) as the out of the box CodeQL query for [clear text logging](https://codeql.github.com/codeql-query-help/javascript/js-clear-text-logging/).
8+
79
## Recommendation
810

911
CAP applications should not log sensitive information. Sensitive information can include: full path names, system information, usernames, passwords or any personally identifiable information. Make sure to log only information that is not sensitive, or obfuscate/encrypt sensitive information any time that it is logged.
@@ -19,7 +21,18 @@ const LOG = cds.log("logger");
1921
class SampleVulnService extends cds.ApplicationService {
2022
init() {
2123
LOG.info(`[INFO] Environment: ${JSON.stringify(process.env)}`); // CAP log exposure alert
22-
LOG.info(`[INFO] Environment: ${JSON.stringify(process.env)}`); // CAP log exposure alert
24+
var obj = {
25+
x: password
26+
};
27+
28+
LOG.info(obj); // CAP log exposure alert
29+
30+
LOG.info(obj.x.replace(/./g, "*")); // NO CAP log exposure alert - replace call acts as sanitizer
31+
32+
var user = {
33+
password: encryptLib.encryptPassword(password)
34+
};
35+
LOG.info(user); // NO CAP log exposure alert - the data is encrypted
2336
}
2437
}
2538
```

0 commit comments

Comments
 (0)