@zapier/secret-scrubber 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/index.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 1.0.8
|
|
2
|
+
|
|
3
|
+
_released `2023-10-25`_
|
|
4
|
+
|
|
5
|
+
- fix issue where the order of replacements in `scrub` matters in the sense that we can end up with partially scrubbed sensitive data. Now, we sort the sensitive bank values by larger keys first ([!11](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/11))
|
|
6
|
+
|
|
1
7
|
## 1.0.7
|
|
2
8
|
|
|
3
9
|
_released `2022-04-28`_
|
package/lib/index.js
CHANGED
|
@@ -10,11 +10,17 @@ const utils_1 = require("./utils");
|
|
|
10
10
|
*/
|
|
11
11
|
const scrub = (input, secretValues) => {
|
|
12
12
|
const sensitiveBank = (0, utils_1.makeSensitiveBank)(secretValues);
|
|
13
|
+
// Sort by string length first and then by letters.
|
|
14
|
+
// Otherwise, a sensitive bank {"abcdefg": "aa", "abcdefgh": "bb"} would censor {"api_key": "abcdefgh"}
|
|
15
|
+
// into {"api_key": "aah"} while the desired output is {"api_key": "bb"}.
|
|
16
|
+
const sortedKeys = Object.keys(sensitiveBank).sort((x, y) => x.length - y.length === 0 ? y.localeCompare(x) : y.length - x.length);
|
|
17
|
+
const sensitiveBankEntries = sortedKeys
|
|
18
|
+
.map((key) => [key, sensitiveBank[key]]);
|
|
13
19
|
const replacer = (val) => {
|
|
14
20
|
if (typeof val === 'string') {
|
|
15
21
|
let copiedVal = val;
|
|
16
22
|
// have to look for substrings in the value instead of looking for the value in the map
|
|
17
|
-
|
|
23
|
+
sensitiveBankEntries.forEach(([transformed, censored]) => {
|
|
18
24
|
copiedVal = (0, utils_1.replaceAll)(copiedVal, transformed, censored);
|
|
19
25
|
});
|
|
20
26
|
return copiedVal;
|