@microsoft/omnichannel-chat-widget 1.0.2 → 1.0.3-main.05297ce
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.
|
@@ -28,22 +28,25 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
28
28
|
});
|
|
29
29
|
return action;
|
|
30
30
|
}
|
|
31
|
-
let isRuleMatched = false;
|
|
32
31
|
for (const ruleId of Object.keys(regexCollection)) {
|
|
33
32
|
const item = regexCollection[ruleId];
|
|
34
33
|
if (item) {
|
|
34
|
+
let ruleInfiniteException = false;
|
|
35
|
+
let ruleApplied = false;
|
|
35
36
|
try {
|
|
36
37
|
const regex = new RegExp(item, "gi");
|
|
37
38
|
let match;
|
|
38
39
|
// eslint-disable-next-line no-cond-assign
|
|
39
40
|
while (match = regex.exec(text)) {
|
|
40
41
|
const replaceStr = match[0].replace(/./gi, maskedChar);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const modifiedText = text.replace(match[0], replaceStr);
|
|
43
|
+
if (modifiedText == text) {
|
|
44
|
+
ruleInfiniteException = true;
|
|
45
|
+
console.warn(`The data masking rule ${item} is ignored because it matches empty strings. Please modify this rule.`);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
ruleApplied = true;
|
|
49
|
+
text = modifiedText;
|
|
47
50
|
}
|
|
48
51
|
} catch (err) {
|
|
49
52
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -54,11 +57,21 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (ruleApplied) {
|
|
61
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
62
|
+
Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplied,
|
|
63
|
+
Description: `Data Masking Rule Id: ${ruleId} applied.`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (ruleInfiniteException) {
|
|
67
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
68
|
+
Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplyFailed,
|
|
69
|
+
ExceptionDetails: {
|
|
70
|
+
RuleId: ruleId,
|
|
71
|
+
Exception: "The data masking rule matches empty strings."
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
action.payload.text = text;
|
|
@@ -22,22 +22,25 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
22
22
|
});
|
|
23
23
|
return action;
|
|
24
24
|
}
|
|
25
|
-
let isRuleMatched = false;
|
|
26
25
|
for (const ruleId of Object.keys(regexCollection)) {
|
|
27
26
|
const item = regexCollection[ruleId];
|
|
28
27
|
if (item) {
|
|
28
|
+
let ruleInfiniteException = false;
|
|
29
|
+
let ruleApplied = false;
|
|
29
30
|
try {
|
|
30
31
|
const regex = new RegExp(item, "gi");
|
|
31
32
|
let match;
|
|
32
33
|
// eslint-disable-next-line no-cond-assign
|
|
33
34
|
while (match = regex.exec(text)) {
|
|
34
35
|
const replaceStr = match[0].replace(/./gi, maskedChar);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const modifiedText = text.replace(match[0], replaceStr);
|
|
37
|
+
if (modifiedText == text) {
|
|
38
|
+
ruleInfiniteException = true;
|
|
39
|
+
console.warn(`The data masking rule ${item} is ignored because it matches empty strings. Please modify this rule.`);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
ruleApplied = true;
|
|
43
|
+
text = modifiedText;
|
|
41
44
|
}
|
|
42
45
|
} catch (err) {
|
|
43
46
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
@@ -48,11 +51,21 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
48
51
|
}
|
|
49
52
|
});
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
if (ruleApplied) {
|
|
55
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
56
|
+
Event: TelemetryEvent.DataMaskingRuleApplied,
|
|
57
|
+
Description: `Data Masking Rule Id: ${ruleId} applied.`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (ruleInfiniteException) {
|
|
61
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
62
|
+
Event: TelemetryEvent.DataMaskingRuleApplyFailed,
|
|
63
|
+
ExceptionDetails: {
|
|
64
|
+
RuleId: ruleId,
|
|
65
|
+
Exception: "The data masking rule matches empty strings."
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
action.payload.text = text;
|