leakshield 0.1.0 → 0.1.1
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/README.md +4 -4
- package/README.zh-TW.md +2 -2
- package/dist/decision/ingress.js +2 -2
- package/dist/opencode-hooks.js +2 -2
- package/dist/opencode-transparent-aisdk.js +3 -3
- package/dist/opencode-transparent-http.js +7 -7
- package/dist/opencode-transparent-ws.js +4 -4
- package/dist/opencode-transparent.js +10 -10
- package/dist/opencode-v2.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ MCP server mode has been removed. It depended on the model voluntarily calling a
|
|
|
24
24
|
|
|
25
25
|
## Project status
|
|
26
26
|
|
|
27
|
-
**Experimental, pre-release.**
|
|
27
|
+
**Experimental, pre-release.** Published to npm as `leakshield` (`0.1.x`): run `npx leakshield`, or build locally (`npm ci && npm run build`) and point OpenCode at the `dist` directory.
|
|
28
28
|
|
|
29
29
|
- Transparent mode has been verified on OpenCode v2.0.28 with local loopback providers, and once against a real OpenAI model. It is **not** a guarantee that nothing sensitive reaches a model: the recommended hook-first setup is reported as `PARTIAL` by `--doctor`, and content added after the plugin's hooks or sent by permitted tools (curl, remote MCP) is outside its coverage.
|
|
30
30
|
- Not yet verified: OS-keychain persistence, a real Anthropic provider, long histories on other providers, long-running use ([#26](https://github.com/jwcrystal/leakshield/issues/26)).
|
|
@@ -99,9 +99,9 @@ npm install
|
|
|
99
99
|
npm run build
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
`npx leakshield …` runs the published package. For local development, install
|
|
103
|
+
the build globally or `npm link` it, then use `leakshield` directly.
|
|
104
|
+
`npm run scan -- ...` works from this repository without installing.
|
|
105
105
|
|
|
106
106
|
### npm Scripts
|
|
107
107
|
|
package/README.zh-TW.md
CHANGED
|
@@ -24,7 +24,7 @@ MCP Server 模式已移除。它依賴模型在已收到相關 context 後自行
|
|
|
24
24
|
|
|
25
25
|
## 目前狀態
|
|
26
26
|
|
|
27
|
-
**實驗性,尚未正式發佈。**
|
|
27
|
+
**實驗性,尚未正式發佈。** 已發佈到 npm(`leakshield`,`0.1.x`):可直接用 `npx leakshield`,或在本機建置(`npm ci && npm run build`)再讓 OpenCode 指向 `dist` 目錄。
|
|
28
28
|
|
|
29
29
|
- Transparent 模式已在 OpenCode v2.0.28 搭配本機替身 provider 驗證,並用真實 OpenAI 模型驗證過一次。它**不保證**敏感內容絕不會送到模型:建議的 hook-first 設定在 `--doctor` 顯示為 `PARTIAL`,hook 之後才加入的內容,以及被允許的工具外送(curl、遠端 MCP),都不在保護範圍內。
|
|
30
30
|
- 尚未驗證:OS keychain 持久化、真實 Anthropic provider、其他 provider 的長對話、長時間使用([#26](https://github.com/jwcrystal/leakshield/issues/26))。
|
|
@@ -104,7 +104,7 @@ npm install
|
|
|
104
104
|
npm run build
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
`npx leakshield …` 會執行已發佈的套件。本機開發時,全域安裝或 `npm link` 這份 build 後即可直接使用
|
|
108
108
|
`leakshield`;在此 repository 內不用安裝,直接用 `npm run scan -- ...` 即可。
|
|
109
109
|
|
|
110
110
|
### npm scripts 速查
|
package/dist/decision/ingress.js
CHANGED
|
@@ -4,7 +4,7 @@ import { redactAndVerify } from "../scanner/redaction-verifier.js";
|
|
|
4
4
|
const DEFAULT_CACHE_SIZE = 512;
|
|
5
5
|
export function blockedText(context, totalFindings) {
|
|
6
6
|
const count = totalFindings === 0 ? "unscanned" : `${totalFindings} sensitive item(s)`;
|
|
7
|
-
return `[LeakShield blocked ${context}: ${count}.
|
|
7
|
+
return `[LeakShield blocked ${context}: ${count}. The original was not sent to the model.]`;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Returns text that is safe to place in an LLM context. Content that exceeds
|
|
@@ -121,7 +121,7 @@ export function protectUnknownStrings(value, config, options, protector = protec
|
|
|
121
121
|
return copy;
|
|
122
122
|
}
|
|
123
123
|
if (!isPlainRecord(value)) {
|
|
124
|
-
return "[LeakShield blocked unsupported metadata value.]";
|
|
124
|
+
return "[LeakShield blocked an unsupported metadata value.]";
|
|
125
125
|
}
|
|
126
126
|
const copy = {};
|
|
127
127
|
seen.set(value, copy);
|
package/dist/opencode-hooks.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ContentHashCache, protectUnknownStrings, } from "./decision/ingress.js";
|
|
2
|
-
const INITIALIZATION_ERROR = "LeakShield initialization failed
|
|
2
|
+
const INITIALIZATION_ERROR = "LeakShield initialization failed, so the request was blocked before anything was sent.";
|
|
3
3
|
function blockedAttachment(part) {
|
|
4
4
|
return {
|
|
5
5
|
id: part.id,
|
|
6
6
|
sessionID: part.sessionID,
|
|
7
7
|
messageID: part.messageID,
|
|
8
8
|
type: "text",
|
|
9
|
-
text: "[LeakShield blocked an attachment
|
|
9
|
+
text: "[LeakShield blocked an attachment: its content cannot be scanned, so it was not sent.]",
|
|
10
10
|
synthetic: true,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* the supported contract (including any private sockets/global-fetch path). */
|
|
6
6
|
import { types } from "node:util";
|
|
7
7
|
import { classifyModelRoute } from "./opencode-transparent-http.js";
|
|
8
|
-
const ADMISSION_ERROR = "LeakShield
|
|
9
|
-
const DISPOSED_ERROR = "LeakShield
|
|
10
|
-
const PROTECTION_ERROR = "LeakShield
|
|
8
|
+
const ADMISSION_ERROR = "LeakShield blocked an unsupported route. The provider must use the fetch OpenCode injects.";
|
|
9
|
+
const DISPOSED_ERROR = "LeakShield blocked a request on an inactive AI SDK transport.";
|
|
10
|
+
const PROTECTION_ERROR = "LeakShield blocked an AI SDK request. Check its protocol, metadata and content, then try again.";
|
|
11
11
|
function optionsOf(event) {
|
|
12
12
|
if (types.isProxy(event))
|
|
13
13
|
throw new Error(ADMISSION_ERROR);
|
|
@@ -48,13 +48,13 @@ import { createRecoveringSseStream } from "./opencode-transparent-stream.js";
|
|
|
48
48
|
const warnDegradation = (context) => {
|
|
49
49
|
console.warn(`[leakshield] degraded: ${context}`);
|
|
50
50
|
};
|
|
51
|
-
const UNSUPPORTED_REQUEST_BODY = "LeakShield
|
|
52
|
-
const UNSUPPORTED_TRANSPORT = "LeakShield
|
|
53
|
-
const MASK_FAILURE = "LeakShield
|
|
54
|
-
const UNSUPPORTED_RESPONSE = "LeakShield
|
|
55
|
-
const RESTORE_FAILURE = "LeakShield
|
|
56
|
-
const MALFORMED_STREAM = "LeakShield
|
|
57
|
-
const STREAM_BUFFER_LIMIT = "LeakShield
|
|
51
|
+
const UNSUPPORTED_REQUEST_BODY = "LeakShield blocked the request because its body is unsupported or could not be identified.";
|
|
52
|
+
const UNSUPPORTED_TRANSPORT = "LeakShield blocked a request on an unsupported route.";
|
|
53
|
+
const MASK_FAILURE = "LeakShield blocked the request because it could not be masked safely.";
|
|
54
|
+
const UNSUPPORTED_RESPONSE = "LeakShield blocked a response it could not restore safely.";
|
|
55
|
+
const RESTORE_FAILURE = "LeakShield blocked the response because it could not be restored safely.";
|
|
56
|
+
const MALFORMED_STREAM = "LeakShield blocked a malformed or incomplete stream.";
|
|
57
|
+
const STREAM_BUFFER_LIMIT = "LeakShield blocked an oversized stream buffer.";
|
|
58
58
|
/**
|
|
59
59
|
* Content-free refusal classification (2026-10-08): every request refusal
|
|
60
60
|
* appends a fixed code naming WHICH check failed — the refusal-policy spec
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* OpenCode exposes no connection ID; attribution uses the hook's session,
|
|
5
5
|
* kind and model lane, then the provider's response ID. */
|
|
6
6
|
import { admitModelRequest, classifyModelRoute, remaskResponsesRequest, RESPONSES_TEXT_DELTA_TYPES, RESPONSES_TEXT_DONE_TYPES, restoreDisplayText, restoreResponsesEventDisplay, splitRestorable, } from "./opencode-transparent-http.js";
|
|
7
|
-
const ROUTE_ERROR = "LeakShield
|
|
8
|
-
const FRAME_ERROR = "LeakShield
|
|
9
|
-
const ATTRIBUTION_ERROR = "LeakShield
|
|
10
|
-
const LIMIT_ERROR = "LeakShield
|
|
7
|
+
const ROUTE_ERROR = "LeakShield blocked a request on an unsupported route.";
|
|
8
|
+
const FRAME_ERROR = "LeakShield blocked an unsupported or malformed WebSocket frame.";
|
|
9
|
+
const ATTRIBUTION_ERROR = "LeakShield blocked a WebSocket frame that could not be matched to a request.";
|
|
10
|
+
const LIMIT_ERROR = "LeakShield blocked an oversized WebSocket buffer.";
|
|
11
11
|
const MAX_FRAME_BYTES = 4 * 1024 * 1024;
|
|
12
12
|
const MAX_LANES = 1024;
|
|
13
13
|
const MAX_CHANNELS = 256;
|
|
@@ -46,16 +46,16 @@ import { createResponsesWebSocketAdapter } from "./opencode-transparent-ws.js";
|
|
|
46
46
|
import { createAISDKTransportAdmission } from "./opencode-transparent-aisdk.js";
|
|
47
47
|
import { BUILTIN_RULES } from "./rules/builtin.js";
|
|
48
48
|
// ─── Static failure messages (no content ever included) ─────────────────────
|
|
49
|
-
const INITIALIZATION_ERROR = "LeakShield initialization failed
|
|
50
|
-
const PROTECT_FAILED_ERROR = "LeakShield
|
|
51
|
-
const ATTRIBUTION_ERROR = "LeakShield
|
|
52
|
-
const UNSUPPORTED_ROUTE_ERROR = "LeakShield
|
|
53
|
-
const TOOL_REFUSAL_ERROR = "LeakShield
|
|
54
|
-
const TOOL_UNKNOWN_MAPPING_ERROR = "LeakShield
|
|
55
|
-
const TOOL_RESTORE_LIMIT_ERROR = "LeakShield
|
|
56
|
-
const TOOL_SHELL_CONTEXT_ERROR = "LeakShield
|
|
57
|
-
const TOOL_INPUT_SHAPE_ERROR = "LeakShield
|
|
58
|
-
const STRUCTURAL_SENSITIVE_ERROR = "LeakShield
|
|
49
|
+
const INITIALIZATION_ERROR = "LeakShield initialization failed, so the request was blocked before anything was sent.";
|
|
50
|
+
const PROTECT_FAILED_ERROR = "LeakShield blocked a model request because it could not be masked safely.";
|
|
51
|
+
const ATTRIBUTION_ERROR = "LeakShield blocked a response because it could not be matched to a request.";
|
|
52
|
+
const UNSUPPORTED_ROUTE_ERROR = "LeakShield blocked a request on an unsupported route.";
|
|
53
|
+
const TOOL_REFUSAL_ERROR = "LeakShield blocked this tool call because its arguments could not be restored safely. Re-read the file and try again.";
|
|
54
|
+
const TOOL_UNKNOWN_MAPPING_ERROR = "LeakShield blocked this tool call because a placeholder has no mapping in this session. Re-read the file, then try again.";
|
|
55
|
+
const TOOL_RESTORE_LIMIT_ERROR = "LeakShield blocked this tool call because its arguments are too large to restore safely. Use smaller arguments and try again.";
|
|
56
|
+
const TOOL_SHELL_CONTEXT_ERROR = "LeakShield blocked this tool call because the shell command's quoting is not supported. Use a simple command with plain arguments, or a different tool.";
|
|
57
|
+
const TOOL_INPUT_SHAPE_ERROR = "LeakShield blocked this tool call because its argument structure cannot be safely restored. Use plain JSON values and try again.";
|
|
58
|
+
const STRUCTURAL_SENSITIVE_ERROR = "LeakShield blocked this request because a structural identifier (message or tool id, name, role, or part type) scans as sensitive and cannot be masked. Change it or adjust the matching rule, then try again.";
|
|
59
59
|
function toolRestoreError(reason) {
|
|
60
60
|
if (reason === "unknown_token" || reason === "malformed_token")
|
|
61
61
|
return TOOL_UNKNOWN_MAPPING_ERROR;
|
package/dist/opencode-v2.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createHmac } from "node:crypto";
|
|
|
2
2
|
import { ContentHashCache, protectUnknownStrings, } from "./decision/ingress.js";
|
|
3
3
|
import { deidentifyText } from "./decision/deidentify.js";
|
|
4
4
|
import { registerV2EnvTools } from "./opencode-env-tools.js";
|
|
5
|
-
const INITIALIZATION_ERROR = "LeakShield initialization failed
|
|
6
|
-
const BLOCKED_ATTACHMENT_NOTICE = "[LeakShield blocked an attachment
|
|
5
|
+
const INITIALIZATION_ERROR = "LeakShield initialization failed, so the request was blocked before anything was sent.";
|
|
6
|
+
const BLOCKED_ATTACHMENT_NOTICE = "[LeakShield blocked an attachment: its content cannot be scanned, so it was not sent.]";
|
|
7
7
|
function isRecordLike(value) {
|
|
8
8
|
return typeof value === "object" && value !== null;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leakshield",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenCode plugin, CLI, and web scanner for sensitive content before sending it to AI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=20"
|
|
35
35
|
},
|
|
36
36
|
"bin": {
|
|
37
|
-
"leakshield": "
|
|
37
|
+
"leakshield": "dist/cli.js"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|