@solongate/proxy 0.81.12 → 0.81.13
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/dist/index.js +6 -3
- package/dist/shield.js +6 -3
- package/hooks/audit.mjs +7 -4
- package/hooks/shield.mjs +7 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10923,15 +10923,18 @@ function dlpGlobToRe(glob, flags) {
|
|
|
10923
10923
|
function redactString(s, cfg) {
|
|
10924
10924
|
if (!cfg || typeof s !== "string" || !s) return s;
|
|
10925
10925
|
const allow = new Set(cfg.patterns);
|
|
10926
|
+
const NUL = String.fromCharCode(0);
|
|
10927
|
+
const labels = [];
|
|
10928
|
+
const stash = (label) => NUL + (labels.push(label) - 1) + NUL;
|
|
10926
10929
|
let out2 = s;
|
|
10927
|
-
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out2 = out2.replace(p.re, `[REDACTED: ${p.name}]`);
|
|
10930
|
+
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out2 = out2.replace(p.re, () => stash(`[REDACTED: ${p.name}]`));
|
|
10928
10931
|
for (const c2 of cfg.custom) {
|
|
10929
10932
|
try {
|
|
10930
|
-
out2 = out2.replace(dlpGlobToRe(c2.re, "gi"), `[REDACTED: ${c2.name || "custom"}]`);
|
|
10933
|
+
out2 = out2.replace(dlpGlobToRe(c2.re, "gi"), () => stash(`[REDACTED: ${c2.name || "custom"}]`));
|
|
10931
10934
|
} catch {
|
|
10932
10935
|
}
|
|
10933
10936
|
}
|
|
10934
|
-
return out2;
|
|
10937
|
+
return out2.replace(new RegExp(NUL + "(\\d+)" + NUL, "g"), (_, i) => labels[+i] || "");
|
|
10935
10938
|
}
|
|
10936
10939
|
function redactDeep(value, cfg) {
|
|
10937
10940
|
const ghost = cfg && Array.isArray(cfg.ghost) ? cfg.ghost : null;
|
package/dist/shield.js
CHANGED
|
@@ -164,15 +164,18 @@ function dlpGlobToRe(glob, flags) {
|
|
|
164
164
|
function redactString(s, cfg) {
|
|
165
165
|
if (!cfg || typeof s !== "string" || !s) return s;
|
|
166
166
|
const allow = new Set(cfg.patterns);
|
|
167
|
+
const NUL = String.fromCharCode(0);
|
|
168
|
+
const labels = [];
|
|
169
|
+
const stash = (label) => NUL + (labels.push(label) - 1) + NUL;
|
|
167
170
|
let out = s;
|
|
168
|
-
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out = out.replace(p.re, `[REDACTED: ${p.name}]`);
|
|
171
|
+
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out = out.replace(p.re, () => stash(`[REDACTED: ${p.name}]`));
|
|
169
172
|
for (const c of cfg.custom) {
|
|
170
173
|
try {
|
|
171
|
-
out = out.replace(dlpGlobToRe(c.re, "gi"), `[REDACTED: ${c.name || "custom"}]`);
|
|
174
|
+
out = out.replace(dlpGlobToRe(c.re, "gi"), () => stash(`[REDACTED: ${c.name || "custom"}]`));
|
|
172
175
|
} catch {
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
|
-
return out;
|
|
178
|
+
return out.replace(new RegExp(NUL + "(\\d+)" + NUL, "g"), (_, i) => labels[+i] || "");
|
|
176
179
|
}
|
|
177
180
|
function redactDeep(value, cfg) {
|
|
178
181
|
const ghost = cfg && Array.isArray(cfg.ghost) ? cfg.ghost : null;
|
package/hooks/audit.mjs
CHANGED
|
@@ -330,16 +330,19 @@ function dlpGlobToRe(glob, flags) {
|
|
|
330
330
|
return new RegExp(re, flags);
|
|
331
331
|
}
|
|
332
332
|
function dlpRedactText(text, cfg) {
|
|
333
|
-
if (!cfg || typeof text !==
|
|
333
|
+
if (!cfg || typeof text !== "string" || !text) return text;
|
|
334
334
|
const allow = new Set(Array.isArray(cfg.patterns) ? cfg.patterns : []);
|
|
335
|
+
const NUL = String.fromCharCode(0);
|
|
336
|
+
const labels = [];
|
|
337
|
+
const stash = (label) => NUL + (labels.push(label) - 1) + NUL;
|
|
335
338
|
let out = text;
|
|
336
339
|
for (const p of DLP_PATTERNS) {
|
|
337
|
-
if (allow.has(p.name)) out = out.replace(p.re,
|
|
340
|
+
if (allow.has(p.name)) out = out.replace(p.re, () => stash("[REDACTED:" + p.name + "]"));
|
|
338
341
|
}
|
|
339
342
|
for (const c of Array.isArray(cfg.custom) ? cfg.custom : []) {
|
|
340
|
-
try { out = out.replace(dlpGlobToRe(c.re,
|
|
343
|
+
try { out = out.replace(dlpGlobToRe(c.re, "gi"), () => stash("[REDACTED:" + (c.name || "custom") + "]")); } catch {}
|
|
341
344
|
}
|
|
342
|
-
return out;
|
|
345
|
+
return out.replace(new RegExp(NUL + "(\\d+)" + NUL, "g"), (_, i) => labels[+i] || "");
|
|
343
346
|
}
|
|
344
347
|
|
|
345
348
|
// Best-effort extraction of the model-visible text from a tool_response. Shapes
|
package/hooks/shield.mjs
CHANGED
|
@@ -171,14 +171,17 @@ function dlpGlobToRe(glob, flags) {
|
|
|
171
171
|
return new RegExp(re, flags);
|
|
172
172
|
}
|
|
173
173
|
function redactString(s, cfg) {
|
|
174
|
-
if (!cfg || typeof s !==
|
|
174
|
+
if (!cfg || typeof s !== "string" || !s) return s;
|
|
175
175
|
const allow = new Set(cfg.patterns);
|
|
176
|
+
const NUL = String.fromCharCode(0);
|
|
177
|
+
const labels = [];
|
|
178
|
+
const stash = (label) => NUL + (labels.push(label) - 1) + NUL;
|
|
176
179
|
let out = s;
|
|
177
|
-
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out = out.replace(p.re, `[REDACTED: ${p.name}]`);
|
|
180
|
+
for (const p of DLP_PATTERNS) if (allow.has(p.name)) out = out.replace(p.re, () => stash(`[REDACTED: ${p.name}]`));
|
|
178
181
|
for (const c of cfg.custom) {
|
|
179
|
-
try { out = out.replace(dlpGlobToRe(c.re,
|
|
182
|
+
try { out = out.replace(dlpGlobToRe(c.re, "gi"), () => stash(`[REDACTED: ${c.name || "custom"}]`)); } catch {}
|
|
180
183
|
}
|
|
181
|
-
return out;
|
|
184
|
+
return out.replace(new RegExp(NUL + "(\\d+)" + NUL, "g"), (_, i) => labels[+i] || "");
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
function redactDeep(value, cfg) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.13",
|
|
4
4
|
"description": "AI tool security proxy: protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. No code changes required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|