fix: sensitive keyword detection may produce false positives (#7881)

This commit is contained in:
Manuel
2022-03-24 02:54:07 +01:00
committed by GitHub
parent 765cfd02dc
commit 0d6f9e951d
3 changed files with 20 additions and 5 deletions

View File

@@ -341,9 +341,9 @@ class Utils {
* @returns {Boolean} True if a match was found, false otherwise.
*/
static objectContainsKeyValue(obj, key, value) {
const isMatch = (a, b) => (typeof a === 'string' && new RegExp(a).test(b)) || a === b;
const isKeyMatch = k => isMatch(key, k);
const isValueMatch = v => isMatch(value, v);
const isMatch = (a, b) => (typeof a === 'string' && new RegExp(b).test(a)) || a === b;
const isKeyMatch = k => isMatch(k, key);
const isValueMatch = v => isMatch(v, value);
for (const [k, v] of Object.entries(obj)) {
if (key !== undefined && value === undefined && isKeyMatch(k)) {
return true;