leakshield 0.5.4 → 0.5.5

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.
Files changed (2) hide show
  1. package/dist/core/wire.js +45 -4
  2. package/package.json +1 -1
package/dist/core/wire.js CHANGED
@@ -41,6 +41,7 @@
41
41
  * then bypass rewriting; source errors and cancellation remain failures.
42
42
  * Non-stream restoration failures are recovered by the session hook.
43
43
  */
44
+ import { createHash } from "node:crypto";
44
45
  import { containsTokenPrefix, PSEUDONYM_TOKEN_PREFIXES, } from "../decision/pseudonymization.js";
45
46
  import { walkSchemaStrings } from "../decision/schema-strings.js";
46
47
  import { createRecoveringSseStream } from "./sse-recovery.js";
@@ -67,8 +68,8 @@ const STREAM_BUFFER_LIMIT = "LeakShield blocked an oversized stream buffer.";
67
68
  * and user-facing errors. Existing substring assertions keep passing: the
68
69
  * base sentence is unchanged and the code is appended in brackets.
69
70
  */
70
- function refusal(code) {
71
- return `${UNSUPPORTED_REQUEST_BODY} [${code}]`;
71
+ function refusal(code, detail) {
72
+ return `${UNSUPPORTED_REQUEST_BODY} [${detail === undefined ? code : `${code}:${detail}`}]`;
72
73
  }
73
74
  /**
74
75
  * All byte caps are UTF-8 bytes (not UTF-16 code units): the bound is a memory
@@ -1176,6 +1177,45 @@ function validateResponsesReasoningParts(parts) {
1176
1177
  }
1177
1178
  }
1178
1179
  }
1180
+ /**
1181
+ * Standard Responses input item types this masker recognizes but still
1182
+ * refuses (issue #148). Membership only lets the refusal name the type: an
1183
+ * item reference or an unhandled tool-call output points at content the
1184
+ * masker has not seen, so it cannot be placed or scanned and keeps refusing.
1185
+ */
1186
+ const UNSUPPORTED_RESPONSES_ITEM_TYPES = new Set([
1187
+ "item_reference",
1188
+ "local_shell_call",
1189
+ "local_shell_call_output",
1190
+ "shell_call",
1191
+ "shell_call_output",
1192
+ "apply_patch_call",
1193
+ "apply_patch_call_output",
1194
+ "web_search_call",
1195
+ "file_search_call",
1196
+ "computer_call",
1197
+ "computer_call_output",
1198
+ "image_generation_call",
1199
+ "code_interpreter_call",
1200
+ "mcp_call",
1201
+ "mcp_list_tools",
1202
+ "mcp_approval_request",
1203
+ "mcp_approval_response",
1204
+ ]);
1205
+ /**
1206
+ * Content-free label for a refused input item (issue #148): a standard
1207
+ * protocol type is named as-is; anything else appears only as a short digest
1208
+ * and its length, because an unhandled `type` string is host-controlled text
1209
+ * that must not reach the log.
1210
+ */
1211
+ function describeRefusedItemType(type) {
1212
+ if (typeof type !== "string")
1213
+ return `non-string-${type === null ? "null" : typeof type}`;
1214
+ if (UNSUPPORTED_RESPONSES_ITEM_TYPES.has(type))
1215
+ return type;
1216
+ const digest = createHash("sha256").update(type).digest("hex").slice(0, 8);
1217
+ return `unknown-${digest}-len${type.length}`;
1218
+ }
1179
1219
  function validateResponsesInputItem(item, allowAttachments) {
1180
1220
  if (typeof item === "string")
1181
1221
  return;
@@ -1244,8 +1284,9 @@ function validateResponsesInputItem(item, allowAttachments) {
1244
1284
  }
1245
1285
  return;
1246
1286
  default:
1247
- // item_reference / unknown: cannot verify or place.
1248
- throw new Error(refusal("responses-item-type"));
1287
+ // item_reference / unknown: cannot verify or place. The refusal names
1288
+ // the type (content-free) so a host-log failure is attributable.
1289
+ throw new Error(refusal("responses-item-type", describeRefusedItemType(item.type)));
1249
1290
  }
1250
1291
  }
1251
1292
  function validateResponsesDialect(body, allowAttachments) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leakshield",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Masks sensitive content before it reaches an AI model: OpenCode plugin, pi extension, Claude Code proxy, CLI, and web scanner",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jared Wang",