@stratusagent/permissions 0.11.8 → 0.11.9
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/dist/commands.d.ts +61 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +441 -12
- package/dist/commands.js.map +1 -1
- package/dist/index.d.ts +17 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -16
- package/dist/index.js.map +1 -1
- package/dist/origins.d.ts +17 -4
- package/dist/origins.d.ts.map +1 -1
- package/dist/origins.js +20 -8
- package/dist/origins.js.map +1 -1
- package/dist/whitelist.d.ts +2 -0
- package/dist/whitelist.d.ts.map +1 -1
- package/dist/whitelist.js +6 -2
- package/dist/whitelist.js.map +1 -1
- package/dist/workspace.d.ts +27 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +750 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +2 -2
package/dist/commands.d.ts
CHANGED
|
@@ -55,6 +55,28 @@ export interface CommandScope {
|
|
|
55
55
|
* ordinary push.
|
|
56
56
|
*/
|
|
57
57
|
denyRefspecForms?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* At most this many positional arguments, where `listOnly` allows none.
|
|
60
|
+
* `grep` reads its pattern from the first positional and a *file* from
|
|
61
|
+
* every one after it, so a `grep` that may only filter what is piped to
|
|
62
|
+
* it is a `grep` with one.
|
|
63
|
+
*/
|
|
64
|
+
maxPositionals?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Flags whose value is the next token (`-n 20`), so that token is read
|
|
67
|
+
* as the flag's value rather than counted as a positional. Matched as
|
|
68
|
+
* the token is spelled, whole: `-n` takes a value, a bundle like `-vn`
|
|
69
|
+
* does not, and its next token counts as a positional.
|
|
70
|
+
*/
|
|
71
|
+
flagsWithValue?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* Refuse any token the shell would expand: an unquoted glob, brace,
|
|
74
|
+
* `~`, `$`, or backslash. A filter limited to one positional is only
|
|
75
|
+
* limited to one if the shell agrees — unquoted `grep *` is `grep`
|
|
76
|
+
* handed every file in the directory, the first as its pattern and the
|
|
77
|
+
* rest to read.
|
|
78
|
+
*/
|
|
79
|
+
literal?: boolean;
|
|
58
80
|
}
|
|
59
81
|
/**
|
|
60
82
|
* The commands that run unattended out of the box.
|
|
@@ -73,13 +95,29 @@ export interface CommandScope {
|
|
|
73
95
|
* error text, which the shell tool returns. A command that can be handed a
|
|
74
96
|
* path is a file reader wearing another name.
|
|
75
97
|
*/
|
|
98
|
+
/**
|
|
99
|
+
* An `allowedFlags` entry admitting a flag that is only a number, the way
|
|
100
|
+
* `head -20` spells `head -n 20`. Not a letter, so no bundle can spell it.
|
|
101
|
+
*/
|
|
102
|
+
export declare const NUMERIC_FLAG = "-<number>";
|
|
76
103
|
export declare const SAFE_COMMAND_SCOPES: CommandScope[];
|
|
77
104
|
export interface CommandAnalysis {
|
|
78
105
|
/** The command as written, for messages and prompts. */
|
|
79
106
|
command: string;
|
|
80
|
-
/** The base command, absent when the string could not be tokenized. */
|
|
107
|
+
/** The base command, absent when the string could not be tokenized or is a pipeline. */
|
|
81
108
|
base?: string;
|
|
82
109
|
tokens: string[];
|
|
110
|
+
/**
|
|
111
|
+
* Per token, whether the shell would expand it (an unquoted glob, brace,
|
|
112
|
+
* `~`, `$`, or backslash). Absent reads as "nothing expands", which only
|
|
113
|
+
* a scope marked `literal` consults.
|
|
114
|
+
*/
|
|
115
|
+
expands?: boolean[];
|
|
116
|
+
/**
|
|
117
|
+
* The commands of a pipeline (`a | b`), each analyzed on its own. Present,
|
|
118
|
+
* the invocation is covered only when every one of them is.
|
|
119
|
+
*/
|
|
120
|
+
pipeline?: CommandAnalysis[];
|
|
83
121
|
/**
|
|
84
122
|
* Why this invocation cannot be auto-approved at all — a control
|
|
85
123
|
* operator, an unbalanced quote, an absolute path. Undefined means it is
|
|
@@ -91,6 +129,11 @@ export interface CommandAnalysis {
|
|
|
91
129
|
export declare const analyzeCommand: (command: string) => CommandAnalysis;
|
|
92
130
|
/** Whether an invocation falls inside one scope. */
|
|
93
131
|
export declare const matchesScope: (analysis: CommandAnalysis, scope: CommandScope) => boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The scopes covering an invocation, one per command of a pipeline and one
|
|
134
|
+
* for a plain command, or undefined unless every command is covered.
|
|
135
|
+
*/
|
|
136
|
+
export declare const findCoveringScopes: (analysis: CommandAnalysis, scopes: readonly CommandScope[]) => CommandScope[] | undefined;
|
|
94
137
|
/** The first scope covering this invocation, if any covers it. */
|
|
95
138
|
export declare const findMatchingScope: (analysis: CommandAnalysis, scopes: readonly CommandScope[]) => CommandScope | undefined;
|
|
96
139
|
/**
|
|
@@ -130,6 +173,23 @@ export declare const findMatchingScope: (analysis: CommandAnalysis, scopes: read
|
|
|
130
173
|
* counts once.
|
|
131
174
|
*/
|
|
132
175
|
export declare const normalizeCommandScope: (analysis: CommandAnalysis) => CommandScope | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* The scope an operator declares in config (`approvals.commands`): a
|
|
178
|
+
* command and, optionally, the subcommands it is limited to — `agentboard`,
|
|
179
|
+
* `pnpm test`, `gh pr`. Whatever follows the prefix may vary, the way a
|
|
180
|
+
* remembered scope's arguments do, and the same things stay refused: the
|
|
181
|
+
* destructive flags, whatever the built-in list refuses for that command,
|
|
182
|
+
* and git's refspec deletes.
|
|
183
|
+
*
|
|
184
|
+
* Only words. A flag, an operator, or a token the shell would expand has no
|
|
185
|
+
* meaning as a prefix, and guessing one would be a grant nobody wrote, so
|
|
186
|
+
* the entry is refused with the reason instead.
|
|
187
|
+
*/
|
|
188
|
+
export declare const commandScopeFromPrefix: (prefix: string) => {
|
|
189
|
+
scope: CommandScope;
|
|
190
|
+
} | {
|
|
191
|
+
reason: string;
|
|
192
|
+
};
|
|
133
193
|
/** One line an operator can read in a log or a whitelist listing. */
|
|
134
194
|
export declare const describeCommandScope: (scope: CommandScope) => string;
|
|
135
195
|
/** Whether two scopes permit the same thing, so a whitelist does not grow duplicates. */
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;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