passport-bridge 0.19.0 → 0.20.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/README.md +1 -1
- package/dist/cliAutopilotPolicy.d.ts +34 -9
- package/dist/cliAutopilotPolicy.js +32 -1
- package/dist/cliHook.js +1 -1
- package/dist/cliHookDecide.js +1 -1
- package/dist/cliHookGuard.d.ts +12 -5
- package/dist/cliHookGuard.js +26 -35
- package/dist/cliHookVendors.d.ts +3 -0
- package/dist/cliHookVendors.js +7 -0
- package/dist/cliHookVendorsMore.d.ts +3 -4
- package/dist/cliHookVendorsMore.js +3 -9
- package/dist/cliKeysShim.d.ts +1 -1
- package/dist/cliPolicyV2.js +61 -19
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -262,7 +262,7 @@ An ask becomes one Activity row. In Claude Code, with the audit hook registered,
|
|
|
262
262
|
|
|
263
263
|
**When Passport can't be reached.** A local run, block, or attended ask stands as decided. When the guard needs Passport (an unattended ask, Codex, or a Production action someone else approves) and it doesn't answer within the budget, the environment's `offline` setting from cli-policy v2 decides: ask, block, or allow (ask everywhere by default). An ask nobody can answer (unattended, or Codex) blocks, a second-person action is always blocked, and allow never covers an irreversible action or an ask from a team floor, team or workspace rule, approver rule, or approved exception. A policy synced more than 7 days ago uses the default. The reason ends with one line saying why, such as `Nobody is here to approve it and Passport couldn't be reached, so it's blocked.`
|
|
264
264
|
|
|
265
|
-
**App access.** The person's pass for the app a `passport exec` CLI acts on (Railway for `railway`, GitHub for `gh`, and so on) comes with cli-policy v2 as `appAccess
|
|
265
|
+
**App access.** The person's pass for the app a `passport exec` CLI acts on (Railway for `railway`, GitHub for `gh`, and so on) comes with cli-policy v2 as `access`, one record per CLI whose app limits the person (an older server's `appAccess` map is read the same way). The guard applies it before any rule, and no rule or exception lifts it. No access blocks every command of that CLI with `You don't have access to Railway in Passport. Ask an admin.` and a link to the app's Access tab; read-only blocks everything but reads. `passport exec` says the same (exit 5, cause `no_access`, with `Access: <link>`). A CLI whose app isn't in the workspace keeps working from its key.
|
|
266
266
|
|
|
267
267
|
`src/cliPolicy.ts` caches the member's CLI policy (`GET /api/my/cli-policy`) at `$PASSPORT_HOME/cli-policy/<profile>.json` (mode 600). Servers with Autopilot send version 2 (`src/cliPolicyV2.ts`: presets, floors, CLI rules, irreversible and delete verbs, environment flags, placed environments); older servers send version 1, and then the guard keeps its earlier shape: ask or deny before destructive verbs, never allow, no server call, and reports without the Autopilot fields. `passport login` and `passport status` refresh it and `passport logout` removes it. A 404 or error keeps the previous copy; with no copy the guard asks before every destructive verb. `PASSPORT_HOOK_DISABLED=1` turns both hooks off.
|
|
268
268
|
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Autopilot decisions on this machine, from the cached cli-policy v2.
|
|
3
3
|
*
|
|
4
4
|
* The same order the server uses (docs: autopilot map, section 4):
|
|
5
|
+
* 0. The access ceiling: the person's pass for the app the CLI acts on.
|
|
6
|
+
* No access blocks every command, Read-only runs only reads. Nothing
|
|
7
|
+
* below lifts it.
|
|
5
8
|
* 1. Block rules → Blocked.
|
|
6
9
|
* 2. (Grants given in this session live on the server; unattended runs ask it.)
|
|
7
10
|
* 3. The most specific exception (action > app > class), strictest across
|
|
@@ -17,7 +20,7 @@ export type Preset = (typeof PRESETS)[number];
|
|
|
17
20
|
export declare const ACTION_CLASSES: readonly ["read", "change", "delete", "irreversible"];
|
|
18
21
|
export type ActionClass = (typeof ACTION_CLASSES)[number];
|
|
19
22
|
export type Decision = "allow" | "ask" | "block";
|
|
20
|
-
export type CauseKind = "block" | "grant" | "rule" | "floor" | "preset" | "default";
|
|
23
|
+
export type CauseKind = "access" | "block" | "grant" | "rule" | "floor" | "preset" | "default";
|
|
21
24
|
export type Cause = {
|
|
22
25
|
kind: CauseKind;
|
|
23
26
|
id?: string;
|
|
@@ -74,11 +77,28 @@ export type RuleException = {
|
|
|
74
77
|
actionClass?: ActionClass;
|
|
75
78
|
environment: ActionEnv | "any";
|
|
76
79
|
};
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
/**
|
|
81
|
+
* One access ceiling record (cli-policy v2 `access`, shared `CliAccessRecord`):
|
|
82
|
+
* the person's pass for the app a vendor CLI acts on, sent only when it limits
|
|
83
|
+
* them. No record means no ceiling.
|
|
84
|
+
*/
|
|
85
|
+
export type AccessRecord = {
|
|
86
|
+
layer: "access";
|
|
87
|
+
/** The vendor CLI it governs, e.g. `railway` or `flyctl`. */
|
|
88
|
+
vendor: string;
|
|
89
|
+
appKey: string;
|
|
90
|
+
/** The app's name, "Railway". */
|
|
80
91
|
app: string;
|
|
92
|
+
pass: "none" | "readonly";
|
|
93
|
+
/** The cause line: "No access to Railway in Passport". */
|
|
81
94
|
cause: string;
|
|
95
|
+
/** What the person and the agent read. */
|
|
96
|
+
message: string;
|
|
97
|
+
/** The app's Access tab, when the server sent a valid link. */
|
|
98
|
+
link?: string;
|
|
99
|
+
};
|
|
100
|
+
/** What a person reads when the access ceiling blocks: the message and the Access link. */
|
|
101
|
+
export type AccessBlock = {
|
|
82
102
|
message: string;
|
|
83
103
|
link?: string;
|
|
84
104
|
};
|
|
@@ -131,10 +151,10 @@ export type AutopilotPolicy = {
|
|
|
131
151
|
/** What the guard does per environment when Passport can't be reached
|
|
132
152
|
* (Batch A). Absent from older servers: built-in defaults apply. */
|
|
133
153
|
offline?: Record<ActionEnv, "ask" | "block" | "allow">;
|
|
134
|
-
/** The
|
|
135
|
-
*
|
|
136
|
-
* only reads. A vendor without
|
|
137
|
-
|
|
154
|
+
/** The access ceiling (cli-policy v2 `access`): one record per vendor CLI
|
|
155
|
+
* whose app limits this person. No access blocks every command, Read-only
|
|
156
|
+
* runs only reads. A vendor without a record has no ceiling. */
|
|
157
|
+
access?: AccessRecord[];
|
|
138
158
|
/** Resources the workspace placed, by id (Phase 4.5). Present only when the
|
|
139
159
|
* server reads where a finding lands, so findings may carry it. */
|
|
140
160
|
resources?: Array<{
|
|
@@ -186,9 +206,14 @@ export type ActionFacts = {
|
|
|
186
206
|
export type LocalDecision = {
|
|
187
207
|
decision: Decision;
|
|
188
208
|
cause: Cause;
|
|
209
|
+
/** Blocked by the access ceiling: what the person reads. */
|
|
210
|
+
access?: AccessBlock;
|
|
189
211
|
};
|
|
212
|
+
/** The access record for a vendor CLI, under either spelling (`fly`, `flyctl`). */
|
|
213
|
+
export declare function accessRecordFor(policy: AutopilotPolicy, vendor: string): AccessRecord | undefined;
|
|
190
214
|
/** The server's `decideAction`, minus grants (only the server knows them).
|
|
191
|
-
* The
|
|
215
|
+
* The access ceiling comes first and nothing lifts it; the second-person rule
|
|
216
|
+
* turns a Production run into an ask the server owns. */
|
|
192
217
|
export declare function decideAction(policy: AutopilotPolicy, facts: ActionFacts): LocalDecision;
|
|
193
218
|
/** Whether an ask needs someone other than the person at the keyboard. */
|
|
194
219
|
export declare function needsSecondPerson(cause: Cause | undefined): boolean;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Autopilot decisions on this machine, from the cached cli-policy v2.
|
|
3
3
|
*
|
|
4
4
|
* The same order the server uses (docs: autopilot map, section 4):
|
|
5
|
+
* 0. The access ceiling: the person's pass for the app the CLI acts on.
|
|
6
|
+
* No access blocks every command, Read-only runs only reads. Nothing
|
|
7
|
+
* below lifts it.
|
|
5
8
|
* 1. Block rules → Blocked.
|
|
6
9
|
* 2. (Grants given in this session live on the server; unattended runs ask it.)
|
|
7
10
|
* 3. The most specific exception (action > app > class), strictest across
|
|
@@ -12,6 +15,7 @@
|
|
|
12
15
|
* Every decision carries its cause, and every cause reads as one line.
|
|
13
16
|
*/
|
|
14
17
|
import { ENV_LABEL } from "./cliHookEnvironment.js";
|
|
18
|
+
import { vendorKeys } from "./cliHookVendors.js";
|
|
15
19
|
export const PRESETS = ["careful", "balanced", "handsoff"];
|
|
16
20
|
export const ACTION_CLASSES = ["read", "change", "delete", "irreversible"];
|
|
17
21
|
/**
|
|
@@ -253,9 +257,36 @@ function mostSpecific(rules) {
|
|
|
253
257
|
function stricter(a, b) {
|
|
254
258
|
return DECISION_RANK[b] > DECISION_RANK[a] ? b : a;
|
|
255
259
|
}
|
|
260
|
+
/** The access record for a vendor CLI, under either spelling (`fly`, `flyctl`). */
|
|
261
|
+
export function accessRecordFor(policy, vendor) {
|
|
262
|
+
const records = policy.access;
|
|
263
|
+
if (!records?.length)
|
|
264
|
+
return undefined;
|
|
265
|
+
for (const key of vendorKeys(vendor)) {
|
|
266
|
+
const record = records.find((entry) => entry.vendor === key);
|
|
267
|
+
if (record)
|
|
268
|
+
return record;
|
|
269
|
+
}
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
/** The access ceiling: No access blocks every command, Read-only blocks all but reads. */
|
|
273
|
+
function accessCeiling(policy, facts) {
|
|
274
|
+
const record = accessRecordFor(policy, facts.vendor);
|
|
275
|
+
if (!record || (record.pass === "readonly" && facts.actionClass === "read"))
|
|
276
|
+
return null;
|
|
277
|
+
return {
|
|
278
|
+
decision: "block",
|
|
279
|
+
cause: { kind: "access", label: record.cause },
|
|
280
|
+
access: { message: record.message, ...(record.link ? { link: record.link } : {}) }
|
|
281
|
+
};
|
|
282
|
+
}
|
|
256
283
|
/** The server's `decideAction`, minus grants (only the server knows them).
|
|
257
|
-
* The
|
|
284
|
+
* The access ceiling comes first and nothing lifts it; the second-person rule
|
|
285
|
+
* turns a Production run into an ask the server owns. */
|
|
258
286
|
export function decideAction(policy, facts) {
|
|
287
|
+
const ceiling = accessCeiling(policy, facts);
|
|
288
|
+
if (ceiling)
|
|
289
|
+
return ceiling;
|
|
259
290
|
const decided = decideByRules(policy, facts);
|
|
260
291
|
const classes = policy.secondPerson?.classes ?? [];
|
|
261
292
|
if (decided.decision !== "allow" || facts.environment !== "production" || !classes.includes(facts.actionClass)) {
|
package/dist/cliHook.js
CHANGED
|
@@ -141,7 +141,7 @@ function reportable(findings, decided = [], local = false) {
|
|
|
141
141
|
const entry = decided.find((candidate) => candidate.finding === finding);
|
|
142
142
|
return {
|
|
143
143
|
vendor: finding.vendor,
|
|
144
|
-
verb: safeVerb(finding.verb),
|
|
144
|
+
verb: safeVerb(finding.verbKey ?? finding.verb),
|
|
145
145
|
risk: finding.risk,
|
|
146
146
|
...(entry?.reported ? { environment: entry.reported } : {}),
|
|
147
147
|
...entry?.placement,
|
package/dist/cliHookDecide.js
CHANGED
|
@@ -26,7 +26,7 @@ export const CLI_DECIDE_PATH = "/api/my/cli/decide";
|
|
|
26
26
|
const MAX_RESPONSE_BYTES = 16 * 1024;
|
|
27
27
|
const MAX_FINDINGS = 8;
|
|
28
28
|
const ID = /^[A-Za-z0-9_-]{1,80}$/;
|
|
29
|
-
const CAUSE_KINDS = new Set(["block", "grant", "rule", "floor", "preset", "default"]);
|
|
29
|
+
const CAUSE_KINDS = new Set(["access", "block", "grant", "rule", "floor", "preset", "default"]);
|
|
30
30
|
const CLASSES = new Set(["read", "change", "delete", "irreversible"]);
|
|
31
31
|
function line(raw, max) {
|
|
32
32
|
if (typeof raw !== "string")
|
package/dist/cliHookGuard.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* With a v1 policy (an older server) or none at all, the guard keeps its old
|
|
14
14
|
* shape: ask or deny, never allow.
|
|
15
15
|
*/
|
|
16
|
-
import { type ActionClass, type ActionEnv, type Cause, type Decision } from "./cliAutopilotPolicy.js";
|
|
16
|
+
import { type AccessBlock, type ActionClass, type ActionEnv, type Cause, type Decision } from "./cliAutopilotPolicy.js";
|
|
17
17
|
import type { CliFinding } from "./cliHookClassify.js";
|
|
18
18
|
import { type EnvSource } from "./cliHookEnvironment.js";
|
|
19
19
|
import { type LinkFs } from "./envLinkFs.js";
|
|
@@ -39,10 +39,7 @@ export type DecidedFinding = {
|
|
|
39
39
|
access?: AppAccessBlock;
|
|
40
40
|
};
|
|
41
41
|
/** "You don't have access to Railway in Passport. Ask an admin." and the app's Access link. */
|
|
42
|
-
export type AppAccessBlock =
|
|
43
|
-
message: string;
|
|
44
|
-
link?: string;
|
|
45
|
-
};
|
|
42
|
+
export type AppAccessBlock = AccessBlock;
|
|
46
43
|
export type GuardDecision = {
|
|
47
44
|
verdict: GuardVerdict;
|
|
48
45
|
/** The finding that set the verdict, e.g. `railway volume delete`. */
|
|
@@ -83,6 +80,16 @@ export declare function guardMachineOf(machine: {
|
|
|
83
80
|
}, rawCwd: unknown, env: Record<string, string | undefined>): GuardMachine;
|
|
84
81
|
/** The words a person needs to recognise the command, never its arguments. */
|
|
85
82
|
export declare function guardLabel(finding: CliFinding): string;
|
|
83
|
+
/**
|
|
84
|
+
* Read, Change, Delete, or Irreversible: the server's `cliActionClass`, from
|
|
85
|
+
* the tables it serves. A read is a read, whatever lists it. A write is a
|
|
86
|
+
* Change unless a safety pack raises it (`deletes`); anything else is raised.
|
|
87
|
+
* A raised verb is Irreversible where `irreversible` lists it, or
|
|
88
|
+
* `irreversibleInProduction` does and it runs in Production; otherwise a Delete.
|
|
89
|
+
*/
|
|
90
|
+
export declare function classOf(policy: CachedCliPolicyV2, finding: CliFinding & {
|
|
91
|
+
vendor: string;
|
|
92
|
+
}, verb: string, environment: ActionEnv): ActionClass;
|
|
86
93
|
/** One recognized command's decision, or null when Autopilot has no opinion. */
|
|
87
94
|
export declare function decideFinding(finding: CliFinding, policy: CachedCliPolicyV2, machine?: GuardMachine): DecidedFinding | null;
|
|
88
95
|
/**
|
package/dist/cliHookGuard.js
CHANGED
|
@@ -18,8 +18,7 @@ import { reportedEnvironment } from "./cliHookEnvironment.js";
|
|
|
18
18
|
import { placementOf, resolveTarget, targetNote } from "./envResolve.js";
|
|
19
19
|
import { NODE_LINK_FS } from "./envLinkFs.js";
|
|
20
20
|
import { normalizeArgv, splitCommands } from "./cliHookParse.js";
|
|
21
|
-
import { VENDORS } from "./cliHookVendors.js";
|
|
22
|
-
import { IRREVERSIBLE_IN_PRODUCTION } from "./cliHookVendorsMore.js";
|
|
21
|
+
import { VENDORS, vendorKeys } from "./cliHookVendors.js";
|
|
23
22
|
/** This machine for folder links: the command's folder (canonical, and as
|
|
24
23
|
* the agent named it), the project, home, and the agent's shell. */
|
|
25
24
|
export function guardMachineOf(machine, rawCwd, env) {
|
|
@@ -49,16 +48,8 @@ const RANK = { allow: 0, ask: 1, deny: 2 };
|
|
|
49
48
|
const LABEL_TOKEN = /^-{0,2}[A-Za-z0-9][A-Za-z0-9._:+-]{0,39}$/;
|
|
50
49
|
/** Shell features that hide what will run. Any of them: no allow. */
|
|
51
50
|
const OPAQUE_SHELL = /[<>`$\\\n]|\$\(/;
|
|
52
|
-
/** Built in, whatever the server sends: these can't be taken back. */
|
|
53
|
-
const BUILT_IN_IRREVERSIBLE = { gh: ["repo delete"] };
|
|
54
51
|
/** Classes the guard decides; anything else (http, api, sql, local) is no decision. */
|
|
55
52
|
const CLASS_OF_RISK = CLASS_OF_HOOK_RISK;
|
|
56
|
-
/** `fly` and `flyctl` share one map; the server may key either spelling. */
|
|
57
|
-
function vendorKeys(vendor) {
|
|
58
|
-
const spec = Object.hasOwn(VENDORS, vendor) ? VENDORS[vendor] : undefined;
|
|
59
|
-
const aliases = spec ? Object.keys(VENDORS).filter((key) => VENDORS[key] === spec && key !== vendor) : [];
|
|
60
|
-
return [vendor, ...aliases];
|
|
61
|
-
}
|
|
62
53
|
function policyDecision(policy, vendor, verb) {
|
|
63
54
|
for (const key of vendorKeys(vendor)) {
|
|
64
55
|
const verbs = Object.hasOwn(policy.vendors, key) ? policy.vendors[key] : undefined;
|
|
@@ -107,6 +98,8 @@ function verdictV1(finding, policy) {
|
|
|
107
98
|
return null;
|
|
108
99
|
const explicit = policy ? policyDecision(policy, finding.vendor, finding.verbKey ?? finding.verb) : undefined;
|
|
109
100
|
// Built-in default when no policy was ever synced: ask before destructive.
|
|
101
|
+
// Every irreversible verb (the server's irreversible tables) is destructive
|
|
102
|
+
// too, so this covers them without a list of its own.
|
|
110
103
|
const decision = explicit ?? (finding.risk === "destructive" ? (policy?.default.destructive ?? "ask") : undefined);
|
|
111
104
|
if (decision === "never")
|
|
112
105
|
return "deny";
|
|
@@ -140,25 +133,25 @@ function listed(map, vendor, verb) {
|
|
|
140
133
|
return false;
|
|
141
134
|
return vendorKeys(vendor).some((key) => Object.hasOwn(map, key) && map[key].includes(verb));
|
|
142
135
|
}
|
|
143
|
-
/**
|
|
144
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Read, Change, Delete, or Irreversible: the server's `cliActionClass`, from
|
|
138
|
+
* the tables it serves. A read is a read, whatever lists it. A write is a
|
|
139
|
+
* Change unless a safety pack raises it (`deletes`); anything else is raised.
|
|
140
|
+
* A raised verb is Irreversible where `irreversible` lists it, or
|
|
141
|
+
* `irreversibleInProduction` does and it runs in Production; otherwise a Delete.
|
|
142
|
+
*/
|
|
143
|
+
export function classOf(policy, finding, verb, environment) {
|
|
145
144
|
const { autopilot } = policy;
|
|
146
|
-
// The server's `cliActionClass`: a read is a read, whatever lists it.
|
|
147
145
|
if (finding.risk === "read")
|
|
148
146
|
return "read";
|
|
149
|
-
if (
|
|
147
|
+
if (finding.risk === "write" && !listed(autopilot.deletes, finding.vendor, verb))
|
|
148
|
+
return "change";
|
|
149
|
+
if (listed(autopilot.irreversible, finding.vendor, verb))
|
|
150
150
|
return "irreversible";
|
|
151
|
-
|
|
152
|
-
const productionOnly = listed(autopilot.irreversibleInProduction, finding.vendor, verb) ||
|
|
153
|
-
listed(IRREVERSIBLE_IN_PRODUCTION, finding.vendor, verb);
|
|
154
|
-
if (environment === "production" && productionOnly) {
|
|
151
|
+
if (environment === "production" && listed(autopilot.irreversibleInProduction, finding.vendor, verb)) {
|
|
155
152
|
return "irreversible";
|
|
156
153
|
}
|
|
157
|
-
|
|
158
|
-
if (finding.vendor === "git" && verb === "push --force" && environment === "production")
|
|
159
|
-
return "irreversible";
|
|
160
|
-
const base = CLASS_OF_RISK[finding.risk] ?? "delete";
|
|
161
|
-
return base === "change" && listed(autopilot.deletes, finding.vendor, verb) ? "delete" : base;
|
|
154
|
+
return "delete";
|
|
162
155
|
}
|
|
163
156
|
/** Commands run as administrator never run silently. */
|
|
164
157
|
const SUDO_CAUSE = { kind: "default", label: "Commands run with sudo always ask" };
|
|
@@ -176,6 +169,7 @@ function decideLocal(finding, policy) {
|
|
|
176
169
|
finding,
|
|
177
170
|
decision: sudo ? "ask" : decided.decision,
|
|
178
171
|
cause: sudo ? SUDO_CAUSE : decided.cause,
|
|
172
|
+
...(decided.access ? { access: decided.access } : {}),
|
|
179
173
|
environment: facts.environment,
|
|
180
174
|
environmentSource: "flag",
|
|
181
175
|
reported: facts.environment,
|
|
@@ -187,7 +181,7 @@ function decideLocal(finding, policy) {
|
|
|
187
181
|
* repository's own `.passport/actions.toml` may only ask or block. */
|
|
188
182
|
function decideProject(finding, policy) {
|
|
189
183
|
const facts = finding.project;
|
|
190
|
-
const { decision, cause } = decideAction(policy.autopilot, {
|
|
184
|
+
const { decision, cause, access } = decideAction(policy.autopilot, {
|
|
191
185
|
vendor: "project",
|
|
192
186
|
verb: finding.verb,
|
|
193
187
|
actionClass: facts.actionClass,
|
|
@@ -199,6 +193,7 @@ function decideProject(finding, policy) {
|
|
|
199
193
|
finding,
|
|
200
194
|
decision,
|
|
201
195
|
cause,
|
|
196
|
+
...(access ? { access } : {}),
|
|
202
197
|
environment: facts.environment,
|
|
203
198
|
environmentSource: "mapping",
|
|
204
199
|
reported: facts.environment,
|
|
@@ -231,27 +226,20 @@ export function decideFinding(finding, policy, machine) {
|
|
|
231
226
|
: target;
|
|
232
227
|
const verb = finding.verbKey ?? finding.verb;
|
|
233
228
|
const actionClass = classOf(policy, finding, verb, hint.kind);
|
|
234
|
-
|
|
229
|
+
// The access ceiling comes first inside the engine: No access blocks every
|
|
230
|
+
// command, Read-only runs only reads (the same as exec).
|
|
231
|
+
const { decision, cause, access } = decideAction(policy.autopilot, {
|
|
235
232
|
vendor: finding.vendor,
|
|
236
233
|
verb,
|
|
237
234
|
actionClass,
|
|
238
235
|
environment: hint.kind
|
|
239
236
|
});
|
|
240
|
-
// The person's pass for the app this CLI acts on comes first: No access
|
|
241
|
-
// blocks every command, Read-only runs only reads (the same as exec).
|
|
242
|
-
const pass = Object.hasOwn(policy.autopilot.appAccess ?? {}, finding.vendor)
|
|
243
|
-
? policy.autopilot.appAccess[finding.vendor]
|
|
244
|
-
: undefined;
|
|
245
|
-
const limited = pass && (pass.pass === "none" || (pass.pass === "readonly" && actionClass !== "read"));
|
|
246
|
-
const { decision, cause } = limited
|
|
247
|
-
? { decision: "block", cause: { kind: "block", label: pass.cause } }
|
|
248
|
-
: ruled;
|
|
249
237
|
const reported = finding.pushEnvironment ?? reportedEnvironment(hint);
|
|
250
238
|
return {
|
|
251
239
|
finding,
|
|
252
240
|
decision,
|
|
253
241
|
cause,
|
|
254
|
-
...(
|
|
242
|
+
...(access ? { access } : {}),
|
|
255
243
|
environment: hint.kind,
|
|
256
244
|
environmentSource: hint.source,
|
|
257
245
|
...(reported ? { reported } : {}),
|
|
@@ -402,6 +390,9 @@ export function denyMessage(decision, owner) {
|
|
|
402
390
|
// The app's access, in the words exec uses, with where an admin changes it.
|
|
403
391
|
if (decision.access)
|
|
404
392
|
return decision.access.link ? `${decision.access.message} ${decision.access.link}` : decision.access.message;
|
|
393
|
+
// The server's access block without its message: no rule or exception lifts it.
|
|
394
|
+
if (decision.cause?.kind === "access")
|
|
395
|
+
return `${decision.cause.label}. Ask an admin for access.`;
|
|
405
396
|
if (decision.cause) {
|
|
406
397
|
const mine = decision.cause.label.startsWith("Your rule");
|
|
407
398
|
const next = mine
|
package/dist/cliHookVendors.d.ts
CHANGED
|
@@ -20,4 +20,7 @@ export type VendorSpec = {
|
|
|
20
20
|
opTokenRisk?: Record<string, CliRisk>;
|
|
21
21
|
};
|
|
22
22
|
export declare const VENDORS: Record<string, VendorSpec>;
|
|
23
|
+
/** A vendor and its aliases: `fly` and `flyctl` share one map, and the server
|
|
24
|
+
* may key either spelling. The vendor itself comes first. */
|
|
25
|
+
export declare function vendorKeys(vendor: string): string[];
|
|
23
26
|
export declare const NPX_PACKAGE_TO_VENDOR: Record<string, string>;
|
package/dist/cliHookVendors.js
CHANGED
|
@@ -570,6 +570,13 @@ VENDORS.fly = VENDORS.flyctl;
|
|
|
570
570
|
VENDORS.neon = VENDORS.neonctl;
|
|
571
571
|
VENDORS.tf = VENDORS.terraform;
|
|
572
572
|
VENDORS.k = VENDORS.kubectl;
|
|
573
|
+
/** A vendor and its aliases: `fly` and `flyctl` share one map, and the server
|
|
574
|
+
* may key either spelling. The vendor itself comes first. */
|
|
575
|
+
export function vendorKeys(vendor) {
|
|
576
|
+
const spec = Object.hasOwn(VENDORS, vendor) ? VENDORS[vendor] : undefined;
|
|
577
|
+
const aliases = spec ? Object.keys(VENDORS).filter((key) => VENDORS[key] === spec && key !== vendor) : [];
|
|
578
|
+
return [vendor, ...aliases];
|
|
579
|
+
}
|
|
573
580
|
// npx / bunx / pnpm dlx / yarn dlx package-name -> vendor name
|
|
574
581
|
export const NPX_PACKAGE_TO_VENDOR = {
|
|
575
582
|
vercel: "vercel",
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* connection string. Same shape and meaning as `cliHookVendors.ts`: each risk
|
|
5
5
|
* describes what the verb does, never what Passport permits.
|
|
6
6
|
*
|
|
7
|
-
* Database verbs that throw data away are destructive (a Delete)
|
|
8
|
-
*
|
|
7
|
+
* Database verbs that throw data away are destructive (a Delete). Which of
|
|
8
|
+
* them can't be undone in Production (dropping a database) comes from the
|
|
9
|
+
* server's irreversible tables in cli-policy v2, never from this file.
|
|
9
10
|
*/
|
|
10
11
|
/** The same shape as `VendorSpec` in cliHookVendors.ts (kept local: no import cycle). */
|
|
11
12
|
type Risk = "read" | "write" | "destructive" | "local";
|
|
@@ -16,6 +17,4 @@ type VendorSpec = {
|
|
|
16
17
|
export declare const MORE_VENDORS: Record<string, VendorSpec>;
|
|
17
18
|
/** npx / bunx / pnpm dlx package names for these CLIs. */
|
|
18
19
|
export declare const MORE_NPX_PACKAGES: Record<string, string>;
|
|
19
|
-
/** Verbs that can't be taken back when they run against Production. */
|
|
20
|
-
export declare const IRREVERSIBLE_IN_PRODUCTION: Record<string, string[]>;
|
|
21
20
|
export {};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* connection string. Same shape and meaning as `cliHookVendors.ts`: each risk
|
|
5
5
|
* describes what the verb does, never what Passport permits.
|
|
6
6
|
*
|
|
7
|
-
* Database verbs that throw data away are destructive (a Delete)
|
|
8
|
-
*
|
|
7
|
+
* Database verbs that throw data away are destructive (a Delete). Which of
|
|
8
|
+
* them can't be undone in Production (dropping a database) comes from the
|
|
9
|
+
* server's irreversible tables in cli-policy v2, never from this file.
|
|
9
10
|
*/
|
|
10
11
|
const RAILS_DB = {
|
|
11
12
|
"db:migrate": "write",
|
|
@@ -187,10 +188,3 @@ export const MORE_NPX_PACKAGES = {
|
|
|
187
188
|
knex: "knex",
|
|
188
189
|
"sequelize-cli": "sequelize"
|
|
189
190
|
};
|
|
190
|
-
/** Verbs that can't be taken back when they run against Production. */
|
|
191
|
-
export const IRREVERSIBLE_IN_PRODUCTION = {
|
|
192
|
-
rails: ["db:drop"],
|
|
193
|
-
rake: ["db:drop"],
|
|
194
|
-
sequelize: ["db:drop"],
|
|
195
|
-
psql: ["drop database"]
|
|
196
|
-
};
|
package/dist/cliKeysShim.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type ShimDependencies = {
|
|
|
14
14
|
};
|
|
15
15
|
/** A shim as JSON: no home-folder paths beyond Passport's own. */
|
|
16
16
|
export declare function shimJson(shim: ShimInfo): {
|
|
17
|
-
vendor: "railway" | "wrangler" | "vercel" | "flyctl" | "supabase" | "aws" | "stripe" | "
|
|
17
|
+
vendor: "railway" | "wrangler" | "vercel" | "flyctl" | "supabase" | "aws" | "stripe" | "neonctl" | "gh";
|
|
18
18
|
command: string;
|
|
19
19
|
state: import("./execShims.js").ShimState;
|
|
20
20
|
path: string;
|
package/dist/cliPolicyV2.js
CHANGED
|
@@ -169,6 +169,7 @@ function offline(value) {
|
|
|
169
169
|
return out;
|
|
170
170
|
}
|
|
171
171
|
const PASSES = new Set(["full", "readonly", "none"]);
|
|
172
|
+
const MAX_ACCESS = 128;
|
|
172
173
|
/** An absolute http(s) link, or undefined. */
|
|
173
174
|
function webLink(value) {
|
|
174
175
|
if (typeof value !== "string" || value.length > 300 || /[\u0000- \u007f]/.test(value))
|
|
@@ -181,8 +182,53 @@ function webLink(value) {
|
|
|
181
182
|
return undefined;
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
/**
|
|
185
|
-
function
|
|
185
|
+
/** One ceiling record's words: the server's, or the same words built from the app's name. */
|
|
186
|
+
function accessRecord(vendor, appKey, pass, body) {
|
|
187
|
+
const app = printable(body.app, 80);
|
|
188
|
+
if (!app)
|
|
189
|
+
return null;
|
|
190
|
+
const cause = printable(body.cause, 160) || `${pass === "none" ? "No access" : "Read-only access"} to ${app} in Passport`;
|
|
191
|
+
const link = webLink(body.link);
|
|
192
|
+
return {
|
|
193
|
+
layer: "access",
|
|
194
|
+
vendor,
|
|
195
|
+
appKey,
|
|
196
|
+
app,
|
|
197
|
+
pass,
|
|
198
|
+
cause,
|
|
199
|
+
message: printable(body.message, 240) || `${cause}.`,
|
|
200
|
+
...(link ? { link } : {})
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** `access`, the ceiling records: absent is none at all, anything malformed rejects the document. */
|
|
204
|
+
function access(value) {
|
|
205
|
+
if (value === undefined)
|
|
206
|
+
return undefined;
|
|
207
|
+
if (!Array.isArray(value) || value.length > MAX_ACCESS)
|
|
208
|
+
return null;
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const raw of value) {
|
|
211
|
+
const body = plainObject(raw);
|
|
212
|
+
if (!body || body.layer !== "access")
|
|
213
|
+
return null;
|
|
214
|
+
const { vendor, appKey, pass } = body;
|
|
215
|
+
if (typeof vendor !== "string" || !VENDOR_KEY.test(vendor) || UNSAFE_KEYS.has(vendor))
|
|
216
|
+
return null;
|
|
217
|
+
if (typeof appKey !== "string" || !VENDOR_KEY.test(appKey))
|
|
218
|
+
return null;
|
|
219
|
+
if (pass !== "none" && pass !== "readonly")
|
|
220
|
+
return null;
|
|
221
|
+
const record = accessRecord(vendor, appKey, pass, body);
|
|
222
|
+
if (!record)
|
|
223
|
+
return null;
|
|
224
|
+
out.push(record);
|
|
225
|
+
}
|
|
226
|
+
return out;
|
|
227
|
+
}
|
|
228
|
+
/** An older server's `appAccess` map (bridges up to 0.19), as ceiling records:
|
|
229
|
+
* the vendors whose pass is not full. The map doesn't name the app's key, so
|
|
230
|
+
* the vendor stands in. Anything malformed rejects the document, as before. */
|
|
231
|
+
function legacyAccess(value) {
|
|
186
232
|
if (value === undefined)
|
|
187
233
|
return undefined;
|
|
188
234
|
const body = plainObject(value);
|
|
@@ -191,24 +237,19 @@ function appAccess(value) {
|
|
|
191
237
|
const entries = Object.entries(body);
|
|
192
238
|
if (entries.length > MAX_VENDORS)
|
|
193
239
|
return null;
|
|
194
|
-
const out =
|
|
240
|
+
const out = [];
|
|
195
241
|
for (const [vendor, raw] of entries) {
|
|
196
242
|
const entry = plainObject(raw);
|
|
197
243
|
if (!VENDOR_KEY.test(vendor) || UNSAFE_KEYS.has(vendor) || !entry || !PASSES.has(entry.pass))
|
|
198
244
|
return null;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (
|
|
245
|
+
if (!printable(entry.app, 80))
|
|
246
|
+
return null;
|
|
247
|
+
if (entry.pass === "full")
|
|
248
|
+
continue;
|
|
249
|
+
const record = accessRecord(vendor, vendor, entry.pass, entry);
|
|
250
|
+
if (!record)
|
|
202
251
|
return null;
|
|
203
|
-
|
|
204
|
-
const link = webLink(entry.link);
|
|
205
|
-
out[vendor] = {
|
|
206
|
-
pass,
|
|
207
|
-
app,
|
|
208
|
-
cause,
|
|
209
|
-
message: printable(entry.message, 240) || `${cause}.`,
|
|
210
|
-
...(link ? { link } : {})
|
|
211
|
-
};
|
|
252
|
+
out.push(record);
|
|
212
253
|
}
|
|
213
254
|
return out;
|
|
214
255
|
}
|
|
@@ -385,7 +426,7 @@ export function serializeCliPolicyV2(policy) {
|
|
|
385
426
|
})),
|
|
386
427
|
...(autopilot.secondPerson ? { secondPerson: autopilot.secondPerson } : {}),
|
|
387
428
|
...(autopilot.offline ? { offline: autopilot.offline } : {}),
|
|
388
|
-
...(autopilot.
|
|
429
|
+
...(autopilot.access ? { access: autopilot.access } : {}),
|
|
389
430
|
irreversible: autopilot.irreversible,
|
|
390
431
|
irreversibleInProduction: autopilot.irreversibleInProduction ?? {},
|
|
391
432
|
deletes: autopilot.deletes ?? {},
|
|
@@ -439,8 +480,9 @@ export function parseCliPolicyV2(value) {
|
|
|
439
480
|
const knownProject = project(body.project);
|
|
440
481
|
if (knownProject === null)
|
|
441
482
|
return null;
|
|
442
|
-
|
|
443
|
-
|
|
483
|
+
// The ceiling records; an older server sends only the `appAccess` map.
|
|
484
|
+
const ceiling = body.access !== undefined ? access(body.access) : legacyAccess(body.appAccess);
|
|
485
|
+
if (ceiling === null)
|
|
444
486
|
return null;
|
|
445
487
|
return {
|
|
446
488
|
version: 2,
|
|
@@ -461,7 +503,7 @@ export function parseCliPolicyV2(value) {
|
|
|
461
503
|
...(body.speed === true ? { reportsSpeed: true } : {}),
|
|
462
504
|
...(parsedSecondPerson?.classes.length ? { secondPerson: parsedSecondPerson } : {}),
|
|
463
505
|
...(offline(body.offline) ? { offline: offline(body.offline) } : {}),
|
|
464
|
-
...(
|
|
506
|
+
...(ceiling?.length ? { access: ceiling } : {}),
|
|
465
507
|
...(knownProject ? { project: knownProject } : {})
|
|
466
508
|
}
|
|
467
509
|
};
|
package/dist/pluginPin.d.ts
CHANGED
package/dist/pluginPin.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.20.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Keep in lockstep with bridge/package.json.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.20.0";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passport-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "passport-bridge",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.20.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.1"
|