@link-foundation/sensitive-data-sanitizer 0.21.1 → 0.21.2
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/package.json +1 -1
- package/src/credential-spans.js +13 -1
- package/src/credentials.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b5bc2e1: Preserve prose after an existing credential mask on repeated plaintext and encoded sanitization passes, while continuing to detect later credentials and exact known secrets.
|
|
8
|
+
|
|
3
9
|
## 0.21.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@link-foundation/sensitive-data-sanitizer",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "Offline sensitive-text sanitization with credential, multilingual personal-data and scanner union detection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/credential-spans.js
CHANGED
|
@@ -107,13 +107,25 @@ function narrowed(text, finding) {
|
|
|
107
107
|
return parts ? parts.map((part) => ({ ...finding, ...part })) : [finding];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// A complete existing mask bounds context too: vendor rules no longer match
|
|
111
|
+
// it on the next pass. Only strip sentence punctuation, never a glued suffix.
|
|
112
|
+
function maskedPrefix(text, start, end) {
|
|
113
|
+
const token = /^[^\s]+/u.exec(text.slice(start, end))?.[0] ?? '';
|
|
114
|
+
let length = token.length;
|
|
115
|
+
while (length > 0 && /[.,;:!?]/.test(token[length - 1])) {
|
|
116
|
+
length--;
|
|
117
|
+
}
|
|
118
|
+
const value = token.slice(0, length);
|
|
119
|
+
return maskedValue(value) ? start + value.length : end;
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
// `token: ghp_… . Next sentence` — a context value that a vendor rule ends
|
|
111
123
|
// earlier stops at that end when only punctuation or a space follows.
|
|
112
124
|
function bounded(text, finding, findings) {
|
|
113
125
|
if (!openEnded.has(finding.rule) || finding.category !== 'credential') {
|
|
114
126
|
return finding;
|
|
115
127
|
}
|
|
116
|
-
let end = finding.end;
|
|
128
|
+
let end = maskedPrefix(text, finding.start, finding.end);
|
|
117
129
|
for (const other of findings) {
|
|
118
130
|
if (
|
|
119
131
|
other.category === 'credential' &&
|
package/src/credentials.js
CHANGED
|
@@ -56,7 +56,10 @@ export function templatedCredential(text, finding) {
|
|
|
56
56
|
}
|
|
57
57
|
// A template glued to literal characters (`<x>abc`, `[A]x9`) is not one.
|
|
58
58
|
const after = text[finding.start + value.length] ?? '';
|
|
59
|
-
|
|
59
|
+
const sentenceEnd = /^[.,;:!?]+(?:\s|$)/.test(
|
|
60
|
+
text.slice(finding.start + value.length)
|
|
61
|
+
);
|
|
62
|
+
return (!/[\w$%+/=.-]/.test(after) || sentenceEnd) && templatedValue(value);
|
|
60
63
|
}
|
|
61
64
|
// Only variable references and the documented gh lookup are exempt. Arbitrary
|
|
62
65
|
// shell commands and Actions expressions can contain literal credentials.
|