@zapier/secret-scrubber 1.0.6 → 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 +15 -3
- package/lib/convenience.js +8 -0
- package/lib/index.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
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
|
+
|
|
7
|
+
## 1.0.7
|
|
8
|
+
|
|
9
|
+
_released `2022-04-28`_
|
|
10
|
+
|
|
11
|
+
- add simple checks when checking if input is a url ([!7](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/7))
|
|
12
|
+
|
|
1
13
|
## 1.0.6
|
|
2
14
|
|
|
3
15
|
_released `2022-04-06`_
|
|
4
16
|
|
|
5
|
-
- tweak `findSensitiveValues` to no longer return _any_ url with a querystring. It's always tried to extract secrets from a url, but now doesn't fall back to censoring the whole url.
|
|
17
|
+
- tweak `findSensitiveValues` to no longer return _any_ url with a querystring. It's always tried to extract secrets from a url, but now doesn't fall back to censoring the whole url ([!6](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/6))
|
|
6
18
|
|
|
7
19
|
Calling `findSensitiveValues` with a structure containing urls:
|
|
8
20
|
|
|
@@ -16,13 +28,13 @@ Calling `findSensitiveValues` with a structure containing urls:
|
|
|
16
28
|
|
|
17
29
|
_released `2021-10-25`_
|
|
18
30
|
|
|
19
|
-
- Reduce `scrub` memory usage
|
|
31
|
+
- Reduce `scrub` memory usage ([!5](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/5))
|
|
20
32
|
|
|
21
33
|
## 1.0.4
|
|
22
34
|
|
|
23
35
|
_released `2021-10-04`_
|
|
24
36
|
|
|
25
|
-
- add `api-key` to sensitive substrings [!4](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/4)
|
|
37
|
+
- add `api-key` to sensitive substrings ([!4](https://gitlab.com/zapier/team-developer-platform/secret-scrubber-js/-/merge_requests/4))
|
|
26
38
|
|
|
27
39
|
## 1.0.3
|
|
28
40
|
|
package/lib/convenience.js
CHANGED
|
@@ -23,6 +23,14 @@ exports.SENSITIVE_SUBSTRINGS = [
|
|
|
23
23
|
* * has potentially secret information, such as a password or querystring
|
|
24
24
|
*/
|
|
25
25
|
const isUrlWithSecrets = (val) => {
|
|
26
|
+
// creating a URL object is a little expensive; perform a couple of quick checks first
|
|
27
|
+
if (typeof val !== 'string') {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
// if this doesn't start with http(s), it's probably not a url we care about
|
|
31
|
+
if (!val.startsWith('http')) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
26
34
|
let url;
|
|
27
35
|
try {
|
|
28
36
|
url = new url_1.URL(val);
|
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;
|