@netlify/build 33.3.0 → 33.4.0
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.
|
@@ -84,6 +84,26 @@ export function getSecretKeysToScanFor(env, secretKeys) {
|
|
|
84
84
|
const filteredSecretKeys = filterOmittedKeys(env, secretKeys);
|
|
85
85
|
return filteredSecretKeys.filter((key) => !isValueTrivial(env[key]));
|
|
86
86
|
}
|
|
87
|
+
const getShannonEntropy = (str) => {
|
|
88
|
+
const len = str.length;
|
|
89
|
+
if (len === 0)
|
|
90
|
+
return 0;
|
|
91
|
+
const freqMap = {};
|
|
92
|
+
for (const char of str) {
|
|
93
|
+
freqMap[char] = (freqMap[char] || 0) + 1;
|
|
94
|
+
}
|
|
95
|
+
let entropy = 0;
|
|
96
|
+
for (const char in freqMap) {
|
|
97
|
+
const p = freqMap[char] / len;
|
|
98
|
+
entropy -= p * Math.log2(p);
|
|
99
|
+
}
|
|
100
|
+
return entropy;
|
|
101
|
+
};
|
|
102
|
+
const HIGH_ENTROPY_THRESHOLD = 4.5;
|
|
103
|
+
const doesEntropyMeetThresholdForSecret = (str) => {
|
|
104
|
+
const entropy = getShannonEntropy(str);
|
|
105
|
+
return entropy >= HIGH_ENTROPY_THRESHOLD;
|
|
106
|
+
};
|
|
87
107
|
// Most prefixes are 4-5 chars, so requiring 12 chars after ensures a reasonable secret length
|
|
88
108
|
const MIN_CHARS_AFTER_PREFIX = 12;
|
|
89
109
|
// Escape special regex characters (like $, *, +, etc) in prefixes so they're treated as literal characters
|
|
@@ -129,6 +149,10 @@ export function findLikelySecrets({ text, omitValuesFromEnhancedScan = [], }) {
|
|
|
129
149
|
if (!token || !prefix || allOmittedValues.includes(token)) {
|
|
130
150
|
continue;
|
|
131
151
|
}
|
|
152
|
+
// Despite the prefix, the string does not look random enough to be convinced it's a secret
|
|
153
|
+
if (!doesEntropyMeetThresholdForSecret(token)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
132
156
|
matches.push({
|
|
133
157
|
prefix,
|
|
134
158
|
index: match.index,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "33.
|
|
3
|
+
"version": "33.4.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -158,5 +158,5 @@
|
|
|
158
158
|
"engines": {
|
|
159
159
|
"node": ">=18.14.0"
|
|
160
160
|
},
|
|
161
|
-
"gitHead": "
|
|
161
|
+
"gitHead": "5289c05c1991824b24e3a8c38c8457bdc5534046"
|
|
162
162
|
}
|