@agentic-kit/permissions 0.0.0-stage → 0.2.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/LICENSE +23 -0
- package/README.md +279 -2
- package/bash/analyze.d.ts +133 -0
- package/bash/analyze.js +442 -0
- package/bash/args.d.ts +45 -0
- package/bash/args.js +145 -0
- package/bash/braces.d.ts +6 -0
- package/bash/braces.js +72 -0
- package/bash/commands.d.ts +14 -0
- package/bash/commands.js +361 -0
- package/bash/file-commands.d.ts +22 -0
- package/bash/file-commands.js +278 -0
- package/bash/flows.d.ts +67 -0
- package/bash/flows.js +208 -0
- package/bash/git.d.ts +7 -0
- package/bash/git.js +163 -0
- package/bash/network.d.ts +24 -0
- package/bash/network.js +295 -0
- package/bash/quoting.d.ts +16 -0
- package/bash/quoting.js +164 -0
- package/bash/system.d.ts +16 -0
- package/bash/system.js +122 -0
- package/bash/tokenize.d.ts +67 -0
- package/bash/tokenize.js +440 -0
- package/bash/words.d.ts +9 -0
- package/bash/words.js +30 -0
- package/bash/wrappers.d.ts +32 -0
- package/bash/wrappers.js +237 -0
- package/classify.d.ts +22 -0
- package/classify.js +259 -0
- package/engine.d.ts +109 -0
- package/engine.js +144 -0
- package/env.d.ts +13 -0
- package/env.js +37 -0
- package/esm/bash/analyze.d.ts +133 -0
- package/esm/bash/analyze.js +405 -0
- package/esm/bash/args.d.ts +45 -0
- package/esm/bash/args.js +135 -0
- package/esm/bash/braces.d.ts +6 -0
- package/esm/bash/braces.js +69 -0
- package/esm/bash/commands.d.ts +14 -0
- package/esm/bash/commands.js +324 -0
- package/esm/bash/file-commands.d.ts +22 -0
- package/esm/bash/file-commands.js +233 -0
- package/esm/bash/flows.d.ts +67 -0
- package/esm/bash/flows.js +203 -0
- package/esm/bash/git.d.ts +7 -0
- package/esm/bash/git.js +127 -0
- package/esm/bash/network.d.ts +24 -0
- package/esm/bash/network.js +282 -0
- package/esm/bash/quoting.d.ts +16 -0
- package/esm/bash/quoting.js +153 -0
- package/esm/bash/system.d.ts +16 -0
- package/esm/bash/system.js +82 -0
- package/esm/bash/tokenize.d.ts +67 -0
- package/esm/bash/tokenize.js +437 -0
- package/esm/bash/words.d.ts +9 -0
- package/esm/bash/words.js +24 -0
- package/esm/bash/wrappers.d.ts +32 -0
- package/esm/bash/wrappers.js +200 -0
- package/esm/classify.d.ts +22 -0
- package/esm/classify.js +223 -0
- package/esm/engine.d.ts +109 -0
- package/esm/engine.js +108 -0
- package/esm/env.d.ts +13 -0
- package/esm/env.js +34 -0
- package/esm/findings.d.ts +7 -0
- package/esm/findings.js +9 -0
- package/esm/glob.d.ts +15 -0
- package/esm/glob.js +69 -0
- package/esm/grants.d.ts +36 -0
- package/esm/grants.js +99 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +18 -0
- package/esm/node-fs.d.ts +6 -0
- package/esm/node-fs.js +34 -0
- package/esm/paths.d.ts +43 -0
- package/esm/paths.js +121 -0
- package/esm/policy.d.ts +21 -0
- package/esm/policy.js +85 -0
- package/esm/prompt.d.ts +14 -0
- package/esm/prompt.js +79 -0
- package/esm/roots.d.ts +75 -0
- package/esm/roots.js +148 -0
- package/esm/secret-files.d.ts +16 -0
- package/esm/secret-files.js +84 -0
- package/esm/secrets/collect.d.ts +19 -0
- package/esm/secrets/collect.js +60 -0
- package/esm/secrets/index.d.ts +5 -0
- package/esm/secrets/index.js +5 -0
- package/esm/secrets/parse.d.ts +19 -0
- package/esm/secrets/parse.js +140 -0
- package/esm/secrets/redact-result.d.ts +8 -0
- package/esm/secrets/redact-result.js +67 -0
- package/esm/secrets/rules.d.ts +34 -0
- package/esm/secrets/rules.js +101 -0
- package/esm/secrets/vault.d.ts +48 -0
- package/esm/secrets/vault.js +158 -0
- package/esm/signals.d.ts +14 -0
- package/esm/signals.js +26 -0
- package/esm/tool-input.d.ts +13 -0
- package/esm/tool-input.js +40 -0
- package/esm/types.d.ts +146 -0
- package/esm/types.js +20 -0
- package/findings.d.ts +7 -0
- package/findings.js +13 -0
- package/glob.d.ts +15 -0
- package/glob.js +73 -0
- package/grants.d.ts +36 -0
- package/grants.js +110 -0
- package/index.d.ts +19 -0
- package/index.js +52 -0
- package/node-fs.d.ts +6 -0
- package/node-fs.js +37 -0
- package/package.json +35 -3
- package/paths.d.ts +43 -0
- package/paths.js +164 -0
- package/policy.d.ts +21 -0
- package/policy.js +88 -0
- package/prompt.d.ts +14 -0
- package/prompt.js +83 -0
- package/roots.d.ts +75 -0
- package/roots.js +192 -0
- package/secret-files.d.ts +16 -0
- package/secret-files.js +124 -0
- package/secrets/collect.d.ts +19 -0
- package/secrets/collect.js +96 -0
- package/secrets/index.d.ts +5 -0
- package/secrets/index.js +21 -0
- package/secrets/parse.d.ts +19 -0
- package/secrets/parse.js +145 -0
- package/secrets/redact-result.d.ts +8 -0
- package/secrets/redact-result.js +70 -0
- package/secrets/rules.d.ts +34 -0
- package/secrets/rules.js +107 -0
- package/secrets/vault.d.ts +48 -0
- package/secrets/vault.js +163 -0
- package/signals.d.ts +14 -0
- package/signals.js +29 -0
- package/tool-input.d.ts +13 -0
- package/tool-input.js +46 -0
- package/types.d.ts +146 -0
- package/types.js +24 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrappers that run another command (`env`, `sudo`, `timeout`, `xargs`, …).
|
|
3
|
+
* They come off the front of a command before its rules apply, so `/bin/rm`,
|
|
4
|
+
* `command rm` and `env rm` are all `rm`.
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { leadingOptions } from './args';
|
|
8
|
+
import { NO_OPERANDS } from './commands';
|
|
9
|
+
/** `xargs` options whose value is the next word (`-i`, `-e`, `-l` and `--replace` take only a glued one). */
|
|
10
|
+
const XARGS_WITH_VALUE = /^-[InPLdEsa]$|^--(max-args|max-procs|max-lines|delimiter|eof|max-chars|arg-file)$/;
|
|
11
|
+
function xargs(analyzer, args, i, scope) {
|
|
12
|
+
const input = (scope.xargs ??= { fromFile: false });
|
|
13
|
+
let k = i + 1;
|
|
14
|
+
while (k < args.length) {
|
|
15
|
+
const t = args[k].text;
|
|
16
|
+
if (t === '--')
|
|
17
|
+
return k + 1;
|
|
18
|
+
if (t === '-I')
|
|
19
|
+
input.replace = args[k + 1]?.text ?? '{}';
|
|
20
|
+
else if (t === '-i' || t === '--replace')
|
|
21
|
+
input.replace = '{}';
|
|
22
|
+
else if (/^-[Ii]./.test(t))
|
|
23
|
+
input.replace = t.slice(2);
|
|
24
|
+
else if (t.startsWith('--replace='))
|
|
25
|
+
input.replace = t.slice('--replace='.length);
|
|
26
|
+
if (t === '-a' || t === '--arg-file' || t.startsWith('--arg-file=')) {
|
|
27
|
+
input.fromFile = true;
|
|
28
|
+
const file = t.startsWith('--arg-file=') ? { ...args[k], text: t.slice('--arg-file='.length) } : args[k + 1];
|
|
29
|
+
if (file)
|
|
30
|
+
analyzer.addPath(file, 'read', true);
|
|
31
|
+
}
|
|
32
|
+
if (XARGS_WITH_VALUE.test(t))
|
|
33
|
+
k += 2;
|
|
34
|
+
else if (t.startsWith('-') && t !== '-')
|
|
35
|
+
k++;
|
|
36
|
+
else
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return k;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The operands of the command `xargs` runs. The words on stdin join them when
|
|
43
|
+
* they are known, and the roots of a file listing stand in for the names it
|
|
44
|
+
* prints. Otherwise the names cannot be seen, which is a signal.
|
|
45
|
+
*/
|
|
46
|
+
export function xargsOperands(analyzer, name, rest, input) {
|
|
47
|
+
const { replace } = input;
|
|
48
|
+
const { words, listedUnder } = input.fromFile ? { words: null, listedUnder: null } : analyzer.stdin;
|
|
49
|
+
if (words !== null) {
|
|
50
|
+
if (!replace)
|
|
51
|
+
return [...rest, ...words];
|
|
52
|
+
return rest.flatMap((a) => (a.text.includes(replace) ? words.map((w) => ({ ...a, text: a.text.split(replace).join(w.text) })) : [a]));
|
|
53
|
+
}
|
|
54
|
+
if (listedUnder !== null) {
|
|
55
|
+
if (!replace)
|
|
56
|
+
return [...rest, ...listedUnder];
|
|
57
|
+
return rest.flatMap((a) => (a.text.includes(replace) ? listedUnder : [a]));
|
|
58
|
+
}
|
|
59
|
+
if (!NO_OPERANDS.has(name)) {
|
|
60
|
+
analyzer.flag('stdin-operands', `xargs gives ${name} file names from its input, which cannot be checked before it runs`);
|
|
61
|
+
}
|
|
62
|
+
return rest;
|
|
63
|
+
}
|
|
64
|
+
const ENV_VALUE_OPTIONS = new Set(['-u', '--unset', '-C', '--chdir', '-S', '--split-string']);
|
|
65
|
+
const RUNNER_VALUE_OPTIONS = new Set(['-c', '--call', '-p', '--package']);
|
|
66
|
+
/**
|
|
67
|
+
* `npx -c 'cmd'`, `pnpm exec --call=cmd`: the runner's options from `from` up
|
|
68
|
+
* to the package name, its `-c` shell string, and where the package name is.
|
|
69
|
+
*/
|
|
70
|
+
function runnerOptions(args, from) {
|
|
71
|
+
const { options, next } = leadingOptions(args.slice(from), RUNNER_VALUE_OPTIONS);
|
|
72
|
+
const call = options.find((o) => o.key === '-c' || o.key === '--call');
|
|
73
|
+
return { call: call ? (call.value ?? null) : undefined, next: from + next };
|
|
74
|
+
}
|
|
75
|
+
/** A runner's `-c` string: analyzed as a nested command, or dynamic when it is not known. */
|
|
76
|
+
function runCall(analyzer, call, what) {
|
|
77
|
+
if (!call || call.unknown)
|
|
78
|
+
analyzer.dynamic(`it runs ${what} with a string from a variable`);
|
|
79
|
+
else
|
|
80
|
+
analyzer.nested(call.text, `it runs a string with ${what}`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Take one wrapper off the front of the command. Returns the index of the
|
|
84
|
+
* next word, or `i` when `args[i]` is not a wrapper.
|
|
85
|
+
*/
|
|
86
|
+
export function stripWrapper(analyzer, args, i, scope) {
|
|
87
|
+
const name = path.basename(args[i].text);
|
|
88
|
+
const opts = (withValue, flags = /^-/) => {
|
|
89
|
+
let k = i + 1;
|
|
90
|
+
while (k < args.length) {
|
|
91
|
+
const t = args[k].text;
|
|
92
|
+
if (t === '--')
|
|
93
|
+
return k + 1;
|
|
94
|
+
if (withValue.test(t))
|
|
95
|
+
k += 2;
|
|
96
|
+
else if (flags.test(t) && t !== '-')
|
|
97
|
+
k++;
|
|
98
|
+
else
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return k;
|
|
102
|
+
};
|
|
103
|
+
switch (name) {
|
|
104
|
+
case 'command':
|
|
105
|
+
case 'builtin':
|
|
106
|
+
case 'nohup':
|
|
107
|
+
case 'chronic':
|
|
108
|
+
case 'unbuffer':
|
|
109
|
+
return opts(/^$/);
|
|
110
|
+
case 'time':
|
|
111
|
+
return opts(/^$/, /^-[pv]+$/);
|
|
112
|
+
case 'exec':
|
|
113
|
+
return opts(/^-a$/, /^-[cl]+$/);
|
|
114
|
+
case 'nice':
|
|
115
|
+
return opts(/^(-n|--adjustment)$/, /^-/);
|
|
116
|
+
case 'ionice':
|
|
117
|
+
return opts(/^-[cnp]$/, /^-/);
|
|
118
|
+
case 'stdbuf':
|
|
119
|
+
return opts(/^-[ioe]$/, /^-/);
|
|
120
|
+
case 'caffeinate':
|
|
121
|
+
return opts(/^-[tw]$/, /^-/);
|
|
122
|
+
case 'timeout': {
|
|
123
|
+
const k = opts(/^-[sk]$/, /^-/);
|
|
124
|
+
return k + 1;
|
|
125
|
+
}
|
|
126
|
+
case 'env': {
|
|
127
|
+
// `env -` is `env -i`.
|
|
128
|
+
const from = args[i + 1]?.text === '-' ? i + 2 : i + 1;
|
|
129
|
+
const rest = args.slice(from);
|
|
130
|
+
const { options, next } = leadingOptions(rest, ENV_VALUE_OPTIONS);
|
|
131
|
+
for (const { key, value } of options) {
|
|
132
|
+
if (key === '-S' || key === '--split-string') {
|
|
133
|
+
const words = [value, ...rest.slice(next)].filter((a) => a !== undefined);
|
|
134
|
+
if (words.some((a) => a.unknown))
|
|
135
|
+
analyzer.dynamic('it runs env -S with a string from a variable');
|
|
136
|
+
else
|
|
137
|
+
analyzer.nested(words.map((a) => a.text).join(' '), 'it runs a string with env -S');
|
|
138
|
+
return args.length;
|
|
139
|
+
}
|
|
140
|
+
if (key === '-C' || key === '--chdir') {
|
|
141
|
+
analyzer.base = value && !value.unknown ? analyzer.toAbs(value.text) : null;
|
|
142
|
+
scope.chdir = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return from + next;
|
|
146
|
+
}
|
|
147
|
+
case 'sudo':
|
|
148
|
+
case 'doas':
|
|
149
|
+
case 'pkexec': {
|
|
150
|
+
scope.sudo = true;
|
|
151
|
+
analyzer.flag('sudo', `it runs ${name} to get root`);
|
|
152
|
+
const k = opts(/^(-[ugCDhprtTU]|--user|--group)$/, /^-/);
|
|
153
|
+
const shellFlag = args.slice(i + 1, k).some((a) => /^-[a-zA-Z]*[si]/.test(a.text));
|
|
154
|
+
if (shellFlag && k < args.length) {
|
|
155
|
+
analyzer.nested(args.slice(k).map((a) => a.text).join(' '), `it runs a shell with ${name} -s`);
|
|
156
|
+
return args.length;
|
|
157
|
+
}
|
|
158
|
+
return k;
|
|
159
|
+
}
|
|
160
|
+
case 'su': {
|
|
161
|
+
scope.sudo = true;
|
|
162
|
+
analyzer.flag('sudo', 'it runs su to switch user');
|
|
163
|
+
const c = args.findIndex((a, k) => k > i && (a.text === '-c' || a.text === '--command'));
|
|
164
|
+
if (c > 0 && args[c + 1])
|
|
165
|
+
analyzer.nested(args[c + 1].text, 'it runs a string with su -c');
|
|
166
|
+
return args.length;
|
|
167
|
+
}
|
|
168
|
+
case 'xargs':
|
|
169
|
+
return xargs(analyzer, args, i, scope);
|
|
170
|
+
case 'watch': {
|
|
171
|
+
const k = opts(/^-[nqd]$|^--(interval|differences)$/, /^-/);
|
|
172
|
+
analyzer.nested(args.slice(k).map((a) => a.text).join(' '), 'it runs a string with watch');
|
|
173
|
+
return args.length;
|
|
174
|
+
}
|
|
175
|
+
case 'npx':
|
|
176
|
+
case 'pnpx':
|
|
177
|
+
case 'bunx': {
|
|
178
|
+
const { call, next } = runnerOptions(args, i + 1);
|
|
179
|
+
if (call === undefined)
|
|
180
|
+
return next;
|
|
181
|
+
runCall(analyzer, call, `${name} -c`);
|
|
182
|
+
return args.length;
|
|
183
|
+
}
|
|
184
|
+
case 'pnpm':
|
|
185
|
+
case 'npm':
|
|
186
|
+
case 'yarn':
|
|
187
|
+
case 'bun': {
|
|
188
|
+
const sub = args[i + 1]?.text;
|
|
189
|
+
if (sub !== 'exec' && sub !== 'dlx' && sub !== 'x')
|
|
190
|
+
return i;
|
|
191
|
+
const { call, next } = runnerOptions(args, i + 2);
|
|
192
|
+
if (call === undefined)
|
|
193
|
+
return next;
|
|
194
|
+
runCall(analyzer, call, `${name} ${sub} -c`);
|
|
195
|
+
return args.length;
|
|
196
|
+
}
|
|
197
|
+
default:
|
|
198
|
+
return i;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn one built-in tool call into a `PermissionRequest`: its canonical
|
|
3
|
+
* targets, their zones, and the risk signals, each with the sentence that
|
|
4
|
+
* explains it. No decision is made here.
|
|
5
|
+
*/
|
|
6
|
+
import { type Roots } from './roots';
|
|
7
|
+
import { type SecretVault } from './secrets';
|
|
8
|
+
import { type BuiltinTool, type FsProbe, type PermissionRequest } from './types';
|
|
9
|
+
export interface ClassifyContext {
|
|
10
|
+
cwd: string;
|
|
11
|
+
homeDir: string;
|
|
12
|
+
roots: Roots;
|
|
13
|
+
fs: FsProbe;
|
|
14
|
+
vault: SecretVault;
|
|
15
|
+
/** Env names the host marked secret (`refreshSecrets({ env })`). */
|
|
16
|
+
secretEnvNames: ReadonlySet<string>;
|
|
17
|
+
}
|
|
18
|
+
export declare function classify(call: {
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
toolName: BuiltinTool;
|
|
21
|
+
input: Record<string, unknown>;
|
|
22
|
+
}, ctx: ClassifyContext): Promise<PermissionRequest>;
|
package/esm/classify.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn one built-in tool call into a `PermissionRequest`: its canonical
|
|
3
|
+
* targets, their zones, and the risk signals, each with the sentence that
|
|
4
|
+
* explains it. No decision is made here.
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { analyzeBash, normalizeCommand } from './bash/analyze';
|
|
8
|
+
import { Findings } from './findings';
|
|
9
|
+
import { GLOB_CHARS } from './glob';
|
|
10
|
+
import { canonicalize, resolveLikePi, showPath } from './paths';
|
|
11
|
+
import { globZoneOf, isRootItself, zoneOf } from './roots';
|
|
12
|
+
import { globNamesSecretFiles, isSecretFile } from './secret-files';
|
|
13
|
+
import { SECRET_KEY_PATTERN } from './secrets';
|
|
14
|
+
import { newTexts, stringField } from './tool-input';
|
|
15
|
+
import { TOOL_KIND } from './types';
|
|
16
|
+
/** Zones stricter than the plain ones, strictest first. */
|
|
17
|
+
const RESTRICTIVE = ['hard-deny', 'protected', 'ask-write'];
|
|
18
|
+
const ZONE_SIGNAL = {
|
|
19
|
+
'hard-deny': 'hard-deny',
|
|
20
|
+
protected: 'protected-write',
|
|
21
|
+
'ask-write': 'ask-write',
|
|
22
|
+
outside: 'outside-workspace',
|
|
23
|
+
unresolvable: 'unresolvable-path'
|
|
24
|
+
};
|
|
25
|
+
function strictness(zone) {
|
|
26
|
+
const at = RESTRICTIVE.indexOf(zone);
|
|
27
|
+
return at < 0 ? RESTRICTIVE.length : at;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Where a path sits. The canonical path decides the zone, but the lexical
|
|
31
|
+
* spelling can only make it stricter (`~/.ssh` reached through a link). With
|
|
32
|
+
* no canonical path, only a restrictive lexical zone stands.
|
|
33
|
+
*/
|
|
34
|
+
function placeOf(lexical, canonical, access, roots) {
|
|
35
|
+
const lexicalHit = zoneOf(lexical, access, roots);
|
|
36
|
+
if (canonical === null) {
|
|
37
|
+
return RESTRICTIVE.includes(lexicalHit.zone)
|
|
38
|
+
? { path: lexical, zone: lexicalHit.zone, label: lexicalHit.root.label }
|
|
39
|
+
: { path: lexical, zone: 'unresolvable', label: 'unresolvable' };
|
|
40
|
+
}
|
|
41
|
+
let hit = zoneOf(canonical, access, roots);
|
|
42
|
+
if (canonical !== lexical && strictness(lexicalHit.zone) < strictness(hit.zone))
|
|
43
|
+
hit = lexicalHit;
|
|
44
|
+
return { path: canonical, zone: hit.zone, label: hit.root?.label ?? hit.zone };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The target for one path. A glob is matched as a pattern first: if it can
|
|
48
|
+
* expand into a restrictive root, it takes that root's zone.
|
|
49
|
+
*/
|
|
50
|
+
async function makeTarget(raw, abs, access, ctx, glob) {
|
|
51
|
+
const lexical = path.resolve(abs);
|
|
52
|
+
const canonical = await canonicalize(abs, ctx.fs);
|
|
53
|
+
const secretFile = isSecretFile(lexical) ||
|
|
54
|
+
(canonical !== null && isSecretFile(canonical)) ||
|
|
55
|
+
(glob !== undefined && globNamesSecretFiles(path.basename(lexical)));
|
|
56
|
+
const globHit = glob
|
|
57
|
+
? (globZoneOf(lexical, access, ctx.roots, glob.dot) ?? (canonical ? globZoneOf(canonical, access, ctx.roots, glob.dot) : undefined))
|
|
58
|
+
: undefined;
|
|
59
|
+
const place = globHit
|
|
60
|
+
? { path: canonical ?? lexical, zone: globHit.zone, label: globHit.root.label }
|
|
61
|
+
: placeOf(lexical, canonical, access, ctx.roots);
|
|
62
|
+
return { raw, path: place.path, access, zone: place.zone, secretFile, label: place.label, ...(glob ? { glob: true } : {}) };
|
|
63
|
+
}
|
|
64
|
+
function zoneSentence(t, shown) {
|
|
65
|
+
switch (t.zone) {
|
|
66
|
+
case 'hard-deny':
|
|
67
|
+
return `${shown} is in a credential store (${t.label}) that the agent may never touch`;
|
|
68
|
+
case 'protected':
|
|
69
|
+
return `${shown} is in the ${t.label}, which the agent may not change`;
|
|
70
|
+
case 'ask-write':
|
|
71
|
+
return `${shown} is a ${t.label}: a change there runs code later`;
|
|
72
|
+
case 'outside':
|
|
73
|
+
return `${shown} is outside the project`;
|
|
74
|
+
case 'unresolvable':
|
|
75
|
+
return `${shown} goes through a symlink that cannot be resolved`;
|
|
76
|
+
default:
|
|
77
|
+
return `${shown} is in the ${t.label}`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** `rm`, `dd of=`, `chmod -R`, …: destructive outside the project, or on a whole project or temp root. */
|
|
81
|
+
async function flagDestructive(checks, ctx, findings) {
|
|
82
|
+
const resetRoots = [...ctx.roots.workspace, ...ctx.roots.temp];
|
|
83
|
+
const wipesRoot = (p) => isRootItself(resetRoots, p) || (/^[*?.[\]]+$/.test(path.basename(p)) && isRootItself(resetRoots, path.dirname(p)));
|
|
84
|
+
for (const check of checks) {
|
|
85
|
+
const canonical = await canonicalize(check.abs, ctx.fs);
|
|
86
|
+
if (canonical === null)
|
|
87
|
+
continue;
|
|
88
|
+
if (check.rootCounts && wipesRoot(canonical)) {
|
|
89
|
+
findings.flag('destructive', `it runs ${check.what} on ${check.raw}, which wipes a whole project or temp dir`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const zone = zoneOf(canonical, 'write', ctx.roots).zone;
|
|
93
|
+
if (zone !== 'workspace' && zone !== 'temp') {
|
|
94
|
+
findings.flag('destructive', `it runs ${check.what} on ${show(canonical, ctx)}, outside the project`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function show(p, ctx) {
|
|
99
|
+
return showPath(p, ctx.roots.workspace[0]?.path, ctx.homeDir);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Copies, clipboard writes and transforms of a secret file. Redaction matches
|
|
103
|
+
* exact values, so a secret that is encoded, cut or copied into a plain file
|
|
104
|
+
* gets past it.
|
|
105
|
+
*/
|
|
106
|
+
async function flagFlows(flows, ctx, findings) {
|
|
107
|
+
const known = new Map();
|
|
108
|
+
const isSecret = async (abs) => {
|
|
109
|
+
if (!known.has(abs)) {
|
|
110
|
+
const canonical = await canonicalize(abs, ctx.fs);
|
|
111
|
+
known.set(abs, isSecretFile(abs) || (canonical !== null && isSecretFile(canonical)));
|
|
112
|
+
}
|
|
113
|
+
return known.get(abs);
|
|
114
|
+
};
|
|
115
|
+
for (const flow of flows) {
|
|
116
|
+
for (const source of flow.sources) {
|
|
117
|
+
if (!(await isSecret(source.abs)))
|
|
118
|
+
continue;
|
|
119
|
+
const shown = show(path.resolve(source.abs), ctx);
|
|
120
|
+
if (flow.to.kind === 'transform') {
|
|
121
|
+
// An upload already asks, and says more.
|
|
122
|
+
if (!findings.signals.has('upload'))
|
|
123
|
+
findings.flag('secret-transform', `it runs ${flow.what} on the secret file ${shown}; redaction cannot match values it changes`);
|
|
124
|
+
}
|
|
125
|
+
else if (flow.to.kind === 'clipboard') {
|
|
126
|
+
findings.flag('upload', `it uploads data: ${flow.what} puts the secret file ${shown} on the clipboard`);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const dir = flow.to.dir || (await isDir(flow.to.abs, ctx.fs));
|
|
130
|
+
const dest = dir ? path.join(flow.to.abs, path.basename(source.abs)) : flow.to.abs;
|
|
131
|
+
if (await isSecret(dest))
|
|
132
|
+
continue;
|
|
133
|
+
findings.flag('secret-into-plain-file', `it copies the secret file ${shown} into ${show(path.resolve(dest), ctx)} with ${flow.what}, which is not a secret file`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function isDir(abs, fs) {
|
|
139
|
+
try {
|
|
140
|
+
await fs.readDir(abs);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function bashTargets(command, ctx, findings) {
|
|
148
|
+
const analysis = analyzeBash(command, { cwd: ctx.cwd, homeDir: ctx.homeDir }, findings);
|
|
149
|
+
const targets = [];
|
|
150
|
+
for (const p of analysis.paths) {
|
|
151
|
+
const target = await makeTarget(p.raw, p.abs, p.access, ctx, p.glob ? { dot: analysis.dotglob } : undefined);
|
|
152
|
+
// A bare word is only a target when it leads somewhere that matters.
|
|
153
|
+
const plain = target.zone === 'workspace' || target.zone === 'temp' || target.zone === 'trusted';
|
|
154
|
+
if (p.hard || target.secretFile || !plain)
|
|
155
|
+
targets.push(target);
|
|
156
|
+
}
|
|
157
|
+
await flagDestructive(analysis.destructiveChecks, ctx, findings);
|
|
158
|
+
await flagFlows(analysis.flows, ctx, findings);
|
|
159
|
+
const secretVars = analysis.envRefs.filter((name) => SECRET_KEY_PATTERN.test(name) || ctx.secretEnvNames.has(name));
|
|
160
|
+
if (secretVars.length > 0) {
|
|
161
|
+
findings.flag('secret-env-expansion', `it expands ${secretVars.map((n) => `$${n}`).join(', ')}, which ${secretVars.length === 1 ? 'holds a secret' : 'hold secrets'} the command can send or print`);
|
|
162
|
+
}
|
|
163
|
+
return targets;
|
|
164
|
+
}
|
|
165
|
+
async function fileTarget(toolName, input, ctx) {
|
|
166
|
+
const kind = TOOL_KIND[toolName];
|
|
167
|
+
const rawPath = stringField(input, 'path') ?? (kind === 'read' && toolName !== 'read' ? '.' : undefined);
|
|
168
|
+
const access = kind === 'write' ? 'write' : 'read';
|
|
169
|
+
const abs = rawPath === undefined ? null : resolveLikePi(rawPath, ctx.cwd, ctx.homeDir);
|
|
170
|
+
if (abs === null) {
|
|
171
|
+
const shown = rawPath ?? '(no path)';
|
|
172
|
+
return { raw: shown, path: shown, access, zone: 'unresolvable', secretFile: false, label: 'unresolvable' };
|
|
173
|
+
}
|
|
174
|
+
return makeTarget(rawPath, abs, access, ctx, GLOB_CHARS.test(rawPath) ? { dot: true } : undefined);
|
|
175
|
+
}
|
|
176
|
+
function uniqueTargets(targets) {
|
|
177
|
+
const seen = new Set();
|
|
178
|
+
return targets.filter((t) => {
|
|
179
|
+
const key = `${t.access}\0${t.path}`;
|
|
180
|
+
if (seen.has(key))
|
|
181
|
+
return false;
|
|
182
|
+
seen.add(key);
|
|
183
|
+
return true;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export async function classify(call, ctx) {
|
|
187
|
+
const { toolName, input } = call;
|
|
188
|
+
const findings = new Findings();
|
|
189
|
+
const command = toolName === 'bash' ? stringField(input, 'command') ?? '' : undefined;
|
|
190
|
+
const targets = uniqueTargets(command === undefined ? [await fileTarget(toolName, input, ctx)] : await bashTargets(command, ctx, findings));
|
|
191
|
+
const glob = toolName === 'grep' ? stringField(input, 'glob') : undefined;
|
|
192
|
+
if (glob && globNamesSecretFiles(glob))
|
|
193
|
+
findings.flag('secret-file', `the glob ${glob} names secret files; matches are redacted`);
|
|
194
|
+
for (const target of targets) {
|
|
195
|
+
const shown = show(target.path, ctx);
|
|
196
|
+
const signal = ZONE_SIGNAL[target.zone];
|
|
197
|
+
if (signal)
|
|
198
|
+
findings.flag(signal, zoneSentence(target, shown));
|
|
199
|
+
if (target.secretFile)
|
|
200
|
+
findings.flag('secret-file', `${shown} is a secret file: its values reach the model only as placeholders`);
|
|
201
|
+
}
|
|
202
|
+
const written = toolName === 'write' || toolName === 'edit' ? targets[0] : undefined;
|
|
203
|
+
if (written && !written.secretFile) {
|
|
204
|
+
const found = newTexts(toolName, input)
|
|
205
|
+
.map((text) => ctx.vault.findSecret(text))
|
|
206
|
+
.find(Boolean);
|
|
207
|
+
if (found) {
|
|
208
|
+
const shown = show(written.path, ctx);
|
|
209
|
+
findings.flag('secret-into-plain-file', found.kind === 'value'
|
|
210
|
+
? `the new content of ${shown} holds the value of ${found.name}, and ${shown} is not a secret file`
|
|
211
|
+
: `the new content of ${shown} holds the placeholder for ${found.name}; it would be written as literal text, because ${shown} is not a secret file`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
toolCallId: call.toolCallId,
|
|
216
|
+
toolName,
|
|
217
|
+
kind: TOOL_KIND[toolName],
|
|
218
|
+
targets,
|
|
219
|
+
...(command === undefined ? {} : { command: normalizeCommand(command) }),
|
|
220
|
+
signals: [...findings.signals],
|
|
221
|
+
signalReasons: findings.reasons
|
|
222
|
+
};
|
|
223
|
+
}
|
package/esm/engine.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The permission engine: classify a tool call, decide it against the mode,
|
|
3
|
+
* the grants and the fixed lists, and keep secrets out of what the model sees.
|
|
4
|
+
*
|
|
5
|
+
* Harness-neutral. A harness adapter (the pi lane in `@agentic-kit/pi`) owns the
|
|
6
|
+
* glue: call `evaluate` on a tool call and show `decision.prompt` on an ask,
|
|
7
|
+
* call `restoreInput` with the decision before the tool runs, and
|
|
8
|
+
* `redactResult` on every result. The engine holds no state about one call
|
|
9
|
+
* between those steps: the decision carries all of it.
|
|
10
|
+
*/
|
|
11
|
+
import { type PolicyRules } from './policy';
|
|
12
|
+
import { type FsProbe, type Grant, type PermissionDecision, type PermissionMode } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* The fixed paths a host knows about. Every entry is an absolute path (a file
|
|
15
|
+
* or a directory, matched as "equal or inside") unless it says otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export interface RootsInput {
|
|
18
|
+
/** The project folders. Defaults to `[cwd]`. */
|
|
19
|
+
workspace?: string[];
|
|
20
|
+
/** Read-only roots the agent needs (skills, prompts, harness docs). Writes there are DENY. */
|
|
21
|
+
trustedRead?: string[];
|
|
22
|
+
/** Roots the agent may read and run from (harness scripts). Writes there are DENY. */
|
|
23
|
+
trustedExec?: string[];
|
|
24
|
+
/** Scratch dirs: read and write without a prompt. Defaults to the OS temp dirs. */
|
|
25
|
+
temp?: string[];
|
|
26
|
+
/** Added to the built-in credential list (`defaultHardDeny(homeDir)`). Read, write and run are DENY. */
|
|
27
|
+
hardDeny?: string[];
|
|
28
|
+
/** Absolute paths whose writes are DENY in every mode (the permission store, the agent dir). */
|
|
29
|
+
protectedWrite?: string[];
|
|
30
|
+
/** Added to the per-workspace ask-write list (`.git/hooks`, `.husky`, …). Writes ask outside Full mode. */
|
|
31
|
+
askWrite?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface SecretSourceInput {
|
|
34
|
+
/** Extra secret values the host knows of (a key it just minted). Name → value. */
|
|
35
|
+
values?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* The environment the tools run with. Values whose names look secret (or
|
|
38
|
+
* that are token-shaped) are redacted too, so `env | grep TOKEN` shows
|
|
39
|
+
* placeholders. Kept across refreshes.
|
|
40
|
+
*/
|
|
41
|
+
env?: Record<string, string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
export interface PermissionEngineOptions {
|
|
44
|
+
cwd: string;
|
|
45
|
+
homeDir: string;
|
|
46
|
+
roots?: RootsInput;
|
|
47
|
+
/**
|
|
48
|
+
* More hard-deny paths, listed again at every decision: entries that can
|
|
49
|
+
* appear while a session runs (another tool's data dir, a new store file).
|
|
50
|
+
* A throw fails the decision, and the call is blocked.
|
|
51
|
+
*/
|
|
52
|
+
liveHardDeny?: () => Promise<readonly string[]>;
|
|
53
|
+
/** Defaults to the Node fs (`nodeFsProbe`). */
|
|
54
|
+
fs?: FsProbe;
|
|
55
|
+
/** Per-install HMAC key for placeholder suffixes. Without one, a random key per engine. */
|
|
56
|
+
placeholderKey?: string;
|
|
57
|
+
/** Non-fatal problems (an unreadable `.env`): the engine goes on with what it has. */
|
|
58
|
+
onError?: (error: unknown, where: string) => void;
|
|
59
|
+
}
|
|
60
|
+
export interface ToolCallInput {
|
|
61
|
+
toolCallId: string;
|
|
62
|
+
toolName: string;
|
|
63
|
+
input: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export interface EvaluateContext {
|
|
66
|
+
mode: PermissionMode;
|
|
67
|
+
/** Chat and project grants together; the engine checks chat grants first. */
|
|
68
|
+
grants: readonly Grant[];
|
|
69
|
+
/** User allow and deny rules. Reserved: v1 has no rule editor. */
|
|
70
|
+
rules?: PolicyRules;
|
|
71
|
+
}
|
|
72
|
+
export interface ToolResultInput {
|
|
73
|
+
toolName: string;
|
|
74
|
+
content: readonly unknown[];
|
|
75
|
+
details?: unknown;
|
|
76
|
+
}
|
|
77
|
+
export interface RedactedResult {
|
|
78
|
+
content: unknown[];
|
|
79
|
+
details?: unknown;
|
|
80
|
+
/** `true` when at least one value was replaced. */
|
|
81
|
+
changed: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface PermissionEngine {
|
|
84
|
+
/**
|
|
85
|
+
* Classify and decide one tool call. Returns `null` for a tool this layer
|
|
86
|
+
* does not own (anything that is not a pi built-in), so the next gate decides.
|
|
87
|
+
*/
|
|
88
|
+
evaluate(call: ToolCallInput, context: EvaluateContext): Promise<PermissionDecision | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Put real secret values back into the call's input, in place, where that is
|
|
91
|
+
* safe: a write or edit to a secret file always, a bash command only when
|
|
92
|
+
* `approved` (a person saw the placeholder in the command and allowed it).
|
|
93
|
+
*/
|
|
94
|
+
restoreInput(decision: PermissionDecision, input: Record<string, unknown>, options?: {
|
|
95
|
+
approved?: boolean;
|
|
96
|
+
}): void;
|
|
97
|
+
/**
|
|
98
|
+
* Replace known secret values in a tool result with placeholders. After a
|
|
99
|
+
* tool that can write, the vault first re-reads the workspace secret files,
|
|
100
|
+
* so a value that tool just wrote is already known. Throws on failure; the
|
|
101
|
+
* caller fails closed.
|
|
102
|
+
*/
|
|
103
|
+
redactResult(result: ToolResultInput): Promise<RedactedResult>;
|
|
104
|
+
/** Re-read the workspace secret files, and take in host values and env. */
|
|
105
|
+
refreshSecrets(extra?: SecretSourceInput): Promise<void>;
|
|
106
|
+
/** Add a value the host knows is secret (a minted API key). */
|
|
107
|
+
addSecret(name: string, value: string): void;
|
|
108
|
+
}
|
|
109
|
+
export declare function createPermissionEngine(options: PermissionEngineOptions): PermissionEngine;
|
package/esm/engine.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The permission engine: classify a tool call, decide it against the mode,
|
|
3
|
+
* the grants and the fixed lists, and keep secrets out of what the model sees.
|
|
4
|
+
*
|
|
5
|
+
* Harness-neutral. A harness adapter (the pi lane in `@agentic-kit/pi`) owns the
|
|
6
|
+
* glue: call `evaluate` on a tool call and show `decision.prompt` on an ask,
|
|
7
|
+
* call `restoreInput` with the decision before the tool runs, and
|
|
8
|
+
* `redactResult` on every result. The engine holds no state about one call
|
|
9
|
+
* between those steps: the decision carries all of it.
|
|
10
|
+
*/
|
|
11
|
+
import { randomBytes } from 'node:crypto';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import { classify } from './classify';
|
|
14
|
+
import { nodeFsProbe } from './node-fs';
|
|
15
|
+
import { decide } from './policy';
|
|
16
|
+
import { buildHostHardDeny, buildRoots } from './roots';
|
|
17
|
+
import { isSecretFile } from './secret-files';
|
|
18
|
+
import { collectWorkspaceSecrets, isSecretEntry, redactToolResult, SecretVault } from './secrets';
|
|
19
|
+
import { mapCommand, mapWriteTexts } from './tool-input';
|
|
20
|
+
import { isBuiltinTool, TOOL_KIND } from './types';
|
|
21
|
+
const MIN_HOST_SECRET = 4;
|
|
22
|
+
/**
|
|
23
|
+
* A write or edit to a secret file, by the file it really lands in: a link
|
|
24
|
+
* named `.env` that points at a plain file gets no real values, and a plainly
|
|
25
|
+
* named link to `.env` gets them back, as the values came from there.
|
|
26
|
+
*/
|
|
27
|
+
function writesSecretFile(request) {
|
|
28
|
+
if (request.toolName !== 'write' && request.toolName !== 'edit')
|
|
29
|
+
return false;
|
|
30
|
+
const target = request.targets[0];
|
|
31
|
+
return Boolean(target) && target.zone !== 'unresolvable' && isSecretFile(target.path);
|
|
32
|
+
}
|
|
33
|
+
export function createPermissionEngine(options) {
|
|
34
|
+
const fs = options.fs ?? nodeFsProbe;
|
|
35
|
+
const cwd = path.resolve(options.cwd);
|
|
36
|
+
const homeDir = path.resolve(options.homeDir);
|
|
37
|
+
const vault = new SecretVault(options.placeholderKey ?? randomBytes(32).toString('hex'));
|
|
38
|
+
const report = (error, where) => options.onError?.(error, where);
|
|
39
|
+
let rootsReady;
|
|
40
|
+
const getRoots = () => (rootsReady ??= buildRoots({ cwd, homeDir, ...options.roots }, fs));
|
|
41
|
+
const decisionRoots = async () => {
|
|
42
|
+
const roots = await getRoots();
|
|
43
|
+
if (!options.liveHardDeny)
|
|
44
|
+
return roots;
|
|
45
|
+
const live = await buildHostHardDeny(await options.liveHardDeny(), fs);
|
|
46
|
+
return { ...roots, hardDeny: [...roots.hardDeny, ...live] };
|
|
47
|
+
};
|
|
48
|
+
let hostEnv = {};
|
|
49
|
+
/** The env names whose values are secret: `$NAME` in a command asks. */
|
|
50
|
+
const secretEnvNames = new Set();
|
|
51
|
+
const addHostSecret = (name, value) => {
|
|
52
|
+
if (value && value.length >= MIN_HOST_SECRET)
|
|
53
|
+
vault.add(name, value, 'host');
|
|
54
|
+
};
|
|
55
|
+
const refresh = async (extra) => {
|
|
56
|
+
for (const [name, value] of Object.entries(extra?.values ?? {}))
|
|
57
|
+
addHostSecret(name, value);
|
|
58
|
+
if (extra?.env)
|
|
59
|
+
hostEnv = { ...hostEnv, ...extra.env };
|
|
60
|
+
for (const [name, value] of Object.entries(hostEnv)) {
|
|
61
|
+
if (!value || !isSecretEntry(name, value))
|
|
62
|
+
continue;
|
|
63
|
+
vault.add(name, value, 'host');
|
|
64
|
+
secretEnvNames.add(name);
|
|
65
|
+
}
|
|
66
|
+
const roots = await getRoots();
|
|
67
|
+
const collected = await collectWorkspaceSecrets(roots.workspace.map((w) => w.path), fs);
|
|
68
|
+
for (const { file, error } of collected.errors)
|
|
69
|
+
report(error, `secrets: ${file}`);
|
|
70
|
+
vault.clear('file');
|
|
71
|
+
for (const { name, value } of collected.values)
|
|
72
|
+
vault.add(name, value, 'file');
|
|
73
|
+
};
|
|
74
|
+
// The first read of the workspace secrets happens lazily, once; every later
|
|
75
|
+
// refresh replaces it.
|
|
76
|
+
let vaultReady;
|
|
77
|
+
const refreshReported = (extra) => (vaultReady = refresh(extra).catch((error) => report(error, 'secrets')));
|
|
78
|
+
const ensureVault = () => vaultReady ?? refreshReported();
|
|
79
|
+
const restore = (text) => vault.restore(text);
|
|
80
|
+
return {
|
|
81
|
+
async evaluate(call, context) {
|
|
82
|
+
const { toolName } = call;
|
|
83
|
+
if (!isBuiltinTool(toolName))
|
|
84
|
+
return null;
|
|
85
|
+
const [roots] = await Promise.all([decisionRoots(), ensureVault()]);
|
|
86
|
+
const request = await classify({ toolCallId: call.toolCallId, toolName, input: call.input ?? {} }, { cwd, homeDir, roots, fs, vault, secretEnvNames });
|
|
87
|
+
return decide(request, { ...context, workspace: roots.workspace[0]?.path, homeDir });
|
|
88
|
+
},
|
|
89
|
+
restoreInput(decision, input, restoreOptions) {
|
|
90
|
+
if (decision.request.toolName === 'bash') {
|
|
91
|
+
if (restoreOptions?.approved)
|
|
92
|
+
mapCommand(input, restore);
|
|
93
|
+
}
|
|
94
|
+
else if (writesSecretFile(decision.request)) {
|
|
95
|
+
mapWriteTexts(input, restore);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
async redactResult(result) {
|
|
99
|
+
// A built-in that only reads cannot change a file, so the vault needs no refresh after it.
|
|
100
|
+
const readOnly = isBuiltinTool(result.toolName) && TOOL_KIND[result.toolName] === 'read';
|
|
101
|
+
if (!readOnly)
|
|
102
|
+
await refreshReported();
|
|
103
|
+
return redactToolResult(vault, result.content, result.details);
|
|
104
|
+
},
|
|
105
|
+
refreshSecrets: (extra) => refreshReported(extra),
|
|
106
|
+
addSecret: addHostSecret
|
|
107
|
+
};
|
|
108
|
+
}
|
package/esm/env.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The environment a shell command gets. A host process inherits the user's
|
|
3
|
+
* shell environment, with provider keys and tokens in it; a command that
|
|
4
|
+
* expands one can send it out without the model ever seeing the value. The
|
|
5
|
+
* host passes the environment of each command through `scrubEnv`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A copy of `env` without the variables that hold a secret: a name that looks
|
|
9
|
+
* secret (the vault's key rule), whatever the value's length, unless the value
|
|
10
|
+
* is a path; or a value with a token shape, a URL password included. The
|
|
11
|
+
* shell startup variables go too.
|
|
12
|
+
*/
|
|
13
|
+
export declare function scrubEnv(env: Readonly<Record<string, string | undefined>>): Record<string, string>;
|