leakshield 0.3.0 → 0.4.0
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/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +39 -9
- package/README.zh-TW.md +38 -9
- package/dist/adapters/claude-code/capabilities.d.ts +14 -0
- package/dist/adapters/claude-code/capabilities.js +47 -0
- package/dist/adapters/claude-code/cli.d.ts +10 -0
- package/dist/adapters/claude-code/cli.js +51 -0
- package/dist/adapters/claude-code/doctor.d.ts +19 -0
- package/dist/adapters/claude-code/doctor.js +177 -0
- package/dist/adapters/claude-code/proxy.d.ts +47 -0
- package/dist/adapters/claude-code/proxy.js +348 -0
- package/dist/adapters/opencode/capabilities.d.ts +10 -0
- package/dist/adapters/opencode/capabilities.js +48 -0
- package/dist/adapters/opencode/doctor.d.ts +67 -0
- package/dist/{doctor.js → adapters/opencode/doctor.js} +16 -42
- package/dist/adapters/opencode/env-queries.d.ts +133 -0
- package/dist/adapters/opencode/env-tools.d.ts +20 -0
- package/dist/adapters/opencode/hooks.d.ts +4 -0
- package/dist/adapters/opencode/plugin.d.ts +12 -0
- package/dist/{opencode.js → adapters/opencode/plugin.js} +7 -7
- package/dist/adapters/opencode/tool-policy.d.ts +2 -0
- package/dist/adapters/opencode/tool-policy.js +23 -0
- package/dist/adapters/opencode/transparent-aisdk.d.ts +6 -0
- package/dist/{opencode-transparent-aisdk.js → adapters/opencode/transparent-aisdk.js} +1 -1
- package/dist/adapters/opencode/transparent.d.ts +66 -0
- package/dist/adapters/opencode/transparent.js +237 -0
- package/dist/adapters/opencode/v2.d.ts +20 -0
- package/dist/{opencode-v2.js → adapters/opencode/v2.js} +3 -3
- package/dist/adapters/pi/capabilities.d.ts +10 -0
- package/dist/adapters/pi/capabilities.js +50 -0
- package/dist/adapters/pi/doctor.d.ts +26 -0
- package/dist/adapters/pi/doctor.js +276 -0
- package/dist/adapters/pi/extension.d.ts +28 -0
- package/dist/adapters/pi/extension.js +109 -0
- package/dist/adapters/pi/guard.d.ts +33 -0
- package/dist/adapters/pi/guard.js +154 -0
- package/dist/adapters/pi/persistence.d.ts +9 -0
- package/dist/adapters/pi/persistence.js +69 -0
- package/dist/adapters/pi/settings.d.ts +51 -0
- package/dist/adapters/pi/settings.js +136 -0
- package/dist/adapters/pi/tool-policy.d.ts +11 -0
- package/dist/adapters/pi/tool-policy.js +114 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.js +17 -6
- package/dist/config/loader.d.ts +70 -0
- package/dist/config/plain-object.d.ts +2 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +9 -0
- package/dist/core/session-guard.d.ts +61 -0
- package/dist/{opencode-transparent.js → core/session-guard.js} +55 -713
- package/dist/core/sse-recovery.d.ts +6 -0
- package/dist/core/tool-restore-policy.d.ts +153 -0
- package/dist/core/tool-restore-policy.js +453 -0
- package/dist/core/wire.d.ts +213 -0
- package/dist/{opencode-transparent-http.js → core/wire.js} +170 -50
- package/dist/core/ws.d.ts +26 -0
- package/dist/{opencode-transparent-ws.js → core/ws.js} +1 -1
- package/dist/decision/deidentify.d.ts +63 -0
- package/dist/decision/ingress.d.ts +40 -0
- package/dist/decision/mapping-key.d.ts +91 -0
- package/dist/decision/mapping-store.d.ts +166 -0
- package/dist/decision/model.d.ts +41 -0
- package/dist/decision/pseudonymization.d.ts +176 -0
- package/dist/decision/redaction.d.ts +56 -0
- package/dist/decision/schema-strings.d.ts +23 -0
- package/dist/decision/schema-strings.js +2 -2
- package/dist/decision/value-search.d.ts +39 -0
- package/dist/doctor-capabilities.d.ts +21 -0
- package/dist/doctor-capabilities.js +58 -0
- package/dist/doctor-hosts.d.ts +18 -0
- package/dist/doctor-hosts.js +144 -0
- package/dist/doctor-report.d.ts +45 -0
- package/dist/doctor-report.js +111 -0
- package/dist/forget.d.ts +18 -0
- package/dist/guard-options.d.ts +45 -0
- package/dist/{plugin-options.js → guard-options.js} +4 -1
- package/dist/help.d.ts +2 -0
- package/dist/help.js +15 -1
- package/dist/i18n/en.d.ts +65 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/zh-TW.d.ts +65 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/rules/builtin.d.ts +4 -0
- package/dist/rules/dynamic.d.ts +33 -0
- package/dist/scanner/allowlist.d.ts +22 -0
- package/dist/scanner/cidr.d.ts +39 -0
- package/dist/scanner/encoding.d.ts +87 -0
- package/dist/scanner/engine.d.ts +43 -0
- package/dist/scanner/exact-values.d.ts +11 -0
- package/dist/scanner/redaction-verifier.d.ts +24 -0
- package/dist/scanner/remotes.d.ts +29 -0
- package/dist/scanner/unicode.d.ts +57 -0
- package/dist/scanner/utils.d.ts +22 -0
- package/dist/transports/cli.d.ts +27 -0
- package/dist/transports/web-ui.d.ts +1 -0
- package/dist/transports/web-ui.js +1 -1
- package/dist/transports/web.d.ts +4 -0
- package/dist/types/capabilities.d.ts +67 -0
- package/dist/types/capabilities.js +133 -0
- package/dist/types.d.ts +149 -0
- package/dist/utils/files.d.ts +3 -0
- package/dist/utils/path-security.d.ts +18 -0
- package/dist/utils/win-encoding.d.ts +16 -0
- package/package.json +15 -5
- /package/dist/{env-queries.js → adapters/opencode/env-queries.js} +0 -0
- /package/dist/{opencode-env-tools.js → adapters/opencode/env-tools.js} +0 -0
- /package/dist/{opencode-hooks.js → adapters/opencode/hooks.js} +0 -0
- /package/dist/{opencode-transparent-stream.js → core/sse-recovery.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction helpers — deterministic replacement of sensitive spans
|
|
3
|
+
* and safe preview generation.
|
|
4
|
+
*
|
|
5
|
+
* Internal match metadata (match_start, match_end, match_text) is used
|
|
6
|
+
* for replacement but MUST NOT be exposed via transport-facing outputs.
|
|
7
|
+
*/
|
|
8
|
+
import type { Finding, GuardConfig, ScanResult, RedactResult } from "../types.js";
|
|
9
|
+
/** Keys that are internal-only and must never appear in transport-facing outputs. */
|
|
10
|
+
declare const INTERNAL_FINDING_KEYS: readonly ["match_start", "match_end", "match_text"];
|
|
11
|
+
type InternalFindingKey = (typeof INTERNAL_FINDING_KEYS)[number];
|
|
12
|
+
/** A finding with internal metadata stripped — safe for transport serialization. */
|
|
13
|
+
export type TransportSafeFinding = Omit<Finding, InternalFindingKey>;
|
|
14
|
+
/** A ScanResult with transport-safe findings. */
|
|
15
|
+
export interface TransportSafeScanResult extends Omit<ScanResult, "findings"> {
|
|
16
|
+
findings: TransportSafeFinding[];
|
|
17
|
+
}
|
|
18
|
+
/** A RedactResult with transport-safe findings. */
|
|
19
|
+
export interface TransportSafeRedactResult extends Omit<RedactResult, "findings"> {
|
|
20
|
+
findings: TransportSafeFinding[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Strip internal match metadata from a single finding.
|
|
24
|
+
* The returned object is safe to serialize to transport consumers.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sanitizeFindingForExport(f: Finding): TransportSafeFinding;
|
|
27
|
+
/**
|
|
28
|
+
* Strip internal match metadata from an array of findings.
|
|
29
|
+
*/
|
|
30
|
+
export declare function sanitizeFindingsForExport(findings: readonly Finding[]): TransportSafeFinding[];
|
|
31
|
+
/**
|
|
32
|
+
* Produce a transport-safe copy of a ScanResult by stripping internal
|
|
33
|
+
* match metadata from every finding.
|
|
34
|
+
*/
|
|
35
|
+
export declare function sanitizeScanResultForExport(result: ScanResult): TransportSafeScanResult;
|
|
36
|
+
/**
|
|
37
|
+
* Produce a transport-safe copy of a RedactResult by stripping internal
|
|
38
|
+
* match metadata from every finding.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sanitizeRedactResultForExport(result: RedactResult): TransportSafeRedactResult;
|
|
41
|
+
/**
|
|
42
|
+
* Build a safe preview of the original content.
|
|
43
|
+
*
|
|
44
|
+
* Returns a masked excerpt centered around the first finding,
|
|
45
|
+
* respecting `preview_length` from config (default 60).
|
|
46
|
+
* Returns undefined when no findings or no match metadata is available.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildSafePreview(originalContent: string, findings: readonly Finding[], config?: GuardConfig): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Build a fully redacted version of the original content.
|
|
51
|
+
*
|
|
52
|
+
* Replaces all sensitive spans with semantic placeholders.
|
|
53
|
+
* Returns undefined when no findings or match metadata is missing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function buildRedactedContent(originalContent: string, findings: readonly Finding[], _config?: GuardConfig): string | undefined;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural-string collection for JSON Schema subtrees, shared by the
|
|
3
|
+
* session-layer request guard (src/core/session-guard.ts) and the wire-layer
|
|
4
|
+
* remaskers (src/core/wire.ts) so the pre-mask safety check
|
|
5
|
+
* and the post-mask identity comparison can never drift apart.
|
|
6
|
+
*
|
|
7
|
+
* Structural identifiers (tool names, property keys, enum/const values, regex
|
|
8
|
+
* patterns) must survive masking verbatim: a sensitive or token-bearing one
|
|
9
|
+
* refuses the whole request rather than being silently renamed. Schema
|
|
10
|
+
* ANNOTATION values (`description`, `title` — human prose a provider never
|
|
11
|
+
* dispatches on) are deliberately NOT structural: they are protected as
|
|
12
|
+
* ordinary content leaves, so a scanner hit inside a tool-schema description
|
|
13
|
+
* masks to a pseudonym token instead of failing the request. Fail-closed is
|
|
14
|
+
* unchanged for every identifier position.
|
|
15
|
+
*/
|
|
16
|
+
/** JSON Schema annotation keywords whose VALUES are prose, not identifiers. */
|
|
17
|
+
export declare const SCHEMA_ANNOTATION_KEYS: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Keys and identifier values of a schema/metadata subtree, in stable walk
|
|
20
|
+
* order. Annotation-key VALUES are skipped (the key itself is still pushed so
|
|
21
|
+
* both sides of the before/after comparison see the same collection).
|
|
22
|
+
*/
|
|
23
|
+
export declare function walkSchemaStrings(out: string[], value: unknown): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structural-string collection for JSON Schema subtrees, shared by the
|
|
3
|
-
* session-layer request guard (src/
|
|
4
|
-
* remaskers (src/
|
|
3
|
+
* session-layer request guard (src/core/session-guard.ts) and the wire-layer
|
|
4
|
+
* remaskers (src/core/wire.ts) so the pre-mask safety check
|
|
5
5
|
* and the post-mask identity comparison can never drift apart.
|
|
6
6
|
*
|
|
7
7
|
* Structural identifiers (tool names, property keys, enum/const values, regex
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact-value search for the masking path: every occurrence of a set of
|
|
3
|
+
* detected values in one string, overlapping occurrences included.
|
|
4
|
+
*
|
|
5
|
+
* Searching each value with indexOf costs (values × text length), which is
|
|
6
|
+
* what limited how large a string the model path could afford. An Aho-Corasick
|
|
7
|
+
* automaton over UTF-16 code units costs (total value length + text length),
|
|
8
|
+
* plus the occurrences visited, but building one costs far more than a few
|
|
9
|
+
* indexOf calls and the value set can grow with every string of a request. So
|
|
10
|
+
* indexOf stays for small searches and the automaton takes over when the
|
|
11
|
+
* estimate favours it. Both strategies yield the same occurrences in the same
|
|
12
|
+
* order; tests/value-search.test.ts holds them to that.
|
|
13
|
+
*/
|
|
14
|
+
export type ValueSearchStrategy = "auto" | "indexOf" | "automaton";
|
|
15
|
+
/**
|
|
16
|
+
* Called for an occurrence of `value` at [start, end). Return true when the
|
|
17
|
+
* occurrence was taken. That promises every occurrence overlapping it would be
|
|
18
|
+
* rejected, so the search may skip those.
|
|
19
|
+
*/
|
|
20
|
+
export type OccurrenceVisitor = (start: number, end: number, value: string) => boolean;
|
|
21
|
+
export interface ValueSearch {
|
|
22
|
+
/** Number of distinct values the caller supplied, for detecting staleness. */
|
|
23
|
+
readonly sourceSize: number;
|
|
24
|
+
/**
|
|
25
|
+
* Visits occurrences longest value first, ties in input order, and each
|
|
26
|
+
* value's occurrences in ascending position.
|
|
27
|
+
*/
|
|
28
|
+
visitOccurrences(text: string, visit: OccurrenceVisitor): void;
|
|
29
|
+
/**
|
|
30
|
+
* True when every occurrence of every value lies inside one of `spans`, which
|
|
31
|
+
* must be ascending and disjoint. Spans out of order can only make this return
|
|
32
|
+
* false, never true.
|
|
33
|
+
*/
|
|
34
|
+
everyOccurrenceCovered(text: string, spans: readonly {
|
|
35
|
+
start: number;
|
|
36
|
+
end: number;
|
|
37
|
+
}[]): boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function createValueSearch(source: Iterable<string>, sourceSize: number, strategy?: ValueSearchStrategy): ValueSearch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a host's capability declaration for `leakshield --doctor`.
|
|
3
|
+
*
|
|
4
|
+
* The declaration is the only input: the doctor cannot print a row the adapter
|
|
5
|
+
* does not declare, and a test compares this output with the constant. `outside`
|
|
6
|
+
* and `unknown` rows are warnings because the host verdict is capped at PARTIAL
|
|
7
|
+
* by them.
|
|
8
|
+
*/
|
|
9
|
+
import { type HostCapabilities } from "./types/capabilities.js";
|
|
10
|
+
export interface CapabilityLine {
|
|
11
|
+
/** e.g. `cap.nonFetch` */
|
|
12
|
+
id: string;
|
|
13
|
+
state: "ok" | "warn";
|
|
14
|
+
detail: string;
|
|
15
|
+
note?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function capabilityLines(capabilities: HostCapabilities): CapabilityLine[];
|
|
18
|
+
export declare function capabilityHeader(capabilities: HostCapabilities): string;
|
|
19
|
+
export declare function capabilitySection(capabilities: HostCapabilities): string[];
|
|
20
|
+
/** One sentence for the host verdict line, or null when coverage is full. */
|
|
21
|
+
export declare function capabilityCapText(capabilities: HostCapabilities): string | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a host's capability declaration for `leakshield --doctor`.
|
|
3
|
+
*
|
|
4
|
+
* The declaration is the only input: the doctor cannot print a row the adapter
|
|
5
|
+
* does not declare, and a test compares this output with the constant. `outside`
|
|
6
|
+
* and `unknown` rows are warnings because the host verdict is capped at PARTIAL
|
|
7
|
+
* by them.
|
|
8
|
+
*/
|
|
9
|
+
import { CAPABILITY_ROWS, capabilityAt, capabilityVerdict, } from "./types/capabilities.js";
|
|
10
|
+
const WARN_STATES = new Set(["outside", "unknown"]);
|
|
11
|
+
function shortRow(row) {
|
|
12
|
+
return row.split(".")[1] ?? row;
|
|
13
|
+
}
|
|
14
|
+
export function capabilityLines(capabilities) {
|
|
15
|
+
return CAPABILITY_ROWS.map((row) => {
|
|
16
|
+
const capability = capabilityAt(capabilities, row);
|
|
17
|
+
return {
|
|
18
|
+
id: `cap.${shortRow(row)}`,
|
|
19
|
+
state: WARN_STATES.has(capability.state) ? "warn" : "ok",
|
|
20
|
+
detail: `${capability.state === "unknown" ? "UNKNOWN" : capability.state} — ${capability.mechanism}`,
|
|
21
|
+
note: capability.note,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function capabilityHeader(capabilities) {
|
|
26
|
+
return `Host capabilities — ${capabilities.host} (verified ${capabilities.verifiedVersion}, ${capabilities.interception})`;
|
|
27
|
+
}
|
|
28
|
+
export function capabilitySection(capabilities) {
|
|
29
|
+
const icon = { ok: "[OK] ", warn: "[WARN]" };
|
|
30
|
+
const lines = [capabilityHeader(capabilities)];
|
|
31
|
+
lines.push("Coverage scope: host-wide declaration; not filtered to the selected provider/model.");
|
|
32
|
+
lines.push(`Credential handling (declared): ${capabilities.credentials}`);
|
|
33
|
+
lines.push(`Mapping persistence (declared): ${capabilities.persistence}`);
|
|
34
|
+
for (const line of capabilityLines(capabilities)) {
|
|
35
|
+
lines.push(`${icon[line.state]} ${line.id}: ${line.detail}`);
|
|
36
|
+
if (line.note !== undefined)
|
|
37
|
+
lines.push(` note: ${line.note}`);
|
|
38
|
+
}
|
|
39
|
+
const coverage = capabilityVerdict(capabilities);
|
|
40
|
+
const reasons = [...coverage.unknown.map((row) => `${row} unknown`), ...coverage.outside.map((row) => `${row} outside`)];
|
|
41
|
+
lines.push(coverage.verdict === "PROTECTED"
|
|
42
|
+
? "Coverage: PROTECTED — every declared row is covered."
|
|
43
|
+
: `Coverage: PARTIAL — ${reasons.join("; ")}.`);
|
|
44
|
+
lines.push("Residuals (declared):");
|
|
45
|
+
if (capabilities.residuals.length === 0)
|
|
46
|
+
lines.push(" - none declared");
|
|
47
|
+
for (const residual of capabilities.residuals)
|
|
48
|
+
lines.push(` - ${residual}`);
|
|
49
|
+
return lines;
|
|
50
|
+
}
|
|
51
|
+
/** One sentence for the host verdict line, or null when coverage is full. */
|
|
52
|
+
export function capabilityCapText(capabilities) {
|
|
53
|
+
const coverage = capabilityVerdict(capabilities);
|
|
54
|
+
if (coverage.verdict === "PROTECTED")
|
|
55
|
+
return null;
|
|
56
|
+
const rows = [...coverage.unknown, ...coverage.outside];
|
|
57
|
+
return `${rows.length} declared row${rows.length === 1 ? "" : "s"} unknown or outside (${rows.join(", ")})`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DoctorCheck } from "./doctor-report.js";
|
|
2
|
+
import { type HostCapabilities } from "./types/capabilities.js";
|
|
3
|
+
export type DoctorTarget = "all" | "opencode" | "claude-code" | "pi";
|
|
4
|
+
/** Reads `--doctor=pi`, `--doctor pi`, or a bare `--doctor` (all). */
|
|
5
|
+
export declare function parseDoctorTarget(args: readonly string[]): DoctorTarget | {
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
/** A Claude Code check is protected only behind a healthy LeakShield proxy. */
|
|
9
|
+
export declare function claudeCodeVerdict(checks: readonly DoctorCheck[], capabilities?: HostCapabilities): {
|
|
10
|
+
exit: number;
|
|
11
|
+
verdict: string;
|
|
12
|
+
};
|
|
13
|
+
/** An installed pi extension protects the process; load order is a caveat. */
|
|
14
|
+
export declare function piVerdict(checks: readonly DoctorCheck[], capabilities?: HostCapabilities): {
|
|
15
|
+
exit: number;
|
|
16
|
+
verdict: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function runDoctorCommand(args: readonly string[]): Promise<number>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `leakshield --doctor [host]` dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Every host keeps its own checks and verdict. With no target the aggregate
|
|
5
|
+
* report decides as before; a target prints only that host and returns an exit
|
|
6
|
+
* code for it, so CI can check one integration without another host's state
|
|
7
|
+
* changing the answer.
|
|
8
|
+
*/
|
|
9
|
+
import { createDoctorDeps, runDoctor, } from "./adapters/opencode/doctor.js";
|
|
10
|
+
import { doctorExitCode, formatDoctorReport } from "./doctor-report.js";
|
|
11
|
+
import { createClaudeCodeDoctorDeps, runClaudeCodeDoctor } from "./adapters/claude-code/doctor.js";
|
|
12
|
+
import { createPiDoctorDeps, runPiDoctor } from "./adapters/pi/doctor.js";
|
|
13
|
+
import { CLAUDE_CODE_CAPABILITIES } from "./adapters/claude-code/capabilities.js";
|
|
14
|
+
import { PI_CAPABILITIES } from "./adapters/pi/capabilities.js";
|
|
15
|
+
import { OPENCODE_CAPABILITIES } from "./adapters/opencode/capabilities.js";
|
|
16
|
+
import { capabilityCapText, capabilitySection } from "./doctor-capabilities.js";
|
|
17
|
+
import { capabilityVerdict } from "./types/capabilities.js";
|
|
18
|
+
const TARGETS = new Set(["all", "opencode", "claude-code", "pi"]);
|
|
19
|
+
/** Reads `--doctor=pi`, `--doctor pi`, or a bare `--doctor` (all). */
|
|
20
|
+
export function parseDoctorTarget(args) {
|
|
21
|
+
const inline = args.find((arg) => arg.startsWith("--doctor="));
|
|
22
|
+
let raw;
|
|
23
|
+
if (inline !== undefined) {
|
|
24
|
+
raw = inline.slice("--doctor=".length);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const index = args.indexOf("--doctor");
|
|
28
|
+
const next = index === -1 ? undefined : args[index + 1];
|
|
29
|
+
if (next !== undefined && !next.startsWith("-"))
|
|
30
|
+
raw = next;
|
|
31
|
+
}
|
|
32
|
+
if (raw === undefined)
|
|
33
|
+
return "all";
|
|
34
|
+
if (raw.length === 0)
|
|
35
|
+
return { error: "doctor target is missing; use opencode, claude-code, pi or all" };
|
|
36
|
+
if (raw === "all")
|
|
37
|
+
return "all";
|
|
38
|
+
if (TARGETS.has(raw))
|
|
39
|
+
return raw;
|
|
40
|
+
return { error: `unknown doctor target "${raw}"; use opencode, claude-code, pi or all` };
|
|
41
|
+
}
|
|
42
|
+
const ICON = { ok: "[OK] ", warn: "[WARN]", fail: "[FAIL]", skip: "[SKIP]" };
|
|
43
|
+
function printSection(title, checks, verdict, capabilities) {
|
|
44
|
+
const lines = [`leakshield doctor — ${title}`];
|
|
45
|
+
for (const check of checks) {
|
|
46
|
+
lines.push(`${ICON[check.state]} ${check.id}: ${check.detail}`);
|
|
47
|
+
if (check.fix)
|
|
48
|
+
lines.push(` fix: ${check.fix}`);
|
|
49
|
+
}
|
|
50
|
+
if (capabilities) {
|
|
51
|
+
lines.push("");
|
|
52
|
+
lines.push(...capabilitySection(capabilities));
|
|
53
|
+
}
|
|
54
|
+
lines.push("");
|
|
55
|
+
lines.push(`Verdict: ${verdict}`);
|
|
56
|
+
console.log(lines.join("\n"));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A declaration can only lower a verdict. `unknown` and `outside` rows cap the
|
|
60
|
+
* host at PARTIAL even when its install-level checks pass; a broken install
|
|
61
|
+
* keeps its own failing verdict.
|
|
62
|
+
*/
|
|
63
|
+
function withCoverage(result, capabilities) {
|
|
64
|
+
if (capabilities === undefined)
|
|
65
|
+
return result;
|
|
66
|
+
if (capabilityVerdict(capabilities).verdict === "PROTECTED")
|
|
67
|
+
return result;
|
|
68
|
+
if (!result.verdict.startsWith("PROTECTED"))
|
|
69
|
+
return result;
|
|
70
|
+
return {
|
|
71
|
+
exit: result.exit,
|
|
72
|
+
verdict: `PARTIAL — coverage is partial: ${capabilityCapText(capabilities)}; see the capability rows above.`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** A Claude Code check is protected only behind a healthy LeakShield proxy. */
|
|
76
|
+
export function claudeCodeVerdict(checks, capabilities) {
|
|
77
|
+
return withCoverage(claudeCodeInstallVerdict(checks), capabilities);
|
|
78
|
+
}
|
|
79
|
+
function claudeCodeInstallVerdict(checks) {
|
|
80
|
+
if (checks.some((check) => check.state === "fail"))
|
|
81
|
+
return { exit: 1, verdict: "BROKEN" };
|
|
82
|
+
if (checks.every((check) => check.state === "skip")) {
|
|
83
|
+
return { exit: 1, verdict: "NOT INSTALLED — claude is not on PATH" };
|
|
84
|
+
}
|
|
85
|
+
if (checks.some((check) => check.id === "claude-code-provider" || check.id === "claude-code-host-managed")) {
|
|
86
|
+
return { exit: 1, verdict: "BYPASSED — a provider or host-managed setting skips the proxy" };
|
|
87
|
+
}
|
|
88
|
+
if (checks.some((check) => check.id === "claude-code-proxy" && check.state === "ok")) {
|
|
89
|
+
return { exit: 0, verdict: "PROTECTED — Claude Code is behind the LeakShield proxy" };
|
|
90
|
+
}
|
|
91
|
+
return { exit: 1, verdict: "NOT PROTECTED — Claude Code is not behind the proxy" };
|
|
92
|
+
}
|
|
93
|
+
/** An installed pi extension protects the process; load order is a caveat. */
|
|
94
|
+
export function piVerdict(checks, capabilities) {
|
|
95
|
+
return withCoverage(piInstallVerdict(checks), capabilities);
|
|
96
|
+
}
|
|
97
|
+
function piInstallVerdict(checks) {
|
|
98
|
+
if (checks.every((check) => check.state === "skip")) {
|
|
99
|
+
return { exit: 1, verdict: "NOT INSTALLED — pi is not on PATH" };
|
|
100
|
+
}
|
|
101
|
+
if (checks.some((check) => check.state === "fail"))
|
|
102
|
+
return { exit: 1, verdict: "BROKEN" };
|
|
103
|
+
const registered = checks.find((check) => check.id === "pi-extension-registered");
|
|
104
|
+
if (registered?.state === "ok") {
|
|
105
|
+
return { exit: 0, verdict: "PROTECTED — the extension guards pi's provider requests" };
|
|
106
|
+
}
|
|
107
|
+
if (registered?.state === "warn") {
|
|
108
|
+
return { exit: 0, verdict: "PARTIAL — pi's own requests are guarded; an extension loaded before LeakShield can bypass" };
|
|
109
|
+
}
|
|
110
|
+
return { exit: 1, verdict: "NOT VERIFIED — the extension is not in settings.extensions; a `-e` run is invisible to the doctor" };
|
|
111
|
+
}
|
|
112
|
+
export async function runDoctorCommand(args) {
|
|
113
|
+
const target = parseDoctorTarget(args);
|
|
114
|
+
if (typeof target === "object") {
|
|
115
|
+
console.error(`leakshield: ${target.error}`);
|
|
116
|
+
return 2;
|
|
117
|
+
}
|
|
118
|
+
if (target === "all") {
|
|
119
|
+
const report = await runDoctor(createDoctorDeps());
|
|
120
|
+
report.claudeCode = await runClaudeCodeDoctor(createClaudeCodeDoctorDeps());
|
|
121
|
+
report.pi = await runPiDoctor(createPiDoctorDeps());
|
|
122
|
+
report.capabilities = OPENCODE_CAPABILITIES;
|
|
123
|
+
report.claudeCodeCapabilities = CLAUDE_CODE_CAPABILITIES;
|
|
124
|
+
report.piCapabilities = PI_CAPABILITIES;
|
|
125
|
+
console.log(formatDoctorReport(report));
|
|
126
|
+
return doctorExitCode(report);
|
|
127
|
+
}
|
|
128
|
+
if (target === "opencode") {
|
|
129
|
+
const report = await runDoctor(createDoctorDeps());
|
|
130
|
+
report.capabilities = OPENCODE_CAPABILITIES;
|
|
131
|
+
console.log(formatDoctorReport(report));
|
|
132
|
+
return report.status === "PROTECTED" || report.status === "PARTIAL" ? 0 : 1;
|
|
133
|
+
}
|
|
134
|
+
if (target === "claude-code") {
|
|
135
|
+
const checks = await runClaudeCodeDoctor(createClaudeCodeDoctorDeps());
|
|
136
|
+
const { exit, verdict } = claudeCodeVerdict(checks, CLAUDE_CODE_CAPABILITIES);
|
|
137
|
+
printSection("Claude Code", checks, verdict, CLAUDE_CODE_CAPABILITIES);
|
|
138
|
+
return exit;
|
|
139
|
+
}
|
|
140
|
+
const checks = await runPiDoctor(createPiDoctorDeps());
|
|
141
|
+
const { exit, verdict } = piVerdict(checks, PI_CAPABILITIES);
|
|
142
|
+
printSection("pi", checks, verdict, PI_CAPABILITIES);
|
|
143
|
+
return exit;
|
|
144
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor report shape and rendering, shared by every host adapter.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode's status still decides an aggregate run; the Claude Code and pi
|
|
5
|
+
* section checks are reported next to it and only decide a run when OpenCode
|
|
6
|
+
* is absent (see `doctorExitCode`).
|
|
7
|
+
*/
|
|
8
|
+
import type { HostCapabilities } from "./types/capabilities.js";
|
|
9
|
+
export type DoctorStatus = "PROTECTED" | "PARTIAL" | "BROKEN" | "NOT_REGISTERED" | "HOST_MISSING";
|
|
10
|
+
export interface DoctorCheck {
|
|
11
|
+
id: string;
|
|
12
|
+
state: "ok" | "warn" | "fail" | "skip";
|
|
13
|
+
detail: string;
|
|
14
|
+
fix?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface DoctorReport {
|
|
17
|
+
status: DoctorStatus;
|
|
18
|
+
hostVersion: string | null;
|
|
19
|
+
hostGeneration: "v1" | "v2" | null;
|
|
20
|
+
configPath: string | null;
|
|
21
|
+
checks: DoctorCheck[];
|
|
22
|
+
/** Weakest validated OpenCode configuration; absent when options are unknown. */
|
|
23
|
+
wireProtection?: "enabled" | "disabled" | "not-applicable";
|
|
24
|
+
/** Copy-paste registration snippet for the OpenCode v2 config. */
|
|
25
|
+
snippet?: string;
|
|
26
|
+
/** Claude Code proxy checks; reported separately from the OpenCode status. */
|
|
27
|
+
claudeCode?: DoctorCheck[];
|
|
28
|
+
/** pi adapter checks; reported separately from the OpenCode status. */
|
|
29
|
+
pi?: DoctorCheck[];
|
|
30
|
+
/** OpenCode's declared coverage, printed under the checks. */
|
|
31
|
+
capabilities?: HostCapabilities;
|
|
32
|
+
/** Claude Code's declared coverage, printed with its checks. */
|
|
33
|
+
claudeCodeCapabilities?: HostCapabilities;
|
|
34
|
+
/** pi's declared coverage, printed with its checks. */
|
|
35
|
+
piCapabilities?: HostCapabilities;
|
|
36
|
+
}
|
|
37
|
+
export declare function formatDoctorReport(report: DoctorReport): string;
|
|
38
|
+
/**
|
|
39
|
+
* The OpenCode status decides as before. Only when OpenCode is absent
|
|
40
|
+
* (HOST_MISSING) can Claude Code or an installed pi extension make the run
|
|
41
|
+
* pass, unless a provider or host setting bypasses it; a failed Claude Code
|
|
42
|
+
* check still fails it. A pi failure only decides the run when OpenCode is
|
|
43
|
+
* absent, so a broken ~/.pi never fails a protected OpenCode run.
|
|
44
|
+
*/
|
|
45
|
+
export declare function doctorExitCode(report: DoctorReport): number;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor report shape and rendering, shared by every host adapter.
|
|
3
|
+
*
|
|
4
|
+
* OpenCode's status still decides an aggregate run; the Claude Code and pi
|
|
5
|
+
* section checks are reported next to it and only decide a run when OpenCode
|
|
6
|
+
* is absent (see `doctorExitCode`).
|
|
7
|
+
*/
|
|
8
|
+
import { capabilityCapText, capabilitySection } from "./doctor-capabilities.js";
|
|
9
|
+
export function formatDoctorReport(report) {
|
|
10
|
+
const icon = { ok: "[OK] ", warn: "[WARN]", fail: "[FAIL]", skip: "[SKIP]" };
|
|
11
|
+
const lines = [];
|
|
12
|
+
lines.push(`leakshield doctor — ${new Date().toISOString()}`);
|
|
13
|
+
for (const check of report.checks) {
|
|
14
|
+
lines.push(`${icon[check.state]} ${check.id}: ${check.detail}`);
|
|
15
|
+
if (check.fix)
|
|
16
|
+
lines.push(` fix: ${check.fix}`);
|
|
17
|
+
}
|
|
18
|
+
if (report.snippet) {
|
|
19
|
+
lines.push("");
|
|
20
|
+
lines.push("Registration snippet for your opencode.json:");
|
|
21
|
+
lines.push(report.snippet);
|
|
22
|
+
}
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push(`Configuration status: ${report.status}`);
|
|
25
|
+
lines.push(`Wire protection: ${report.wireProtection ?? "unknown"} (configuration only; live-session interception is not verified).`);
|
|
26
|
+
const capText = report.capabilities ? capabilityCapText(report.capabilities) : null;
|
|
27
|
+
if (report.capabilities) {
|
|
28
|
+
lines.push("");
|
|
29
|
+
lines.push(...capabilitySection(report.capabilities));
|
|
30
|
+
}
|
|
31
|
+
if (report.status === "PROTECTED" || report.status === "PARTIAL") {
|
|
32
|
+
if (report.status === "PARTIAL") {
|
|
33
|
+
lines.push("Partial reason (configuration): wireProtection=false; final outbound HTTP bodies and WebSocket frames are not inspected.");
|
|
34
|
+
}
|
|
35
|
+
if (capText !== null) {
|
|
36
|
+
lines.push(`Partial reason (host coverage): ${capText}.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
lines.push("");
|
|
40
|
+
const verdict = report.status === "PROTECTED"
|
|
41
|
+
? capText === null
|
|
42
|
+
? "PROTECTED — install-level checks pass."
|
|
43
|
+
: `PARTIAL — install-level checks pass, but ${capText}; see Host capabilities above.`
|
|
44
|
+
: report.status === "PARTIAL"
|
|
45
|
+
? "PARTIAL — hook-first protection; final outbound HTTP bodies are not inspected."
|
|
46
|
+
: report.status === "BROKEN"
|
|
47
|
+
? "BROKEN — registered but would not protect; fix the [FAIL] items above."
|
|
48
|
+
: report.status === "NOT_REGISTERED"
|
|
49
|
+
? "NOT REGISTERED — LeakShield is not in the OpenCode config; sessions are unprotected."
|
|
50
|
+
: "HOST MISSING — no OpenCode binary found.";
|
|
51
|
+
lines.push(verdict);
|
|
52
|
+
if (report.claudeCode && report.claudeCode.length > 0) {
|
|
53
|
+
lines.push("");
|
|
54
|
+
lines.push("Claude Code:");
|
|
55
|
+
for (const check of report.claudeCode) {
|
|
56
|
+
lines.push(`${icon[check.state]} ${check.id}: ${check.detail}`);
|
|
57
|
+
if (check.fix)
|
|
58
|
+
lines.push(` fix: ${check.fix}`);
|
|
59
|
+
}
|
|
60
|
+
if (report.claudeCodeCapabilities) {
|
|
61
|
+
lines.push("");
|
|
62
|
+
lines.push(...capabilitySection(report.claudeCodeCapabilities));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (report.pi && report.pi.length > 0) {
|
|
66
|
+
lines.push("");
|
|
67
|
+
lines.push("pi:");
|
|
68
|
+
for (const check of report.pi) {
|
|
69
|
+
lines.push(`${icon[check.state]} ${check.id}: ${check.detail}`);
|
|
70
|
+
if (check.fix)
|
|
71
|
+
lines.push(` fix: ${check.fix}`);
|
|
72
|
+
}
|
|
73
|
+
if (report.piCapabilities) {
|
|
74
|
+
lines.push("");
|
|
75
|
+
lines.push(...capabilitySection(report.piCapabilities));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
lines.push("");
|
|
79
|
+
lines.push("Scope: model-conversation leak protection. This is NOT a tool-egress firewall: permitted local tools (curl, remote MCP, …) can still transmit originals. See README.");
|
|
80
|
+
return lines.join("\n");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The OpenCode status decides as before. Only when OpenCode is absent
|
|
84
|
+
* (HOST_MISSING) can Claude Code or an installed pi extension make the run
|
|
85
|
+
* pass, unless a provider or host setting bypasses it; a failed Claude Code
|
|
86
|
+
* check still fails it. A pi failure only decides the run when OpenCode is
|
|
87
|
+
* absent, so a broken ~/.pi never fails a protected OpenCode run.
|
|
88
|
+
*/
|
|
89
|
+
export function doctorExitCode(report) {
|
|
90
|
+
const claudeCode = report.claudeCode ?? [];
|
|
91
|
+
const pi = report.pi ?? [];
|
|
92
|
+
if (claudeCode.some((check) => check.state === "fail"))
|
|
93
|
+
return 1;
|
|
94
|
+
// pi checks are supplementary: a broken ~/.pi must not fail an otherwise
|
|
95
|
+
// protected OpenCode run. They decide the run only when OpenCode is absent.
|
|
96
|
+
if (pi.some((check) => check.state === "fail") && report.status === "HOST_MISSING")
|
|
97
|
+
return 1;
|
|
98
|
+
if (report.status === "PROTECTED" || report.status === "PARTIAL")
|
|
99
|
+
return 0;
|
|
100
|
+
if (report.status !== "HOST_MISSING")
|
|
101
|
+
return 1;
|
|
102
|
+
// A bypassing provider or host-managed endpoint means requests may not reach
|
|
103
|
+
// the proxy even though it answers at the configured base URL.
|
|
104
|
+
const bypassed = claudeCode.some((check) => check.id === "claude-code-provider" || check.id === "claude-code-host-managed");
|
|
105
|
+
if (bypassed)
|
|
106
|
+
return 1;
|
|
107
|
+
const claudeCodeProtected = claudeCode.some((check) => check.id === "claude-code-proxy" && check.state === "ok");
|
|
108
|
+
const piProtected = pi.some((check) => check.id === "pi-extension-registered" && (check.state === "ok" || check.state === "warn"))
|
|
109
|
+
&& !pi.some((check) => check.state === "fail");
|
|
110
|
+
return claudeCodeProtected || piProtected ? 0 : 1;
|
|
111
|
+
}
|
package/dist/forget.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W2 (B5) `forget` — the active erasure lever for persisted mappings
|
|
3
|
+
* (decision `docs/plans/2026-10-07-persistence-decision-db-over-t2.md` §4:
|
|
4
|
+
* TTL is the passive bound, forget is the explicit one; dispose never
|
|
5
|
+
* erases). Output is content-free: counts and paths only, never originals.
|
|
6
|
+
*
|
|
7
|
+
* Deletion does not decrypt anything, so the store is opened with a throwaway
|
|
8
|
+
* in-memory key: the real key stays wherever the ladder put it (keychain /
|
|
9
|
+
* keyfile). The key itself holds no data and is retained — removing it is
|
|
10
|
+
* unnecessary and would only force regeneration.
|
|
11
|
+
*/
|
|
12
|
+
export interface ForgetOptions {
|
|
13
|
+
all: boolean;
|
|
14
|
+
session?: string;
|
|
15
|
+
storePath?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Process exit code. 0 = success/no-op, 1 = store error, 2 = usage error. */
|
|
18
|
+
export declare function runForget(options: ForgetOptions): number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin options schema — the single source of truth shared by the plugin
|
|
3
|
+
* entry (src/opencode.ts, which keeps a default-only export surface for the
|
|
4
|
+
* host loaders) and the install doctor (src/doctor.ts).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/** Shared with the pi adapter's environment parser so the bounds cannot drift. */
|
|
8
|
+
export declare const PERSISTENCE_TTL_DEFAULT_DAYS = 7;
|
|
9
|
+
export declare const PERSISTENCE_TTL_MAX_DAYS = 3650;
|
|
10
|
+
export declare const PluginOptionsSchema: z.ZodObject<{
|
|
11
|
+
mode: z.ZodEnum<{
|
|
12
|
+
block: "block";
|
|
13
|
+
redact: "redact";
|
|
14
|
+
transparent: "transparent";
|
|
15
|
+
}>;
|
|
16
|
+
configPath: z.ZodOptional<z.ZodString>;
|
|
17
|
+
deidentify: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
envQueries: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
attachments: z.ZodDefault<z.ZodEnum<{
|
|
20
|
+
allow: "allow";
|
|
21
|
+
block: "block";
|
|
22
|
+
}>>;
|
|
23
|
+
wireProtection: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
persistence: z.ZodPrefault<z.ZodPipe<z.ZodCustom<unknown, unknown>, z.ZodObject<{
|
|
25
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
ttlDays: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
path: z.ZodOptional<z.ZodString>;
|
|
28
|
+
keyFile: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
keyfilePath: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type PluginOptions = z.infer<typeof PluginOptionsSchema>;
|
|
33
|
+
/** Fills in the default mode (transparent) when the options omit `mode`. Any
|
|
34
|
+
* other non-object input is returned unchanged so the schema rejects it. */
|
|
35
|
+
export declare function withDefaultMode(input: unknown): unknown;
|
|
36
|
+
/** Validated plugin options for external consumers (doctor, tests). Never
|
|
37
|
+
* throws; returns the combined zod/refine error message on failure. */
|
|
38
|
+
export type PluginOptionsValidation = {
|
|
39
|
+
ok: true;
|
|
40
|
+
options: PluginOptions;
|
|
41
|
+
} | {
|
|
42
|
+
ok: false;
|
|
43
|
+
error: string;
|
|
44
|
+
};
|
|
45
|
+
export declare function validatePluginOptions(input: unknown): PluginOptionsValidation;
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { plainObject } from "./config/plain-object.js";
|
|
8
|
+
/** Shared with the pi adapter's environment parser so the bounds cannot drift. */
|
|
9
|
+
export const PERSISTENCE_TTL_DEFAULT_DAYS = 7;
|
|
10
|
+
export const PERSISTENCE_TTL_MAX_DAYS = 3650;
|
|
8
11
|
// deidentify is valid only in redact mode; an invalid combination
|
|
9
12
|
// makes the parse throw, and every entry path already fails closed on that.
|
|
10
13
|
// transparent is the reversible pseudonymization mode (issue #22):
|
|
@@ -48,7 +51,7 @@ export const PluginOptionsSchema = z
|
|
|
48
51
|
persistence: plainObject(z.object({
|
|
49
52
|
enabled: z.boolean().default(false),
|
|
50
53
|
/** Session TTL in days; 0 = never expire (manual forget only). */
|
|
51
|
-
ttlDays: z.number().int().min(0).max(
|
|
54
|
+
ttlDays: z.number().int().min(0).max(PERSISTENCE_TTL_MAX_DAYS).default(PERSISTENCE_TTL_DEFAULT_DAYS),
|
|
52
55
|
/** Store path. Default: ~/.local/share/leakshield/SGP.db */
|
|
53
56
|
path: z.string().min(1).optional(),
|
|
54
57
|
/** Opt-in weaker fallback when no OS keychain is available. */
|
package/dist/help.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const HELP_TEXT = "leakshield \u2014 scan text for secrets and PII before sending it to AI\n\nUsage:\n leakshield [--cli] [scan options] Scan text, a file, a directory or stdin\n leakshield --web [--port <n>] Start the local Web UI (default port 3000)\n leakshield --doctor [host] Check one host (opencode, claude-code, pi) or all;\n use --doctor pi, not pi --doctor\n leakshield --doctor=<host> Same target, inline form\n leakshield --claude-code-proxy Start the local proxy for Claude Code (see below)\n leakshield --forget --all Delete all persisted transparent-mode mappings\n leakshield --forget --session <id> Delete persisted mappings for one session\n leakshield --help Show this help\n\nScan input (stdin is read when none is given):\n --text <text> Scan the given text\n --file <path> Scan a single file\n --dir <path> Scan a directory recursively\n --ext <.ext ...> With --dir, only scan these extensions\n --stdin Read text from stdin\n --allow-outside Allow --file/--dir paths outside the working directory\n\nScan options:\n --format json JSON output (CI/CD friendly)\n --min-severity <level> Only report high, medium or low and above (default: low)\n --enable-encoding-detection Also decode Base64/hex/URL-encoded content before scanning\n\nRedaction:\n --redact Replace findings with [REDACTED_TYPE] and print to stdout\n --redact --out <path> Write the redacted text to a file\n --redact --dry-run Report what would be redacted without writing output\n\nClaude Code proxy options (then set ANTHROPIC_BASE_URL=http://127.0.0.1:<port>):\n --port <n> Listen port on 127.0.0.1 (default 8787)\n --upstream <url> Anthropic API base URL (default https://api.anthropic.com)\n --config <path> LeakShield config file (default: discovered from the working directory)\n --attachments block|allow Refuse (default) or pass images/documents through unscanned\n\npi (the LeakShield extension runs inside pi; see docs/pi.md):\n Register node_modules/leakshield/dist/adapters/pi/extension.js as the first entry of\n pi settings.extensions, or start pi with -e <path>. Check it with\n leakshield --doctor pi; LEAKSHIELD_CONFIG selects the guard config file.\n\nForget options:\n --path <file> Mapping store location (default: ~/.local/share/leakshield/SGP.db)\n\nExit codes: 0 = safe, 1 = findings detected, 2 = file not found\n";
|
|
2
|
+
export declare function isHelpRequest(args: readonly string[]): boolean;
|
package/dist/help.js
CHANGED
|
@@ -4,7 +4,10 @@ export const HELP_TEXT = `leakshield — scan text for secrets and PII before se
|
|
|
4
4
|
Usage:
|
|
5
5
|
leakshield [--cli] [scan options] Scan text, a file, a directory or stdin
|
|
6
6
|
leakshield --web [--port <n>] Start the local Web UI (default port 3000)
|
|
7
|
-
leakshield --doctor
|
|
7
|
+
leakshield --doctor [host] Check one host (opencode, claude-code, pi) or all;
|
|
8
|
+
use --doctor pi, not pi --doctor
|
|
9
|
+
leakshield --doctor=<host> Same target, inline form
|
|
10
|
+
leakshield --claude-code-proxy Start the local proxy for Claude Code (see below)
|
|
8
11
|
leakshield --forget --all Delete all persisted transparent-mode mappings
|
|
9
12
|
leakshield --forget --session <id> Delete persisted mappings for one session
|
|
10
13
|
leakshield --help Show this help
|
|
@@ -27,6 +30,17 @@ Redaction:
|
|
|
27
30
|
--redact --out <path> Write the redacted text to a file
|
|
28
31
|
--redact --dry-run Report what would be redacted without writing output
|
|
29
32
|
|
|
33
|
+
Claude Code proxy options (then set ANTHROPIC_BASE_URL=http://127.0.0.1:<port>):
|
|
34
|
+
--port <n> Listen port on 127.0.0.1 (default 8787)
|
|
35
|
+
--upstream <url> Anthropic API base URL (default https://api.anthropic.com)
|
|
36
|
+
--config <path> LeakShield config file (default: discovered from the working directory)
|
|
37
|
+
--attachments block|allow Refuse (default) or pass images/documents through unscanned
|
|
38
|
+
|
|
39
|
+
pi (the LeakShield extension runs inside pi; see docs/pi.md):
|
|
40
|
+
Register node_modules/leakshield/dist/adapters/pi/extension.js as the first entry of
|
|
41
|
+
pi settings.extensions, or start pi with -e <path>. Check it with
|
|
42
|
+
leakshield --doctor pi; LEAKSHIELD_CONFIG selects the guard config file.
|
|
43
|
+
|
|
30
44
|
Forget options:
|
|
31
45
|
--path <file> Mapping store location (default: ~/.local/share/leakshield/SGP.db)
|
|
32
46
|
|