@solongate/proxy 0.81.8 → 0.81.10
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 +11 -2
- package/dist/shield.js +11 -2
- package/hooks/shield.mjs +17 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10970,8 +10970,17 @@ function startProxy(upstream) {
|
|
|
10970
10970
|
try {
|
|
10971
10971
|
if (body.length && (req.headers["content-type"] || "").includes("json")) {
|
|
10972
10972
|
const parsed = JSON.parse(body.toString("utf-8"));
|
|
10973
|
-
|
|
10974
|
-
|
|
10973
|
+
if (parsed && typeof parsed === "object" && Array.isArray(parsed["messages"])) {
|
|
10974
|
+
if (parsed["system"] !== void 0) parsed["system"] = redactDeep(parsed["system"], cfg);
|
|
10975
|
+
const msgs = parsed["messages"];
|
|
10976
|
+
for (let i = 0; i < msgs.length; i++) {
|
|
10977
|
+
const m = msgs[i];
|
|
10978
|
+
if (m && m["role"] !== "assistant") msgs[i] = redactDeep(m, cfg);
|
|
10979
|
+
}
|
|
10980
|
+
body = Buffer.from(JSON.stringify(parsed), "utf-8");
|
|
10981
|
+
} else {
|
|
10982
|
+
body = Buffer.from(JSON.stringify(redactDeep(parsed, cfg)), "utf-8");
|
|
10983
|
+
}
|
|
10975
10984
|
}
|
|
10976
10985
|
} catch {
|
|
10977
10986
|
}
|
package/dist/shield.js
CHANGED
|
@@ -211,8 +211,17 @@ function startProxy(upstream) {
|
|
|
211
211
|
try {
|
|
212
212
|
if (body.length && (req.headers["content-type"] || "").includes("json")) {
|
|
213
213
|
const parsed = JSON.parse(body.toString("utf-8"));
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
if (parsed && typeof parsed === "object" && Array.isArray(parsed["messages"])) {
|
|
215
|
+
if (parsed["system"] !== void 0) parsed["system"] = redactDeep(parsed["system"], cfg);
|
|
216
|
+
const msgs = parsed["messages"];
|
|
217
|
+
for (let i = 0; i < msgs.length; i++) {
|
|
218
|
+
const m = msgs[i];
|
|
219
|
+
if (m && m["role"] !== "assistant") msgs[i] = redactDeep(m, cfg);
|
|
220
|
+
}
|
|
221
|
+
body = Buffer.from(JSON.stringify(parsed), "utf-8");
|
|
222
|
+
} else {
|
|
223
|
+
body = Buffer.from(JSON.stringify(redactDeep(parsed, cfg)), "utf-8");
|
|
224
|
+
}
|
|
216
225
|
}
|
|
217
226
|
} catch {
|
|
218
227
|
}
|
package/hooks/shield.mjs
CHANGED
|
@@ -220,21 +220,25 @@ function startProxy(upstream) {
|
|
|
220
220
|
try {
|
|
221
221
|
if (body.length && String(req.headers['content-type'] || '').includes('json')) {
|
|
222
222
|
const parsed = JSON.parse(body.toString('utf-8'));
|
|
223
|
-
//
|
|
224
|
-
// conversation on every
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
223
|
+
// Redact EVERY request, not just the last message. Claude Code re-sends
|
|
224
|
+
// the ORIGINAL (unredacted) conversation on every call — it stores the raw
|
|
225
|
+
// history and rebuilds the request each time, so the shield must re-scan
|
|
226
|
+
// it every request. Redacting only the newest message leaked any secret
|
|
227
|
+
// sitting in an earlier message: the user's own turn often lands at
|
|
228
|
+
// messages[0] with later messages after it, and a one-shot `-p` run has no
|
|
229
|
+
// prior request in which history could have been redacted. Scan the system
|
|
230
|
+
// prompt and every USER-role message (fresh input + tool results like an
|
|
231
|
+
// `ls`/Read result); skip ASSISTANT-role messages (model-generated prose —
|
|
232
|
+
// the bulk of a long session and not a secret source) so cost stays low.
|
|
233
|
+
if (parsed && typeof parsed === 'object' && Array.isArray(parsed.messages)) {
|
|
234
|
+
if (parsed.system !== undefined) parsed.system = redactDeep(parsed.system, cfg);
|
|
235
|
+
for (let i = 0; i < parsed.messages.length; i++) {
|
|
236
|
+
const m = parsed.messages[i];
|
|
237
|
+
if (m && m.role !== 'assistant') parsed.messages[i] = redactDeep(m, cfg);
|
|
238
|
+
}
|
|
235
239
|
body = Buffer.from(JSON.stringify(parsed), 'utf-8');
|
|
236
240
|
} else {
|
|
237
|
-
// Non-messages payload (rare) → redact it
|
|
241
|
+
// Non-messages payload (rare) → redact it whole.
|
|
238
242
|
body = Buffer.from(JSON.stringify(redactDeep(parsed, cfg)), 'utf-8');
|
|
239
243
|
}
|
|
240
244
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.10",
|
|
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": {
|