@molecule/api-ai-tools 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -1
- package/dist/command-position.d.ts +37 -0
- package/dist/command-position.d.ts.map +1 -1
- package/dist/command-position.js +164 -5
- package/dist/cut-run.d.ts.map +1 -1
- package/dist/cut-run.js +10 -6
- package/dist/utilities.d.ts +9 -0
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +115 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-10-
|
|
6
|
+
Generated: 2026-10-21T08:55:11.822Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-tools
|
|
@@ -105,6 +105,28 @@ interface CommandSegment {
|
|
|
105
105
|
}
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
#### `ExecutedCommand`
|
|
109
|
+
|
|
110
|
+
One command a shell command actually executes, wherever the shell runs it.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface ExecutedCommand {
|
|
114
|
+
/**
|
|
115
|
+
* The word in command position, its directory removed (`/usr/bin/printenv` → `printenv`) — or
|
|
116
|
+
* the launcher itself when it runs alone and nothing follows it (`x | env` → `env`).
|
|
117
|
+
*/
|
|
118
|
+
program: string
|
|
119
|
+
/**
|
|
120
|
+
* Its arguments, as written with quotes kept — the statement's own words AFTER the program,
|
|
121
|
+
* including an input redirect's path (`< /proc/self/environ`), so a reader of secret files sees
|
|
122
|
+
* the file it reads.
|
|
123
|
+
*/
|
|
124
|
+
args: readonly string[]
|
|
125
|
+
/** The program and its arguments as one line, what a pattern anchored at the program matches. */
|
|
126
|
+
text: string
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
108
130
|
#### `LocatedCommandSegment`
|
|
109
131
|
|
|
110
132
|
One statement of a shell command, with where it sits and the variables it sets for itself.
|
|
@@ -1670,6 +1692,32 @@ function commandSegments(command: string): CommandSegment[]
|
|
|
1670
1692
|
|
|
1671
1693
|
**Returns:** One entry per statement or pipeline stage that runs something, in order.
|
|
1672
1694
|
|
|
1695
|
+
#### `executedCommands(command)`
|
|
1696
|
+
|
|
1697
|
+
Every command a shell command actually executes, at any depth — the statements themselves, the
|
|
1698
|
+
body of a `sh -c '<command>'`, and the body of every command substitution (`$(…)`, backticks).
|
|
1699
|
+
|
|
1700
|
+
This is the reading a policy that asks "does this command run X" needs, and it is deliberately
|
|
1701
|
+
not a text match. The command-position parser already knows what runs and what is only quoted
|
|
1702
|
+
data ({@link commandSegments}), so a pattern never reads a `|` inside a quoted grep alternation
|
|
1703
|
+
as a pipeline: `grep -E "USER CALLS|ENV|BUTTON" app.log` prints log lines, and the `ENV` in
|
|
1704
|
+
its pattern started nothing (X0 xr-molecule-flash-m331 blocked exactly that call as an
|
|
1705
|
+
environment dump). What the shell DOES run stays visible through the same walk: a bare
|
|
1706
|
+
launcher (`ls | env`), a shell string (`bash -c 'env'`), a substitution
|
|
1707
|
+
(`echo "$(printenv)"`) and a nested one (`sh -c 'x; env'`) are all commands here.
|
|
1708
|
+
|
|
1709
|
+
`commandSegments` answers what a pipeline stage runs for a caller matching a runner; this
|
|
1710
|
+
answers with the launcher left standing when it runs alone, since that is what the shell
|
|
1711
|
+
executes then.
|
|
1712
|
+
|
|
1713
|
+
```typescript
|
|
1714
|
+
function executedCommands(command: string): ExecutedCommand[]
|
|
1715
|
+
```
|
|
1716
|
+
|
|
1717
|
+
- `command` — The shell command.
|
|
1718
|
+
|
|
1719
|
+
**Returns:** Each command the shell executes, in the order the shell reaches them.
|
|
1720
|
+
|
|
1673
1721
|
#### `locatedCommandSegments(command)`
|
|
1674
1722
|
|
|
1675
1723
|
Every statement of a command, with its own assignments and where it sits — assignment-only
|
|
@@ -3323,6 +3371,15 @@ function suiteRunPriorityLaunch(command: string, launch: string): { launch: stri
|
|
|
3323
3371
|
|
|
3324
3372
|
Check if a command is blocked for security reasons. Returns error message or null if allowed.
|
|
3325
3373
|
|
|
3374
|
+
The first check reads the commands the shell actually RUNS — the statements, a `sh -c`
|
|
3375
|
+
string's body, and every command substitution ({@link executedCommands}) — so a `|` inside a
|
|
3376
|
+
quoted grep alternation is data, not a pipeline: `grep -E "USER CALLS|ENV|BUTTON|passed|failed"
|
|
3377
|
+
app.log` prints log lines, and the `ENV` in its pattern started nothing (X0
|
|
3378
|
+
xr-molecule-flash-m331 blocked exactly that call as an environment dump, twice). What the
|
|
3379
|
+
shell DOES run stays visible through the same walk: `ls | env`, `bash -c 'env'`,
|
|
3380
|
+
`echo "$(printenv)"` and a nested `sh -c 'x; env'` are all commands, and so is `env` itself
|
|
3381
|
+
when nothing follows it.
|
|
3382
|
+
|
|
3326
3383
|
```typescript
|
|
3327
3384
|
function checkBlockedCommand(command: string): string | null
|
|
3328
3385
|
```
|
|
@@ -74,6 +74,43 @@ export declare function endsInBackground(command: string): boolean;
|
|
|
74
74
|
* @returns One entry per statement or pipeline stage that runs something, in order.
|
|
75
75
|
*/
|
|
76
76
|
export declare function commandSegments(command: string): CommandSegment[];
|
|
77
|
+
/** One command a shell command actually executes, wherever the shell runs it. */
|
|
78
|
+
export interface ExecutedCommand {
|
|
79
|
+
/**
|
|
80
|
+
* The word in command position, its directory removed (`/usr/bin/printenv` → `printenv`) — or
|
|
81
|
+
* the launcher itself when it runs alone and nothing follows it (`x | env` → `env`).
|
|
82
|
+
*/
|
|
83
|
+
program: string;
|
|
84
|
+
/**
|
|
85
|
+
* Its arguments, as written with quotes kept — the statement's own words AFTER the program,
|
|
86
|
+
* including an input redirect's path (`< /proc/self/environ`), so a reader of secret files sees
|
|
87
|
+
* the file it reads.
|
|
88
|
+
*/
|
|
89
|
+
args: readonly string[];
|
|
90
|
+
/** The program and its arguments as one line, what a pattern anchored at the program matches. */
|
|
91
|
+
text: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Every command a shell command actually executes, at any depth — the statements themselves, the
|
|
95
|
+
* body of a `sh -c '<command>'`, and the body of every command substitution (`$(…)`, backticks).
|
|
96
|
+
*
|
|
97
|
+
* This is the reading a policy that asks "does this command run X" needs, and it is deliberately
|
|
98
|
+
* not a text match. The command-position parser already knows what runs and what is only quoted
|
|
99
|
+
* data ({@link commandSegments}), so a pattern never reads a `|` inside a quoted grep alternation
|
|
100
|
+
* as a pipeline: `grep -E "USER CALLS|ENV|BUTTON" app.log` prints log lines, and the `ENV` in
|
|
101
|
+
* its pattern started nothing (X0 xr-molecule-flash-m331 blocked exactly that call as an
|
|
102
|
+
* environment dump). What the shell DOES run stays visible through the same walk: a bare
|
|
103
|
+
* launcher (`ls | env`), a shell string (`bash -c 'env'`), a substitution
|
|
104
|
+
* (`echo "$(printenv)"`) and a nested one (`sh -c 'x; env'`) are all commands here.
|
|
105
|
+
*
|
|
106
|
+
* `commandSegments` answers what a pipeline stage runs for a caller matching a runner; this
|
|
107
|
+
* answers with the launcher left standing when it runs alone, since that is what the shell
|
|
108
|
+
* executes then.
|
|
109
|
+
*
|
|
110
|
+
* @param command - The shell command.
|
|
111
|
+
* @returns Each command the shell executes, in the order the shell reaches them.
|
|
112
|
+
*/
|
|
113
|
+
export declare function executedCommands(command: string): ExecutedCommand[];
|
|
77
114
|
/**
|
|
78
115
|
* One statement of a shell command, with where it sits and the variables it sets for itself.
|
|
79
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-position.d.ts","sourceRoot":"","sources":["../src/command-position.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,uFAAuF;AACvF,MAAM,WAAW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,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAK/E"}
|
package/dist/command-position.js
CHANGED
|
@@ -694,14 +694,23 @@ function blankHeredocBodies(command) {
|
|
|
694
694
|
* `molecule-dev/api/src/ai/supplied-tree-guard.ts` — so a script that does not classify records
|
|
695
695
|
* no runner, and every run of it reads as nothing).
|
|
696
696
|
*
|
|
697
|
+
* The walk also RECORDS the command substitutions it enters (`$(…)` and backticks), because the
|
|
698
|
+
* shell runs those too: a reader that only saw the outer statements could not tell that
|
|
699
|
+
* `echo "$(printenv)"` prints the environment ({@link executedCommands}).
|
|
700
|
+
*
|
|
697
701
|
* @param command - The shell command.
|
|
698
702
|
* @returns Each statement's text, the offset its first character sits at, and the separator that
|
|
699
703
|
* ended it (`|`, `&&`, `;`, a newline, … — '' after the last one), in order, with empty ones
|
|
700
|
-
* dropped.
|
|
704
|
+
* dropped — and the bodies of the command substitutions this level enters, as offsets.
|
|
701
705
|
*/
|
|
702
|
-
function
|
|
706
|
+
function splitCommand(command) {
|
|
703
707
|
const source = blankHeredocBodies(command);
|
|
704
708
|
const parts = [];
|
|
709
|
+
const substitutions = [];
|
|
710
|
+
/** Where each open `$(` body starts; -1 for a bare `(` opened inside one. */
|
|
711
|
+
const subOpens = [];
|
|
712
|
+
/** Where each open backtick body starts. */
|
|
713
|
+
const tickOpens = [];
|
|
705
714
|
let buffer = '';
|
|
706
715
|
/** The offset in the command of the current buffer's first character. */
|
|
707
716
|
let bufferStart = 0;
|
|
@@ -739,6 +748,32 @@ function splitSegments(command) {
|
|
|
739
748
|
stack.pop();
|
|
740
749
|
continue;
|
|
741
750
|
}
|
|
751
|
+
// Backticks open a command substitution wherever one runs — outside quotes, inside double
|
|
752
|
+
// quotes, and inside another substitution or a parameter expansion — but never inside single
|
|
753
|
+
// quotes (handled above). Its body is a command of its own: nothing in it splits THIS command,
|
|
754
|
+
// and a `'` or `"` in it is the nested command's, not this one's.
|
|
755
|
+
if (top !== 'tick' && char === '`') {
|
|
756
|
+
stack.push('tick');
|
|
757
|
+
tickOpens.push(i + 1);
|
|
758
|
+
put(char, -1);
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if (top === 'tick') {
|
|
762
|
+
if (char === '\\' && next !== undefined) {
|
|
763
|
+
// An escaped character is literal: `\`` does not close the substitution.
|
|
764
|
+
put(char + next, -1);
|
|
765
|
+
i += 1;
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (char === '`') {
|
|
769
|
+
stack.pop();
|
|
770
|
+
const opened = tickOpens.pop();
|
|
771
|
+
if (opened !== undefined)
|
|
772
|
+
substitutions.push({ start: opened, end: i });
|
|
773
|
+
}
|
|
774
|
+
put(char, -1);
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
742
777
|
// Comments are shell syntax only in a command context, including an unquoted `$(`.
|
|
743
778
|
// Blank their bytes so quotes/operators cannot affect this walk, while every later
|
|
744
779
|
// position and depth index stays aligned with the original command. Keep the newline.
|
|
@@ -753,6 +788,7 @@ function splitSegments(command) {
|
|
|
753
788
|
// inside single quotes (handled above). The `(` is consumed here so the depth is counted once.
|
|
754
789
|
if (char === '$' && next === '(') {
|
|
755
790
|
stack.push('sub');
|
|
791
|
+
subOpens.push(i + 2);
|
|
756
792
|
put('$(', -1);
|
|
757
793
|
i += 1;
|
|
758
794
|
continue;
|
|
@@ -802,10 +838,16 @@ function splitSegments(command) {
|
|
|
802
838
|
// Inside a substitution or a subshell of one: its own parentheses nest, its `|`/`;`/`&&`
|
|
803
839
|
// belong to the nested command, and its newlines are that command's too.
|
|
804
840
|
if (top === 'sub') {
|
|
805
|
-
if (char === '(')
|
|
841
|
+
if (char === '(') {
|
|
806
842
|
stack.push('sub');
|
|
807
|
-
|
|
843
|
+
subOpens.push(-1);
|
|
844
|
+
}
|
|
845
|
+
else if (char === ')') {
|
|
808
846
|
stack.pop();
|
|
847
|
+
const opened = subOpens.pop();
|
|
848
|
+
if (opened !== undefined && opened >= 0)
|
|
849
|
+
substitutions.push({ start: opened, end: i });
|
|
850
|
+
}
|
|
809
851
|
put(char, -1);
|
|
810
852
|
continue;
|
|
811
853
|
}
|
|
@@ -861,7 +903,16 @@ function splitSegments(command) {
|
|
|
861
903
|
});
|
|
862
904
|
lastAfter = part.after;
|
|
863
905
|
}
|
|
864
|
-
return out;
|
|
906
|
+
return { parts: out, substitutions };
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* A command's statements and pipeline stages — {@link splitCommand}'s parts on their own.
|
|
910
|
+
*
|
|
911
|
+
* @param command - The shell command.
|
|
912
|
+
* @returns Each statement, in order, with empty ones dropped.
|
|
913
|
+
*/
|
|
914
|
+
function splitSegments(command) {
|
|
915
|
+
return splitCommand(command).parts;
|
|
865
916
|
}
|
|
866
917
|
/**
|
|
867
918
|
* Whether the outer shell's final statement starts a background job.
|
|
@@ -983,6 +1034,114 @@ function leadingAssignments(text) {
|
|
|
983
1034
|
export function commandSegments(command) {
|
|
984
1035
|
return locatedSegmentsOf(command, 0).flatMap((located) => located.segment === null ? [] : [located.segment]);
|
|
985
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* A statement's words with its redirections taken out, so the walk that finds the program does
|
|
1039
|
+
* not read a redirect's target as the program: `env > out.txt` RUNS `env`, and `cat > f` runs
|
|
1040
|
+
* `cat` with no file argument. Each word kept carries its index in `words`, because a caller
|
|
1041
|
+
* reading the statement's ARGUMENTS wants it as written — an input redirect's path is one.
|
|
1042
|
+
*
|
|
1043
|
+
* @param words - One statement's words, quotes kept.
|
|
1044
|
+
* @returns The words that are not redirections, and each one's index in `words`.
|
|
1045
|
+
*/
|
|
1046
|
+
function withoutRedirects(words) {
|
|
1047
|
+
const kept = [];
|
|
1048
|
+
const index = [];
|
|
1049
|
+
for (let i = 0; i < words.length; i += 1) {
|
|
1050
|
+
const word = words[i] ?? '';
|
|
1051
|
+
// An operator written on its own owns the word after it (`> out.txt`, `< /proc/self/environ`).
|
|
1052
|
+
if (REDIRECT_OPERATOR.test(word)) {
|
|
1053
|
+
i += 1;
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
// An operator with its target attached (`2>&1`, `>out.txt`, `&>log`) is one word.
|
|
1057
|
+
if (REDIRECT_WORD.test(word))
|
|
1058
|
+
continue;
|
|
1059
|
+
kept.push(word);
|
|
1060
|
+
index.push(i);
|
|
1061
|
+
}
|
|
1062
|
+
return { words: kept, index };
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* The index of the last launcher a statement names (`x | env`, `sudo nice`), or null when it
|
|
1066
|
+
* names none.
|
|
1067
|
+
*
|
|
1068
|
+
* A statement that only NAMES a launcher runs that launcher: `x | env` pipes x's output into
|
|
1069
|
+
* `env`, which prints the environment, and the walk that reports what a command runs has to say
|
|
1070
|
+
* so ({@link executedCommands}).
|
|
1071
|
+
*
|
|
1072
|
+
* @param words - The statement's words, redirections already taken out.
|
|
1073
|
+
* @returns The launcher's index, or null.
|
|
1074
|
+
*/
|
|
1075
|
+
function lastLauncherIndex(words) {
|
|
1076
|
+
for (let i = words.length - 1; i >= 0; i -= 1) {
|
|
1077
|
+
if (LAUNCHERS.has(programName(words[i] ?? '')))
|
|
1078
|
+
return i;
|
|
1079
|
+
}
|
|
1080
|
+
return null;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* {@link executedCommands}'s recursion: a statement's own `sh -c '<command>'`, and every command
|
|
1084
|
+
* substitution it carries, is a command of its own.
|
|
1085
|
+
*
|
|
1086
|
+
* @param command - The shell command, or one nested command string.
|
|
1087
|
+
* @param depth - How many nested command strings this one already sits inside.
|
|
1088
|
+
* @returns Each command the shell executes, in order.
|
|
1089
|
+
*/
|
|
1090
|
+
function executedCommandsOf(command, depth) {
|
|
1091
|
+
if (typeof command !== 'string' || depth > MAX_NESTING)
|
|
1092
|
+
return [];
|
|
1093
|
+
const out = [];
|
|
1094
|
+
const { parts, substitutions } = splitCommand(command);
|
|
1095
|
+
for (const part of parts) {
|
|
1096
|
+
const words = segmentWords(part.text);
|
|
1097
|
+
const placed = withoutRedirects(words);
|
|
1098
|
+
const start = commandStart(placed.words);
|
|
1099
|
+
// A shell's `-c '<command>'` is the command: what the shell itself does is run it.
|
|
1100
|
+
if (start.nested !== null) {
|
|
1101
|
+
out.push(...executedCommandsOf(start.nested, depth + 1));
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
const at = placed.words[start.at] === undefined ? lastLauncherIndex(placed.words) : start.at;
|
|
1105
|
+
if (at === null)
|
|
1106
|
+
continue;
|
|
1107
|
+
const program = start.program ?? programName(placed.words[at] ?? '');
|
|
1108
|
+
if (!program)
|
|
1109
|
+
continue;
|
|
1110
|
+
// Arguments from the statement as written, from the word after the program: `cat < /proc/…`
|
|
1111
|
+
// reads that file, and a reader of secret files has to see it.
|
|
1112
|
+
const args = words.slice((placed.index[at] ?? 0) + 1);
|
|
1113
|
+
out.push({ program, args, text: [program, ...args].join(' ') });
|
|
1114
|
+
}
|
|
1115
|
+
for (const substitution of substitutions) {
|
|
1116
|
+
out.push(...executedCommandsOf(command.slice(substitution.start, substitution.end), depth + 1));
|
|
1117
|
+
}
|
|
1118
|
+
return out;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Every command a shell command actually executes, at any depth — the statements themselves, the
|
|
1122
|
+
* body of a `sh -c '<command>'`, and the body of every command substitution (`$(…)`, backticks).
|
|
1123
|
+
*
|
|
1124
|
+
* This is the reading a policy that asks "does this command run X" needs, and it is deliberately
|
|
1125
|
+
* not a text match. The command-position parser already knows what runs and what is only quoted
|
|
1126
|
+
* data ({@link commandSegments}), so a pattern never reads a `|` inside a quoted grep alternation
|
|
1127
|
+
* as a pipeline: `grep -E "USER CALLS|ENV|BUTTON" app.log` prints log lines, and the `ENV` in
|
|
1128
|
+
* its pattern started nothing (X0 xr-molecule-flash-m331 blocked exactly that call as an
|
|
1129
|
+
* environment dump). What the shell DOES run stays visible through the same walk: a bare
|
|
1130
|
+
* launcher (`ls | env`), a shell string (`bash -c 'env'`), a substitution
|
|
1131
|
+
* (`echo "$(printenv)"`) and a nested one (`sh -c 'x; env'`) are all commands here.
|
|
1132
|
+
*
|
|
1133
|
+
* `commandSegments` answers what a pipeline stage runs for a caller matching a runner; this
|
|
1134
|
+
* answers with the launcher left standing when it runs alone, since that is what the shell
|
|
1135
|
+
* executes then.
|
|
1136
|
+
*
|
|
1137
|
+
* @param command - The shell command.
|
|
1138
|
+
* @returns Each command the shell executes, in the order the shell reaches them.
|
|
1139
|
+
*/
|
|
1140
|
+
export function executedCommands(command) {
|
|
1141
|
+
if (typeof command !== 'string' || !command.trim())
|
|
1142
|
+
return [];
|
|
1143
|
+
return executedCommandsOf(command, 0);
|
|
1144
|
+
}
|
|
986
1145
|
/**
|
|
987
1146
|
* Where a statement's word sits in its own raw text, as {@link segmentWords} counts the words.
|
|
988
1147
|
*
|
package/dist/cut-run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cut-run.d.ts","sourceRoot":"","sources":["../src/cut-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH;;;GAGG;AACH,eAAO,MAAM,aAAa,kBAAkB,CAAA;AAE5C,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,OAAO,aAAa,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAGhE;AAiBD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,wEAAwE;IACxE,QAAQ,EAAE,OAAO,CAAA;CAClB;AAkDD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,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MAAM,GAAG,IAAI,CAAA;IAClB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,qCAAqC;IACrC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;IACvB,yEAAyE;IACzE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAsDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,SAAI,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAgGf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAmB1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyClD"}
|
package/dist/cut-run.js
CHANGED
|
@@ -345,12 +345,16 @@ export function commandCutRun(command, result, elapsedMs, budgetSeconds = 0, raw
|
|
|
345
345
|
inlineScript,
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
|
-
//
|
|
349
|
-
// bound above fired: the process was stopped from
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
|
|
348
|
+
// A runner's summary that does not account for the total it announced, in a command that
|
|
349
|
+
// actually RUNS that runner, and neither bound above fired: the process was stopped from
|
|
350
|
+
// outside the run. The command must run the runner — a reader of a LIVE run's log prints the
|
|
351
|
+
// same announcement and partial tally as text it copies, and reporting that as a stopped run
|
|
352
|
+
// told the executor a suite it had only grepped had been killed (X0 xr-molecule-flash-m345,
|
|
353
|
+
// +50:00: `grep -B2 -A12 … /tmp/mol-bg-….log | head -40` came back `stoppedBy: process-stop`
|
|
354
|
+
// after 1 s). A run that used the whole budget is the backend's deadline (which sits just past
|
|
355
|
+
// it); anything else is a stop this tool does not own. Either way the summary counts are all
|
|
356
|
+
// that ran, and a pipeline's 0 is not the run's code — the run never reached its own verdict.
|
|
357
|
+
if (suite && summary !== null && summary.announced !== null) {
|
|
354
358
|
const usedBudget = budgetSeconds > 0 && elapsedMs >= atBoundMs(budgetSeconds);
|
|
355
359
|
return {
|
|
356
360
|
seconds: usedBudget ? budgetSeconds : Math.max(1, Math.round(elapsedMs / 1000)),
|
package/dist/utilities.d.ts
CHANGED
|
@@ -424,6 +424,15 @@ export declare function suiteRunPriorityLaunch(command: string, launch: string):
|
|
|
424
424
|
/**
|
|
425
425
|
* Check if a command is blocked for security reasons. Returns error message or null if allowed.
|
|
426
426
|
*
|
|
427
|
+
* The first check reads the commands the shell actually RUNS — the statements, a `sh -c`
|
|
428
|
+
* string's body, and every command substitution ({@link executedCommands}) — so a `|` inside a
|
|
429
|
+
* quoted grep alternation is data, not a pipeline: `grep -E "USER CALLS|ENV|BUTTON|passed|failed"
|
|
430
|
+
* app.log` prints log lines, and the `ENV` in its pattern started nothing (X0
|
|
431
|
+
* xr-molecule-flash-m331 blocked exactly that call as an environment dump, twice). What the
|
|
432
|
+
* shell DOES run stays visible through the same walk: `ls | env`, `bash -c 'env'`,
|
|
433
|
+
* `echo "$(printenv)"` and a nested `sh -c 'x; env'` are all commands, and so is `env` itself
|
|
434
|
+
* when nothing follows it.
|
|
435
|
+
*
|
|
427
436
|
* @param command - Shell command string proposed for execution.
|
|
428
437
|
* @returns A human-readable block reason, or `null` when the command is allowed.
|
|
429
438
|
*/
|
package/dist/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAsB,KAAK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AM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACjC,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,SAAS,aAAa,EAAE,CAAA;KAAE,CAAA;IACvE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,GACA,MAAM,CAuIR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAsCf;AAED,qEAAqE;AACrE,eAAO,MAAM,eAAe,QAA0C,CAAA;AAEtE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB7D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,MAAM,GAAG,IAAI,CAKhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgBvC"}
|
package/dist/utilities.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { posix } from 'path';
|
|
8
|
-
import { commandSegments, locatedCommandSegments, statementArgumentEnd, withoutTimeoutWrapper, } from './command-position.js';
|
|
8
|
+
import { commandSegments, executedCommands, locatedCommandSegments, statementArgumentEnd, withoutTimeoutWrapper, } from './command-position.js';
|
|
9
9
|
import { classifyRunFailure } from './failure-kind.js';
|
|
10
10
|
import { commandRunsNoTests } from './no-test-run.js';
|
|
11
11
|
import { isDiagnosisRun, scopedRerunCommand, suiteCommandTarget, suiteRunInTheWay, withoutHeredocs, withSuiteConfig, } from './suite-overlap.js';
|
|
@@ -1301,30 +1301,127 @@ export function suiteRunPriorityLaunch(command, launch) {
|
|
|
1301
1301
|
};
|
|
1302
1302
|
}
|
|
1303
1303
|
// ── Command blocking ──────────────────────────────────────────────────────────
|
|
1304
|
+
/** A word with one layer of matching shell quotes removed (`"/proc/self/environ"` → `/proc/self/environ`). */
|
|
1305
|
+
function shellWord(word) {
|
|
1306
|
+
return word.replace(/^(['"])(.*)\1$/, '$2');
|
|
1307
|
+
}
|
|
1308
|
+
/** `/proc/<pid>/environ` and `/proc/self/environ` — a process's environment, as the kernel exposes it. */
|
|
1309
|
+
const PROC_ENVIRON = /^\/proc\/(?:\d+|self)\/environ(?:\/|$)/;
|
|
1310
|
+
/** Anything under `/proc`: a process's environment is one of the files there. */
|
|
1311
|
+
const PROC_PATH = /^\/proc(?:\/|$)/;
|
|
1312
|
+
/** The molecule platform's secrets dir — `/etc/mol/env` carries the vault + platform secrets. */
|
|
1313
|
+
const MOL_SECRETS = /^\/etc\/mol(?:\/|$)/;
|
|
1314
|
+
/**
|
|
1315
|
+
* Whether one executed command reads a file that would print a process's environment or the
|
|
1316
|
+
* platform's secrets.
|
|
1317
|
+
*
|
|
1318
|
+
* This is asked of the commands the shell RUNS ({@link executedCommands}), never of the command
|
|
1319
|
+
* text: a file path quoted inside a grep pattern (`grep -E "ENV|/etc/mol" src`) is data a
|
|
1320
|
+
* comparison reads, not a file this command opens. The shapes below are the ones that print:
|
|
1321
|
+
* `cat` and its siblings of a `/proc/<pid>/environ`, a redirect's path handed to a reader
|
|
1322
|
+
* (`xxd < /proc/self/environ`), and reads of `/etc/mol`, which is an env-dump by another door.
|
|
1323
|
+
*
|
|
1324
|
+
* @param program - The command's program, directory removed.
|
|
1325
|
+
* @param args - Its arguments, as written.
|
|
1326
|
+
* @returns True when the command reads one of those files.
|
|
1327
|
+
*/
|
|
1328
|
+
function readsSecretFile(program, args) {
|
|
1329
|
+
const words = args.map(shellWord);
|
|
1330
|
+
const first = words[0] ?? '';
|
|
1331
|
+
switch (program) {
|
|
1332
|
+
case 'cat':
|
|
1333
|
+
return words.some((word) => /^\/etc\/environment(?:\/|\.|$)/.test(word) ||
|
|
1334
|
+
word.startsWith('/root/.bashrc') ||
|
|
1335
|
+
PROC_ENVIRON.test(word) ||
|
|
1336
|
+
MOL_SECRETS.test(word));
|
|
1337
|
+
case 'sed':
|
|
1338
|
+
case 'awk':
|
|
1339
|
+
case 'cp':
|
|
1340
|
+
return words.some((word) => PROC_ENVIRON.test(word) || MOL_SECRETS.test(word));
|
|
1341
|
+
case 'xargs':
|
|
1342
|
+
return words.some((word) => PROC_ENVIRON.test(word));
|
|
1343
|
+
case 'dd':
|
|
1344
|
+
// `dd if=/proc/1/environ` carries the path inside its own argument.
|
|
1345
|
+
return words.some((word) => /\/proc(?:\/|$)/.test(word) || MOL_SECRETS.test(word));
|
|
1346
|
+
case 'base64':
|
|
1347
|
+
case 'head':
|
|
1348
|
+
case 'less':
|
|
1349
|
+
case 'od':
|
|
1350
|
+
case 'strings':
|
|
1351
|
+
case 'tail':
|
|
1352
|
+
case 'xxd':
|
|
1353
|
+
return PROC_PATH.test(first) || words.some((word) => MOL_SECRETS.test(word));
|
|
1354
|
+
default:
|
|
1355
|
+
return false;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1304
1358
|
/**
|
|
1305
|
-
*
|
|
1306
|
-
* Also covers reads of `/etc/mol/…` (the molecule platform's secrets dir —
|
|
1307
|
-
* `/etc/mol/env` carries the vault + platform secrets inside a sandbox),
|
|
1308
|
-
* which is an env-dump by another door.
|
|
1359
|
+
* Whether one executed command prints the environment instead of running something in it.
|
|
1309
1360
|
*
|
|
1310
|
-
* `env` counts only when it DUMPS:
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1361
|
+
* `env` counts only when it DUMPS: {@link executedCommands} reports it as the program only when
|
|
1362
|
+
* nothing follows it, because `env -u KEY cmd`, `env KEY=value cmd` and `env -i cmd` run `cmd`
|
|
1363
|
+
* with a changed environment and print nothing — an executor reaches for them to prove a keyless
|
|
1364
|
+
* build still succeeds, and blocking those sent it looking for workarounds (X0 rehearsal 14).
|
|
1365
|
+
* `export` / `set` / `declare` print every variable they carry when given nothing to set.
|
|
1366
|
+
*
|
|
1367
|
+
* @param program - The command's program, directory removed.
|
|
1368
|
+
* @param args - Its arguments, as written.
|
|
1369
|
+
* @returns True when the command prints the environment.
|
|
1316
1370
|
*/
|
|
1317
|
-
|
|
1318
|
-
const
|
|
1371
|
+
function dumpsEnvironment(program, args) {
|
|
1372
|
+
const words = args.map(shellWord);
|
|
1373
|
+
if (program === 'env')
|
|
1374
|
+
return true;
|
|
1375
|
+
if (program === 'printenv')
|
|
1376
|
+
return true;
|
|
1377
|
+
if (program === 'export')
|
|
1378
|
+
return words.every((word) => word === '-p' || word === '--print');
|
|
1379
|
+
if (program === 'set')
|
|
1380
|
+
return words.length === 0;
|
|
1381
|
+
if (program === 'declare')
|
|
1382
|
+
return (words.length === 0 ||
|
|
1383
|
+
(words.every((word) => word.startsWith('-')) &&
|
|
1384
|
+
words.some((word) => /^-[A-Za-z]*[px]/.test(word))));
|
|
1385
|
+
return false;
|
|
1386
|
+
}
|
|
1387
|
+
/** Interpreters an env-dumping one-liner is written in (python, node, ruby, perl). */
|
|
1388
|
+
const INTERPRETER_PROGRAMS = new Set([
|
|
1389
|
+
'node',
|
|
1390
|
+
'perl',
|
|
1391
|
+
'python',
|
|
1392
|
+
'python2',
|
|
1393
|
+
'python3',
|
|
1394
|
+
'ruby',
|
|
1395
|
+
]);
|
|
1396
|
+
/** An inline program (`-e` / `-c`) that reads the environment and prints it. */
|
|
1397
|
+
const INTERPRETER_ENV_DUMP = /(?:^|\s)(?:-e|-c)\s[^\n]*(?:os\.environ|process\.env|ENV\[|%ENV|ENVIRON)/i;
|
|
1398
|
+
/**
|
|
1399
|
+
* Whether one executed command dumps the environment from an inline interpreter program
|
|
1400
|
+
* (`node -e 'console.log(process.env)'`).
|
|
1401
|
+
*
|
|
1402
|
+
* @param program - The command's program, directory removed.
|
|
1403
|
+
* @param text - The program and its arguments as one line.
|
|
1404
|
+
* @returns True when the inline program reads the environment.
|
|
1405
|
+
*/
|
|
1406
|
+
function dumpsEnvironmentFromInterpreter(program, text) {
|
|
1407
|
+
return INTERPRETER_PROGRAMS.has(program) && INTERPRETER_ENV_DUMP.test(text);
|
|
1408
|
+
}
|
|
1319
1409
|
/** Block shell redirects from /proc environ. */
|
|
1320
1410
|
const BLOCKED_PROC_REDIRECT = /(?:<\s*\/proc\/(?:\d+|self)\/environ)/i;
|
|
1321
1411
|
/** Block shell redirects from the molecule platform secrets dir (`/etc/mol`). */
|
|
1322
1412
|
const BLOCKED_MOL_REDIRECT = /(?:<\s*\/etc\/mol)/i;
|
|
1323
|
-
/** Interpreter-based env dumping (python, node, ruby, perl). */
|
|
1324
|
-
const BLOCKED_INTERPRETER_ENV = /(?:python[23]?|node|ruby|perl)\s+(?:-e|-c)\s+[^\n]*(?:os\.environ|process\.env|ENV\[|%ENV|ENVIRON)/i;
|
|
1325
1413
|
/**
|
|
1326
1414
|
* Check if a command is blocked for security reasons. Returns error message or null if allowed.
|
|
1327
1415
|
*
|
|
1416
|
+
* The first check reads the commands the shell actually RUNS — the statements, a `sh -c`
|
|
1417
|
+
* string's body, and every command substitution ({@link executedCommands}) — so a `|` inside a
|
|
1418
|
+
* quoted grep alternation is data, not a pipeline: `grep -E "USER CALLS|ENV|BUTTON|passed|failed"
|
|
1419
|
+
* app.log` prints log lines, and the `ENV` in its pattern started nothing (X0
|
|
1420
|
+
* xr-molecule-flash-m331 blocked exactly that call as an environment dump, twice). What the
|
|
1421
|
+
* shell DOES run stays visible through the same walk: `ls | env`, `bash -c 'env'`,
|
|
1422
|
+
* `echo "$(printenv)"` and a nested `sh -c 'x; env'` are all commands, and so is `env` itself
|
|
1423
|
+
* when nothing follows it.
|
|
1424
|
+
*
|
|
1328
1425
|
* @param command - Shell command string proposed for execution.
|
|
1329
1426
|
* @returns A human-readable block reason, or `null` when the command is allowed.
|
|
1330
1427
|
*/
|
|
@@ -1341,13 +1438,14 @@ export function checkBlockedCommand(command) {
|
|
|
1341
1438
|
"check the project's provisioned env file to see WHICH services exist. Printing them only " +
|
|
1342
1439
|
'leaks secrets into the transcript. To check whether ONE variable is set without printing ' +
|
|
1343
1440
|
'it: `test -n "$NAME" && echo set || echo missing`.';
|
|
1344
|
-
|
|
1441
|
+
const statements = executedCommands(command);
|
|
1442
|
+
if (statements.some((s) => dumpsEnvironment(s.program, s.args) || readsSecretFile(s.program, s.args)))
|
|
1345
1443
|
return `Command blocked: dumping environment variables is not allowed.${envDumpSteer}`;
|
|
1346
1444
|
if (BLOCKED_PROC_REDIRECT.test(command))
|
|
1347
1445
|
return 'Command blocked: /proc/environ access is not allowed.' + envDumpSteer;
|
|
1348
1446
|
if (BLOCKED_MOL_REDIRECT.test(command))
|
|
1349
1447
|
return 'Command blocked: /etc/mol (platform secrets) access is not allowed.' + envDumpSteer;
|
|
1350
|
-
if (
|
|
1448
|
+
if (statements.some((s) => dumpsEnvironmentFromInterpreter(s.program, s.text)))
|
|
1351
1449
|
return `Command blocked: dumping the environment from an interpreter is not allowed.${envDumpSteer}`;
|
|
1352
1450
|
return null;
|
|
1353
1451
|
}
|