pi-codex-auto-review 0.1.3 → 0.2.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/NOTICE +4 -2
- package/README.ko.md +85 -0
- package/README.md +51 -52
- package/dist/approval-commands.d.ts +3 -3
- package/dist/approval-commands.js +161 -34
- package/dist/approval-commands.js.map +1 -1
- package/dist/approval-settings.d.ts +1 -1
- package/dist/approval-settings.js +17 -10
- package/dist/approval-settings.js.map +1 -1
- package/dist/approvals.d.ts +10 -9
- package/dist/approvals.js +196 -75
- package/dist/approvals.js.map +1 -1
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +37 -13
- package/dist/audit.js.map +1 -1
- package/dist/cli.js +63 -34
- package/dist/cli.js.map +1 -1
- package/dist/context-files.d.ts +2 -2
- package/dist/context-files.js +40 -19
- package/dist/context-files.js.map +1 -1
- package/dist/contracts.d.ts +39 -39
- package/dist/contracts.js +117 -51
- package/dist/contracts.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +147 -43
- package/dist/index.js.map +1 -1
- package/dist/pi-host.js +3 -3
- package/dist/pi-host.js.map +1 -1
- package/dist/policy/domains.js +17 -7
- package/dist/policy/domains.js.map +1 -1
- package/dist/policy/index.d.ts +7 -7
- package/dist/policy/index.js +382 -139
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/paths.js +31 -18
- package/dist/policy/paths.js.map +1 -1
- package/dist/policy/rule-engine.d.ts +2 -0
- package/dist/policy/rule-engine.js +283 -0
- package/dist/policy/rule-engine.js.map +1 -0
- package/dist/policy/rule-types.d.ts +30 -0
- package/dist/policy/rule-types.js +2 -0
- package/dist/policy/rule-types.js.map +1 -0
- package/dist/policy/rules-sync.d.ts +1 -0
- package/dist/policy/rules-sync.js +14 -0
- package/dist/policy/rules-sync.js.map +1 -0
- package/dist/policy/rules-worker.d.ts +1 -0
- package/dist/policy/rules-worker.js +14 -0
- package/dist/policy/rules-worker.js.map +1 -0
- package/dist/policy/rules.d.ts +4 -31
- package/dist/policy/rules.js +126 -38
- package/dist/policy/rules.js.map +1 -1
- package/dist/policy/shell.js +70 -41
- package/dist/policy/shell.js.map +1 -1
- package/dist/policy/starlark/builtins.d.ts +6 -0
- package/dist/policy/starlark/builtins.js +764 -0
- package/dist/policy/starlark/builtins.js.map +1 -0
- package/dist/policy/starlark/evaluator.d.ts +18 -0
- package/dist/policy/starlark/evaluator.js +518 -0
- package/dist/policy/starlark/evaluator.js.map +1 -0
- package/dist/policy/starlark/lexer.d.ts +14 -0
- package/dist/policy/starlark/lexer.js +189 -0
- package/dist/policy/starlark/lexer.js.map +1 -0
- package/dist/policy/starlark/parser.d.ts +140 -0
- package/dist/policy/starlark/parser.js +508 -0
- package/dist/policy/starlark/parser.js.map +1 -0
- package/dist/policy/starlark/validation.d.ts +4 -0
- package/dist/policy/starlark/validation.js +183 -0
- package/dist/policy/starlark/validation.js.map +1 -0
- package/dist/policy/starlark/values.d.ts +46 -0
- package/dist/policy/starlark/values.js +363 -0
- package/dist/policy/starlark/values.js.map +1 -0
- package/dist/reports.d.ts +1 -1
- package/dist/reports.js +66 -30
- package/dist/reports.js.map +1 -1
- package/dist/review/context.d.ts +16 -3
- package/dist/review/context.js +254 -48
- package/dist/review/context.js.map +1 -1
- package/dist/review/investigation.d.ts +2 -2
- package/dist/review/investigation.js +57 -16
- package/dist/review/investigation.js.map +1 -1
- package/dist/review/lifecycle.d.ts +1 -1
- package/dist/review/lifecycle.js +72 -29
- package/dist/review/lifecycle.js.map +1 -1
- package/dist/review/policy.js +27 -5
- package/dist/review/policy.js.map +1 -1
- package/dist/review/upstream-policy.js +1 -1
- package/dist/review/upstream-policy.js.map +1 -1
- package/dist/review/user-input.d.ts +5 -0
- package/dist/review/user-input.js +54 -0
- package/dist/review/user-input.js.map +1 -0
- package/dist/reviewer.d.ts +16 -6
- package/dist/reviewer.js +258 -70
- package/dist/reviewer.js.map +1 -1
- package/dist/signals.js +24 -9
- package/dist/signals.js.map +1 -1
- package/dist/startup.d.ts +4 -4
- package/dist/startup.js +139 -41
- package/dist/startup.js.map +1 -1
- package/dist/tools/controller.d.ts +19 -13
- package/dist/tools/controller.js +460 -118
- package/dist/tools/controller.js.map +1 -1
- package/dist/tools/environment.d.ts +1 -0
- package/dist/tools/environment.js +5 -0
- package/dist/tools/environment.js.map +1 -1
- package/dist/tools/executor.d.ts +1 -1
- package/dist/tools/executor.js +45 -28
- package/dist/tools/executor.js.map +1 -1
- package/dist/tools/external.d.ts +9 -8
- package/dist/tools/external.js +22 -11
- package/dist/tools/external.js.map +1 -1
- package/dist/tools/mcp.d.ts +6 -6
- package/dist/tools/mcp.js +208 -79
- package/dist/tools/mcp.js.map +1 -1
- package/dist/tools/mutation-queue.js.map +1 -1
- package/docs/publishing.ko.md +114 -0
- package/docs/publishing.md +49 -47
- package/docs/security/dependencies.ko.md +54 -0
- package/docs/security/dependencies.md +27 -26
- package/docs/testing/auto-review-protection.ko.md +158 -0
- package/docs/testing/auto-review-protection.md +105 -97
- package/docs/usage.ko.md +242 -0
- package/docs/usage.md +127 -111
- package/package.json +106 -95
- package/dist/native/darwin-arm64/artifact.json +0 -5
- package/dist/native/darwin-arm64/pi-guard-execpolicy +0 -0
- package/dist/native/linux-x64/artifact.json +0 -5
- package/dist/native/linux-x64/pi-guard-execpolicy +0 -0
- package/native/execpolicy/LICENSE +0 -201
- package/native/execpolicy/NOTICE +0 -6
package/dist/policy/rules.d.ts
CHANGED
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly justification?: string;
|
|
5
|
-
}
|
|
1
|
+
import type { CompiledRules, PrefixRule, RuleSource } from "./rule-types.js";
|
|
2
|
+
export type { CompiledRules, PrefixRule, RuleMatch, RuleSource, } from "./rule-types.js";
|
|
3
|
+
export { CODEX_EXECPOLICY_REVISION } from "./rule-types.js";
|
|
6
4
|
export declare function matchesRule(argv: readonly string[], rule: PrefixRule): boolean;
|
|
7
|
-
|
|
8
|
-
export interface RuleSource {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly source: string;
|
|
11
|
-
}
|
|
12
|
-
export interface RuleMatch {
|
|
13
|
-
readonly decision: PrefixRule['decision'];
|
|
14
|
-
readonly justification?: string | null;
|
|
15
|
-
readonly matchedPrefix: readonly string[];
|
|
16
|
-
readonly resolvedProgram?: string | null;
|
|
17
|
-
}
|
|
18
|
-
export interface CompiledRules {
|
|
19
|
-
readonly revision: string;
|
|
20
|
-
readonly rules: readonly PrefixRule[];
|
|
21
|
-
readonly matches: readonly (readonly RuleMatch[])[];
|
|
22
|
-
readonly allowedDomains: readonly string[];
|
|
23
|
-
readonly deniedDomains: readonly string[];
|
|
24
|
-
readonly networkRules: readonly {
|
|
25
|
-
host: string;
|
|
26
|
-
protocol: string;
|
|
27
|
-
decision: PrefixRule['decision'];
|
|
28
|
-
justification?: string | null;
|
|
29
|
-
}[];
|
|
30
|
-
readonly hostExecutables: Readonly<Record<string, readonly string[]>>;
|
|
31
|
-
}
|
|
32
|
-
/** Compatibility reader; parsing and example validation run in Codex's actual Starlark engine. */
|
|
5
|
+
/** Preserve the synchronous API and its deadline without running rules on the host event loop. */
|
|
33
6
|
export declare function parseRules(source: string): readonly PrefixRule[];
|
|
34
7
|
export declare function evaluateRules(sources: readonly RuleSource[], commands?: readonly (readonly string[])[], signal?: AbortSignal): Promise<CompiledRules>;
|
|
35
8
|
/** Advanced scripts are matched as the real outer shell invocation, never as a safe inner prefix. */
|
package/dist/policy/rules.js
CHANGED
|
@@ -1,59 +1,147 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { GuardError, immutable } from
|
|
6
|
-
import {
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { Worker } from "node:worker_threads";
|
|
5
|
+
import { GuardError, immutable } from "../contracts.js";
|
|
6
|
+
import { evaluateRuleSources } from "./rule-engine.js";
|
|
7
|
+
import { analyzeShell } from "./shell.js";
|
|
8
|
+
export { CODEX_EXECPOLICY_REVISION } from "./rule-types.js";
|
|
7
9
|
export function matchesRule(argv, rule) {
|
|
8
|
-
return rule.pattern.length <= argv.length &&
|
|
10
|
+
return (rule.pattern.length <= argv.length &&
|
|
11
|
+
rule.pattern.every((part, index) => {
|
|
12
|
+
const argument = argv[index];
|
|
13
|
+
return typeof part === "string"
|
|
14
|
+
? part === argument
|
|
15
|
+
: argument !== undefined && part.includes(argument);
|
|
16
|
+
}));
|
|
9
17
|
}
|
|
10
|
-
export const CODEX_EXECPOLICY_REVISION = 'a956835d020762cb2b570053af06f643a11c0ecc';
|
|
11
18
|
const MAX_BYTES = 8 * 1024 * 1024;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
function isScalarString(value) {
|
|
20
|
+
if (typeof value !== "string")
|
|
21
|
+
return false;
|
|
22
|
+
for (const char of value) {
|
|
23
|
+
const point = char.codePointAt(0) ?? 0;
|
|
24
|
+
if (point >= 0xd800 && point <= 0xdfff)
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
15
29
|
function request(sources, commands) {
|
|
16
30
|
const input = JSON.stringify({ sources, commands });
|
|
17
31
|
if (Buffer.byteLength(input) > MAX_BYTES)
|
|
18
|
-
throw new GuardError(
|
|
32
|
+
throw new GuardError("INVALID_RULES", "Rule request exceeds the supported size");
|
|
33
|
+
const data = JSON.parse(input);
|
|
34
|
+
if (!Array.isArray(data.sources) ||
|
|
35
|
+
!Array.isArray(data.commands) ||
|
|
36
|
+
data.sources.some((source) => source === null ||
|
|
37
|
+
typeof source !== "object" ||
|
|
38
|
+
!isScalarString(source.name) ||
|
|
39
|
+
!isScalarString(source.source) ||
|
|
40
|
+
Object.keys(source).some((key) => key !== "name" && key !== "source")) ||
|
|
41
|
+
data.commands.some((command) => !Array.isArray(command) ||
|
|
42
|
+
command.some((argument) => !isScalarString(argument)))) {
|
|
43
|
+
throw new GuardError("INVALID_RULES", "Invalid rule request schema");
|
|
44
|
+
}
|
|
19
45
|
return input;
|
|
20
46
|
}
|
|
21
|
-
|
|
22
|
-
const result = JSON.parse(stdout);
|
|
23
|
-
if (result.revision !== CODEX_EXECPOLICY_REVISION || !Array.isArray(result.rules) || !Array.isArray(result.matches) || !Array.isArray(result.allowedDomains) || !Array.isArray(result.deniedDomains))
|
|
24
|
-
throw new GuardError('INVALID_RULES', 'Unexpected Codex rule engine response');
|
|
25
|
-
return immutable(result);
|
|
26
|
-
}
|
|
27
|
-
/** Compatibility reader; parsing and example validation run in Codex's actual Starlark engine. */
|
|
47
|
+
/** Preserve the synchronous API and its deadline without running rules on the host event loop. */
|
|
28
48
|
export function parseRules(source) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
const sources = [{ name: "inline.rules", source }];
|
|
50
|
+
const input = request(sources, []);
|
|
51
|
+
try {
|
|
52
|
+
const result = spawnSync(process.execPath, [
|
|
53
|
+
"--max-old-space-size=64",
|
|
54
|
+
fileURLToPath(new URL("./rules-sync.js", import.meta.url)),
|
|
55
|
+
], {
|
|
56
|
+
input,
|
|
57
|
+
encoding: "utf8",
|
|
58
|
+
timeout: 10000,
|
|
59
|
+
killSignal: "SIGKILL",
|
|
60
|
+
maxBuffer: MAX_BYTES,
|
|
61
|
+
env: process.platform === "win32"
|
|
62
|
+
? { SystemRoot: process.env.SystemRoot }
|
|
63
|
+
: {},
|
|
64
|
+
});
|
|
65
|
+
if (result.error || result.status !== 0)
|
|
66
|
+
throw (result.error ??
|
|
67
|
+
new Error(result.stderr.slice(0, 4000) ||
|
|
68
|
+
"Rule process exited without a result"));
|
|
69
|
+
return immutable(JSON.parse(result.stdout).rules);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw new GuardError("INVALID_RULES", `Codex-compatible rule engine failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
73
|
+
}
|
|
33
74
|
}
|
|
34
75
|
export async function evaluateRules(sources, commands = [], signal) {
|
|
35
|
-
const
|
|
76
|
+
const data = JSON.parse(request(sources, commands));
|
|
36
77
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
78
|
+
signal?.throwIfAborted();
|
|
79
|
+
if (!data.sources.length)
|
|
80
|
+
return immutable(evaluateRuleSources([], data.commands));
|
|
81
|
+
const result = await new Promise((resolve, reject) => {
|
|
82
|
+
const worker = new Worker(new URL("./rules-worker.js", import.meta.url), {
|
|
83
|
+
workerData: data,
|
|
84
|
+
execArgv: [],
|
|
85
|
+
env: process.platform === "win32"
|
|
86
|
+
? { SystemRoot: process.env.SystemRoot }
|
|
87
|
+
: {},
|
|
88
|
+
resourceLimits: {
|
|
89
|
+
maxOldGenerationSizeMb: 64,
|
|
90
|
+
stackSizeMb: 4,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
let isSettled = false;
|
|
94
|
+
const finish = (error, value) => {
|
|
95
|
+
if (isSettled)
|
|
96
|
+
return;
|
|
97
|
+
isSettled = true;
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
signal?.removeEventListener("abort", abort);
|
|
100
|
+
worker.removeAllListeners();
|
|
101
|
+
void worker.terminate();
|
|
102
|
+
if (error)
|
|
103
|
+
reject(error);
|
|
104
|
+
else if (value)
|
|
105
|
+
resolve(value);
|
|
106
|
+
else
|
|
107
|
+
reject(new Error("Rule worker produced no result"));
|
|
108
|
+
};
|
|
109
|
+
const abort = () => finish(new Error("Rule evaluation cancelled", {
|
|
110
|
+
cause: signal?.reason,
|
|
111
|
+
}));
|
|
112
|
+
const timer = setTimeout(() => finish(new Error("Rule evaluation timed out")), 10000);
|
|
113
|
+
worker.once("message", (message) => finish(message.error ? new Error(message.error) : undefined, message.result));
|
|
114
|
+
worker.once("error", (error) => finish(error));
|
|
115
|
+
worker.once("exit", (code) => finish(new Error(`Rule worker exited without a result (${code})`)));
|
|
116
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
117
|
+
if (signal?.aborted)
|
|
118
|
+
abort();
|
|
119
|
+
});
|
|
120
|
+
return immutable(result);
|
|
42
121
|
}
|
|
43
122
|
catch (error) {
|
|
44
|
-
throw new GuardError(
|
|
123
|
+
throw new GuardError("INVALID_RULES", "Codex-compatible rule engine could not evaluate the trusted rules", { cause: error });
|
|
45
124
|
}
|
|
46
125
|
}
|
|
47
126
|
/** Advanced scripts are matched as the real outer shell invocation, never as a safe inner prefix. */
|
|
48
|
-
export function ruleCommands(command, shellPath =
|
|
127
|
+
export function ruleCommands(command, shellPath = "/bin/bash", depth = 0) {
|
|
49
128
|
const parsed = analyzeShell(command);
|
|
50
|
-
if (!parsed.isSupported ||
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
129
|
+
if (!parsed.isSupported ||
|
|
130
|
+
parsed.commands.some((item) => item.reads.length || item.writes.length) ||
|
|
131
|
+
depth > 4)
|
|
132
|
+
return [[shellPath, "-c", command]];
|
|
133
|
+
return parsed.commands.flatMap((item) => {
|
|
134
|
+
const [program, flag, script] = item.argv;
|
|
135
|
+
if (program !== undefined &&
|
|
136
|
+
["bash", "sh", "zsh", "dash"].includes(basename(program)) &&
|
|
137
|
+
item.argv.length === 3 &&
|
|
138
|
+
flag !== undefined &&
|
|
139
|
+
["-c", "-lc"].includes(flag) &&
|
|
140
|
+
script !== undefined) {
|
|
141
|
+
const inner = analyzeShell(script);
|
|
142
|
+
if (inner.isSupported &&
|
|
143
|
+
inner.commands.every((part) => !part.reads.length && !part.writes.length))
|
|
144
|
+
return ruleCommands(script, program, depth + 1);
|
|
57
145
|
}
|
|
58
146
|
return [item.argv];
|
|
59
147
|
});
|
package/dist/policy/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/policy/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/policy/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,MAAM,UAAU,WAAW,CACvB,IAAuB,EACvB,IAAgB;IAEhB,OAAO,CACH,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;QAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,OAAO,IAAI,KAAK,QAAQ;gBAC3B,CAAC,CAAC,IAAI,KAAK,QAAQ;gBACnB,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5D,CAAC,CAAC,CACL,CAAC;AACN,CAAC;AACD,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAClC,SAAS,cAAc,CAAC,KAAc;IAClC,I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KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACnC,IACI,KAAK,CAAC,WAAW;gBACjB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAChB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CACtD;gBAED,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/policy/shell.js
CHANGED
|
@@ -1,52 +1,61 @@
|
|
|
1
|
-
import { GuardError } from
|
|
1
|
+
import { GuardError } from "../contracts.js";
|
|
2
2
|
/** A bounded literal grammar. Expansion/interpreters cannot borrow permission from their first word. */
|
|
3
3
|
export function analyzeShell(command) {
|
|
4
|
-
if (typeof command !==
|
|
5
|
-
|
|
4
|
+
if (typeof command !== "string" ||
|
|
5
|
+
!command.trim() ||
|
|
6
|
+
command.includes("\0"))
|
|
7
|
+
throw new GuardError("INVALID_COMMAND", "Invalid shell command");
|
|
6
8
|
if (command.length > 100_000)
|
|
7
|
-
return {
|
|
9
|
+
return {
|
|
10
|
+
commands: [],
|
|
11
|
+
isSupported: false,
|
|
12
|
+
reason: "Command too long for literal analysis",
|
|
13
|
+
};
|
|
8
14
|
const commands = [];
|
|
9
|
-
let argv = [], writes = [], reads = [], word =
|
|
15
|
+
let argv = [], writes = [], reads = [], word = "", hasWord = false, quote = "", redirect = "";
|
|
10
16
|
let isSupported = true, reason;
|
|
11
|
-
const unsupported = (text) => {
|
|
17
|
+
const unsupported = (text) => {
|
|
18
|
+
isSupported = false;
|
|
19
|
+
reason ??= text;
|
|
20
|
+
};
|
|
12
21
|
const finishWord = () => {
|
|
13
22
|
if (!hasWord)
|
|
14
23
|
return;
|
|
15
|
-
if (redirect ===
|
|
24
|
+
if (redirect === ">")
|
|
16
25
|
writes.push(word);
|
|
17
|
-
else if (redirect ===
|
|
26
|
+
else if (redirect === "<")
|
|
18
27
|
reads.push(word);
|
|
19
28
|
else
|
|
20
29
|
argv.push(word);
|
|
21
|
-
word =
|
|
30
|
+
word = "";
|
|
22
31
|
hasWord = false;
|
|
23
|
-
redirect =
|
|
32
|
+
redirect = "";
|
|
24
33
|
};
|
|
25
34
|
const finishCommand = () => {
|
|
26
35
|
finishWord();
|
|
27
36
|
if (redirect)
|
|
28
|
-
unsupported(
|
|
37
|
+
unsupported("Missing redirection target");
|
|
29
38
|
if (argv.length)
|
|
30
39
|
commands.push({ argv, writes, reads });
|
|
31
40
|
else if (writes.length || reads.length)
|
|
32
|
-
unsupported(
|
|
41
|
+
unsupported("Redirection without literal command");
|
|
33
42
|
argv = [];
|
|
34
43
|
writes = [];
|
|
35
44
|
reads = [];
|
|
36
|
-
redirect =
|
|
45
|
+
redirect = "";
|
|
37
46
|
};
|
|
38
47
|
for (let i = 0; i < command.length; i++) {
|
|
39
|
-
const ch = command
|
|
48
|
+
const ch = command.charAt(i);
|
|
40
49
|
if (quote === "'") {
|
|
41
50
|
if (ch === "'")
|
|
42
|
-
quote =
|
|
51
|
+
quote = "";
|
|
43
52
|
else
|
|
44
53
|
word += ch;
|
|
45
54
|
continue;
|
|
46
55
|
}
|
|
47
|
-
if (ch ===
|
|
56
|
+
if (ch === "\\" && quote !== "'") {
|
|
48
57
|
if (i + 1 >= command.length)
|
|
49
|
-
unsupported(
|
|
58
|
+
unsupported("Trailing escape");
|
|
50
59
|
else {
|
|
51
60
|
word += command[++i];
|
|
52
61
|
hasWord = true;
|
|
@@ -54,7 +63,7 @@ export function analyzeShell(command) {
|
|
|
54
63
|
continue;
|
|
55
64
|
}
|
|
56
65
|
if (ch === '"') {
|
|
57
|
-
quote = quote === '"' ?
|
|
66
|
+
quote = quote === '"' ? "" : '"';
|
|
58
67
|
hasWord = true;
|
|
59
68
|
continue;
|
|
60
69
|
}
|
|
@@ -63,60 +72,80 @@ export function analyzeShell(command) {
|
|
|
63
72
|
hasWord = true;
|
|
64
73
|
continue;
|
|
65
74
|
}
|
|
66
|
-
if (ch ===
|
|
67
|
-
unsupported(
|
|
75
|
+
if (ch === "$" || ch === "`")
|
|
76
|
+
unsupported("Shell expansion requires review");
|
|
68
77
|
if (quote) {
|
|
69
78
|
word += ch;
|
|
70
79
|
continue;
|
|
71
80
|
}
|
|
72
|
-
if (
|
|
73
|
-
unsupported(
|
|
74
|
-
if (ch ===
|
|
75
|
-
unsupported(
|
|
81
|
+
if ("(){}*?~".includes(ch))
|
|
82
|
+
unsupported("Non-literal shell syntax requires review");
|
|
83
|
+
if (ch === "#" && !hasWord) {
|
|
84
|
+
unsupported("Comments require review");
|
|
76
85
|
break;
|
|
77
86
|
}
|
|
78
|
-
if (/\s/.test(ch) && ch !==
|
|
87
|
+
if (/\s/.test(ch) && ch !== "\n") {
|
|
79
88
|
finishWord();
|
|
80
89
|
continue;
|
|
81
90
|
}
|
|
82
|
-
if (ch ===
|
|
91
|
+
if (ch === ";" || ch === "|" || ch === "&" || ch === "\n") {
|
|
83
92
|
finishCommand();
|
|
84
|
-
if (command[i + 1] === ch &&
|
|
93
|
+
if (command[i + 1] === ch && "|&".includes(ch))
|
|
85
94
|
i++;
|
|
86
|
-
else if (ch ===
|
|
87
|
-
unsupported(
|
|
95
|
+
else if (ch === "&")
|
|
96
|
+
unsupported("Background execution requires review");
|
|
88
97
|
continue;
|
|
89
98
|
}
|
|
90
|
-
if (ch ===
|
|
99
|
+
if (ch === ">" || ch === "<") {
|
|
91
100
|
if (hasWord && /^\d+$/.test(word)) {
|
|
92
|
-
word =
|
|
101
|
+
word = "";
|
|
93
102
|
hasWord = false;
|
|
94
103
|
}
|
|
95
104
|
finishWord();
|
|
96
105
|
redirect = ch;
|
|
97
106
|
if (command[i + 1] === ch) {
|
|
98
107
|
i++;
|
|
99
|
-
if (ch ===
|
|
100
|
-
unsupported(
|
|
108
|
+
if (ch === "<")
|
|
109
|
+
unsupported("Here-documents require review");
|
|
101
110
|
}
|
|
102
|
-
if (command[i + 1] ===
|
|
103
|
-
unsupported(
|
|
111
|
+
if (command[i + 1] === "&")
|
|
112
|
+
unsupported("Descriptor redirection requires review");
|
|
104
113
|
continue;
|
|
105
114
|
}
|
|
106
115
|
word += ch;
|
|
107
116
|
hasWord = true;
|
|
108
117
|
}
|
|
109
118
|
if (quote)
|
|
110
|
-
unsupported(
|
|
119
|
+
unsupported("Unclosed quote");
|
|
111
120
|
finishCommand();
|
|
112
121
|
if (!commands.length)
|
|
113
|
-
unsupported(
|
|
114
|
-
if (commands.some(c => c.argv.some(a => /^\w+=/.test(a))))
|
|
115
|
-
unsupported(
|
|
122
|
+
unsupported("No literal command");
|
|
123
|
+
if (commands.some((c) => c.argv.some((a) => /^\w+=/.test(a))))
|
|
124
|
+
unsupported("Environment assignments require review");
|
|
116
125
|
return { commands, isSupported, ...(reason ? { reason } : {}) };
|
|
117
126
|
}
|
|
118
127
|
export function matchesPrefix(argv, prefix) {
|
|
119
|
-
return prefix.length > 0 &&
|
|
128
|
+
return (prefix.length > 0 &&
|
|
129
|
+
prefix.length <= argv.length &&
|
|
130
|
+
prefix.every((arg, i) => argv[i] === arg));
|
|
120
131
|
}
|
|
121
|
-
export const INTERPRETERS = new Set([
|
|
132
|
+
export const INTERPRETERS = new Set([
|
|
133
|
+
"bash",
|
|
134
|
+
"sh",
|
|
135
|
+
"zsh",
|
|
136
|
+
"fish",
|
|
137
|
+
"dash",
|
|
138
|
+
"node",
|
|
139
|
+
"python",
|
|
140
|
+
"python3",
|
|
141
|
+
"perl",
|
|
142
|
+
"ruby",
|
|
143
|
+
"env",
|
|
144
|
+
"eval",
|
|
145
|
+
"source",
|
|
146
|
+
"exec",
|
|
147
|
+
"xargs",
|
|
148
|
+
"sudo",
|
|
149
|
+
"osascript",
|
|
150
|
+
]);
|
|
122
151
|
//# sourceMappingURL=shell.js.map
|
package/dist/policy/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/policy/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/policy/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,wGAAwG;AACxG,MAAM,UAAU,YAAY,CAAC,OAAe;IACxC,IACI,OAAO,OAAO,KAAK,QAAQ;QAC3B,CAAC,OAAO,CAAC,IAAI,EAAE;QACf,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAEtB,MAAM,IAAI,UAAU,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,CAAC;IACrE,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO;QACxB,OAAO;YACH,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,uCAAuC;SAClD,CAAC;IACN,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,IAAI,IAAI,GAAa,EAAE,EACnB,MAAM,GAAa,EAAE,EACrB,KAAK,GAAa,EAAE,EACpB,IAAI,GAAG,EAAE,EACT,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,EAAE,EACV,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,WAAW,GAAG,IAAI,EAClB,MAA0B,CAAC;IAC/B,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE;QACjC,WAAW,GAAG,KAAK,CAAC;QACpB,MAAM,KAAK,IAAI,CAAC;IACpB,CAAC,CAAC;IACF,MAAM,UAAU,GAAG,GAAG,EAAE;QACpB,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,IAAI,QAAQ,KAAK,GAAG;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnC,IAAI,QAAQ,KAAK,GAA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IAEzB,OAAO,CACH,MAAM,CAAC,MAAM,GAAG,CAAC;QACjB,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;QAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAC5C,CAAC;AACN,CAAC;AACD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAChC,MAAM;IACN,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,WAAW;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Budget } from "./lexer.js";
|
|
2
|
+
import { type Callable, type Value } from "./values.js";
|
|
3
|
+
export declare function bindArguments(name: string, args: Value[], keywords: Map<string, Value>, spec: (string | [string, Value])[]): Value[];
|
|
4
|
+
export declare function standardGlobals(budget: Budget, mutate: (value: Value) => void): Map<string, Value>;
|
|
5
|
+
export declare function attribute(value: Value, name: string, budget: Budget, mutate: (value: Value) => void): Callable;
|
|
6
|
+
export declare function percentFormat(format: string, value: Value, budget: Budget): string;
|