@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.148
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/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +2 -0
- package/dist/catalog/provenance.js +5 -1
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/extensions.module.js +9 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +18 -8
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +24 -3
- package/dist/extensions/permission-set.d.ts +12 -3
- package/dist/extensions/permission-set.js +5 -5
- package/dist/extensions/permission-view.d.ts +12 -5
- package/dist/extensions/permission-view.js +23 -2
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { isIP } from "node:net";
|
|
2
|
+
import { isLinkLocalAddress, isLoopbackHost, isLoopbackOrUnspecifiedAddress, NetDeniedError, normalizeHost, } from "./public-address.js";
|
|
3
|
+
export const PRIVATE_ENDPOINT_ALIAS_RE = /^[a-z][a-z0-9-]{0,62}$/;
|
|
4
|
+
export const PRIVATE_ENDPOINT_METHODS = [
|
|
5
|
+
"GET",
|
|
6
|
+
"HEAD",
|
|
7
|
+
"POST",
|
|
8
|
+
"PUT",
|
|
9
|
+
"PATCH",
|
|
10
|
+
"DELETE",
|
|
11
|
+
"OPTIONS",
|
|
12
|
+
];
|
|
13
|
+
/** Why an alias origin is invalid (English), or undefined. */
|
|
14
|
+
export function privateEndpointOriginProblem(value) {
|
|
15
|
+
let u;
|
|
16
|
+
try {
|
|
17
|
+
u = new URL(value);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return "must be an http:// or https:// origin such as https://llm-gateway.internal:8443";
|
|
21
|
+
}
|
|
22
|
+
if (u.protocol !== "http:" && u.protocol !== "https:") {
|
|
23
|
+
return "must be an http:// or https:// origin";
|
|
24
|
+
}
|
|
25
|
+
if (u.username !== "" || u.password !== "")
|
|
26
|
+
return "must not carry credentials";
|
|
27
|
+
if ((u.pathname !== "" && u.pathname !== "/") || u.search !== "" || u.hash !== "") {
|
|
28
|
+
return "must be an origin without a path, query or fragment (use pathPrefix for a path)";
|
|
29
|
+
}
|
|
30
|
+
const host = normalizeHost(u.hostname);
|
|
31
|
+
if (isIP(host) !== 0 && isLinkLocalAddress(host)) {
|
|
32
|
+
return "must not be a link-local or cloud metadata address";
|
|
33
|
+
}
|
|
34
|
+
if (isIP(host) !== 0 && !isLoopbackHost(host) && isLoopbackOrUnspecifiedAddress(host)) {
|
|
35
|
+
return "must not be an unspecified address";
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Why a path prefix is invalid (English), or undefined. */
|
|
40
|
+
export function privateEndpointPathPrefixProblem(value) {
|
|
41
|
+
if (!value.startsWith("/"))
|
|
42
|
+
return "must start with /";
|
|
43
|
+
if (/[%\\?#\s]/.test(value))
|
|
44
|
+
return "must not contain %, \\, ?, # or whitespace";
|
|
45
|
+
if (value.split("/").some((seg) => seg === "." || seg === "..")) {
|
|
46
|
+
return "must not contain . or .. segments";
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
function sameOrigin(a, b) {
|
|
51
|
+
try {
|
|
52
|
+
return new URL(a).origin === b;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function underPrefix(pathname, prefix) {
|
|
59
|
+
const p = prefix.replace(/\/+$/, "");
|
|
60
|
+
if (p === "")
|
|
61
|
+
return true;
|
|
62
|
+
return pathname === p || pathname.startsWith(`${p}/`);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether a path could leave its prefix on some backend although the parsed path stays under it:
|
|
66
|
+
* an encoded slash or backslash, an encoded `%` (a double-decoding hop), a `;` path parameter
|
|
67
|
+
* (`/v1/..;/admin` on Tomcat or Jetty), or a segment that is `.` or `..` or holds a `;` once
|
|
68
|
+
* decoded.
|
|
69
|
+
*/
|
|
70
|
+
function ambiguousPath(pathname) {
|
|
71
|
+
if (/%(2f|5c|25)/i.test(pathname) || pathname.includes(";"))
|
|
72
|
+
return true;
|
|
73
|
+
return pathname.split("/").some((seg) => {
|
|
74
|
+
let decoded;
|
|
75
|
+
try {
|
|
76
|
+
decoded = decodeURIComponent(seg);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return decoded === "." || decoded === ".." || decoded.includes(";");
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Headers by which a backend may run another method than the request line's. */
|
|
85
|
+
const METHOD_OVERRIDE_HEADERS = ["x-http-method-override", "x-http-method", "x-method-override"];
|
|
86
|
+
/**
|
|
87
|
+
* The alias admitting `plugin`'s `method` request to `url`, or undefined when no alias granted to
|
|
88
|
+
* the plugin has the URL's origin (the request is then judged like any other). Throws
|
|
89
|
+
* {@link NetDeniedError} `net.private_address` when an alias granted to the plugin has the origin
|
|
90
|
+
* but none admits the path or method: the destination is private and only the alias reaches it.
|
|
91
|
+
*/
|
|
92
|
+
export function matchPrivateEndpoint(endpoints, plugin, url, method, headers) {
|
|
93
|
+
let target;
|
|
94
|
+
try {
|
|
95
|
+
target = new URL(url);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const granted = Object.entries(endpoints).filter(([, e]) => e.plugins.includes(plugin) && sameOrigin(e.origin, target.origin));
|
|
101
|
+
if (granted.length === 0)
|
|
102
|
+
return undefined;
|
|
103
|
+
const m = method.toUpperCase();
|
|
104
|
+
const ambiguous = ambiguousPath(target.pathname);
|
|
105
|
+
const h = new Headers(headers);
|
|
106
|
+
// a method override in a header or the `_method` query parameter (Rails, Laravel, Symfony); a
|
|
107
|
+
// `_method` form field in the body is not inspected (documented)
|
|
108
|
+
const overridden = METHOD_OVERRIDE_HEADERS.some((name) => h.has(name)) ||
|
|
109
|
+
[...target.searchParams.keys()].some((k) => k.toLowerCase() === "_method");
|
|
110
|
+
for (const [alias, e] of granted) {
|
|
111
|
+
const prefixed = e.pathPrefix.replace(/\/+$/, "") !== "";
|
|
112
|
+
if (prefixed && ambiguous)
|
|
113
|
+
continue;
|
|
114
|
+
if (!underPrefix(target.pathname, e.pathPrefix))
|
|
115
|
+
continue;
|
|
116
|
+
if (e.methods !== undefined && (!e.methods.includes(m) || overridden))
|
|
117
|
+
continue;
|
|
118
|
+
return { alias, origin: target.origin, allowLoopback: e.allowLoopback };
|
|
119
|
+
}
|
|
120
|
+
const host = normalizeHost(target.hostname);
|
|
121
|
+
const names = granted.map(([alias]) => alias).join(", ");
|
|
122
|
+
throw new NetDeniedError("net.private_address", host, `Access to ${host} is refused: the private endpoint ${names} does not allow this method (${m}) or path.`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Why the configured aliases are refused across sections, or null: an alias on the port of the
|
|
126
|
+
* extension isolation Engine API (`extensionHost.isolation.engineUrl`), whatever its host
|
|
127
|
+
* ({@link aliasNetPolicy} refuses it at request time too).
|
|
128
|
+
*/
|
|
129
|
+
export function privateEndpointEngineProblem(config) {
|
|
130
|
+
const engineUrl = config.extensionHost.isolation?.engineUrl;
|
|
131
|
+
if (engineUrl === undefined)
|
|
132
|
+
return null;
|
|
133
|
+
const enginePort = portOf(new URL(engineUrl));
|
|
134
|
+
for (const [alias, e] of Object.entries(config.net.privateEndpoints)) {
|
|
135
|
+
let port;
|
|
136
|
+
try {
|
|
137
|
+
port = portOf(new URL(e.origin));
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (port === enginePort) {
|
|
143
|
+
return `net.privateEndpoints.${alias}.origin: must not use port ${enginePort} of the extension isolation Engine API (extensionHost.isolation.engineUrl), on any host`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const portOf = (u) => u.port || (u.protocol === "https:" ? "443" : "80");
|
|
149
|
+
/**
|
|
150
|
+
* The `NetPolicy.privateEndpoint` of an admitted alias. An alias on the port of the extension
|
|
151
|
+
* isolation Engine API (`engineUrl`) is refused outright, whatever host it names: the Engine may
|
|
152
|
+
* answer on any private address of its host (every interface, loopback, a second NIC), so no
|
|
153
|
+
* private address is admitted on that port. (`net.allowInsecureLoopback`, tests and development
|
|
154
|
+
* only, lifts every loopback refusal of ctx.net on its own, the Engine's included; never set it
|
|
155
|
+
* where the Engine listens on loopback.)
|
|
156
|
+
*/
|
|
157
|
+
export function aliasNetPolicy(match, engineUrl) {
|
|
158
|
+
const target = new URL(match.origin);
|
|
159
|
+
if (engineUrl !== undefined && portOf(new URL(engineUrl)) === portOf(target)) {
|
|
160
|
+
const name = normalizeHost(target.hostname);
|
|
161
|
+
throw new NetDeniedError("net.private_address", name, `Access to ${name} is refused: the private endpoint ${match.alias} uses port ${portOf(target)} of the extension isolation Engine API, which an alias never reaches.`);
|
|
162
|
+
}
|
|
163
|
+
return { origin: match.origin, allowLoopback: match.allowLoopback };
|
|
164
|
+
}
|
|
@@ -7,6 +7,8 @@ export declare function isForbiddenAddress(ip: string): boolean;
|
|
|
7
7
|
export declare function isLinkLocalAddress(ip: string): boolean;
|
|
8
8
|
/** Loopback (`127.0.0.0/8`, `::1`) or unspecified (`0.0.0.0/8`, `::`), embedded forms included. */
|
|
9
9
|
export declare function isLoopbackOrUnspecifiedAddress(ip: string): boolean;
|
|
10
|
+
/** Loopback only (`127.0.0.0/8`, `::1`, embedded forms included), never unspecified. */
|
|
11
|
+
export declare function isLoopbackAddress(ip: string): boolean;
|
|
10
12
|
/** A hostname normalized for comparison: lower case, no IPv6 brackets, no trailing dots. */
|
|
11
13
|
export declare function normalizeHost(host: string): string;
|
|
12
14
|
/** `localhost`, `127.0.0.0/8` or `::1` (as written in a URL). */
|
|
@@ -43,6 +45,18 @@ export type NetPolicy = {
|
|
|
43
45
|
*/
|
|
44
46
|
extension?: {
|
|
45
47
|
privateHint: string;
|
|
48
|
+
/** Appended to a refused plain-http URL (a request made outside an org: the alias to add). */
|
|
49
|
+
insecureHint?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A `net.privateEndpoints` alias admitted this extension request (`private-endpoints.ts`): a
|
|
53
|
+
* request to exactly `origin` may resolve to private addresses (link-local and metadata stay
|
|
54
|
+
* refused; loopback only with `allowLoopback`), may use plain http when the origin is http, and
|
|
55
|
+
* never uses the egress proxy.
|
|
56
|
+
*/
|
|
57
|
+
privateEndpoint?: {
|
|
58
|
+
origin: string;
|
|
59
|
+
allowLoopback: boolean;
|
|
46
60
|
};
|
|
47
61
|
};
|
|
48
62
|
export type LookupFn = (host: string) => Promise<{
|
|
@@ -145,6 +145,13 @@ export function isLinkLocalAddress(ip) {
|
|
|
145
145
|
export function isLoopbackOrUnspecifiedAddress(ip) {
|
|
146
146
|
return inTable(ip, loopbackOrUnspecified);
|
|
147
147
|
}
|
|
148
|
+
const loopbackOnly = new BlockList();
|
|
149
|
+
loopbackOnly.addSubnet("127.0.0.0", 8, "ipv4");
|
|
150
|
+
loopbackOnly.addAddress("::1", "ipv6");
|
|
151
|
+
/** Loopback only (`127.0.0.0/8`, `::1`, embedded forms included), never unspecified. */
|
|
152
|
+
export function isLoopbackAddress(ip) {
|
|
153
|
+
return inTable(ip, loopbackOnly);
|
|
154
|
+
}
|
|
148
155
|
/** A hostname normalized for comparison: lower case, no IPv6 brackets, no trailing dots. */
|
|
149
156
|
export function normalizeHost(host) {
|
|
150
157
|
let h = host.trim().toLowerCase();
|
|
@@ -312,12 +319,19 @@ export async function resolvePublic(host, policy, lookup = defaultLookup, origin
|
|
|
312
319
|
throw new NetDeniedError("net.dns_failed", h, `Cannot resolve ${h}.`);
|
|
313
320
|
}
|
|
314
321
|
const ex = exemptions(h, policy, origin);
|
|
322
|
+
// a private endpoint alias exempts exactly its origin (see NetPolicy.privateEndpoint)
|
|
323
|
+
const alias = policy.privateEndpoint !== undefined && origin === policy.privateEndpoint.origin
|
|
324
|
+
? policy.privateEndpoint
|
|
325
|
+
: undefined;
|
|
315
326
|
// extension requests never reach the kernel's own host, whatever the exemptions
|
|
316
327
|
const ownHost = (a) => policy.extension !== undefined &&
|
|
317
328
|
!policy.allowInsecureLoopback &&
|
|
329
|
+
!(alias?.allowLoopback === true && isLoopbackAddress(a)) &&
|
|
318
330
|
isLoopbackOrUnspecifiedAddress(a);
|
|
319
331
|
const refused = (a) => isForbiddenAddress(a) &&
|
|
320
|
-
(isLinkLocalAddress(a) ||
|
|
332
|
+
(isLinkLocalAddress(a) ||
|
|
333
|
+
ownHost(a) ||
|
|
334
|
+
(alias === undefined && !ex.all && !allowedBy(ex.cidrs, a)));
|
|
321
335
|
if (addrs.some(refused)) {
|
|
322
336
|
const hint = policy.extension?.privateHint ??
|
|
323
337
|
"add the hostname to net.allowPrivateHosts to allow an internal host";
|
package/dist/net/safe-fetch.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ import { type LookupFn, type NetPolicy } from "./public-address.js";
|
|
|
11
11
|
* - with `policy.proxy` (`net.httpsProxy`), an https URL whose host is not loopback and not in
|
|
12
12
|
* `noProxy` tunnels through the proxy (`proxy.ts`) instead: the host is not resolved locally
|
|
13
13
|
* (the proxy resolves it and owns SSRF protection for the resolved address), but an IP-literal
|
|
14
|
-
* host is still checked against the private ranges and `allowPrivateHosts`;
|
|
14
|
+
* host is still checked against the private ranges and `allowPrivateHosts`; an origin a
|
|
15
|
+
* `net.privateEndpoints` alias admitted (`policy.privateEndpoint`) never uses the proxy;
|
|
15
16
|
* - redirects are never followed: a 3xx (other than 304) is {@link NetDeniedError} `net.redirect`,
|
|
16
17
|
* or, with `redirects: "return"`, returned to the caller as is (its body unread);
|
|
17
18
|
* - with `maxBytes`, a declared or streamed body over the limit is {@link NetBodyTooLargeError}.
|
package/dist/net/safe-fetch.js
CHANGED
|
@@ -13,7 +13,8 @@ import { hostEntryExempts, isLoopbackHost, NetDeniedError, normalizeHost, resolv
|
|
|
13
13
|
* - with `policy.proxy` (`net.httpsProxy`), an https URL whose host is not loopback and not in
|
|
14
14
|
* `noProxy` tunnels through the proxy (`proxy.ts`) instead: the host is not resolved locally
|
|
15
15
|
* (the proxy resolves it and owns SSRF protection for the resolved address), but an IP-literal
|
|
16
|
-
* host is still checked against the private ranges and `allowPrivateHosts`;
|
|
16
|
+
* host is still checked against the private ranges and `allowPrivateHosts`; an origin a
|
|
17
|
+
* `net.privateEndpoints` alias admitted (`policy.privateEndpoint`) never uses the proxy;
|
|
17
18
|
* - redirects are never followed: a 3xx (other than 304) is {@link NetDeniedError} `net.redirect`,
|
|
18
19
|
* or, with `redirects: "return"`, returned to the caller as is (its body unread);
|
|
19
20
|
* - with `maxBytes`, a declared or streamed body over the limit is {@link NetBodyTooLargeError}.
|
|
@@ -154,8 +155,11 @@ async function safeFetchOnce(url, init, policy, opts) {
|
|
|
154
155
|
throw new NetDeniedError("net.insecure_url", "", "The URL is not valid.");
|
|
155
156
|
}
|
|
156
157
|
const host = normalizeHost(target.hostname);
|
|
158
|
+
// a net.privateEndpoints alias admitted this exact origin (ctx.net): direct, http if configured
|
|
159
|
+
const aliased = policy.privateEndpoint?.origin === target.origin;
|
|
157
160
|
const insecureOk = target.protocol === "http:" &&
|
|
158
|
-
(
|
|
161
|
+
(aliased ||
|
|
162
|
+
(policy.allowInsecureLoopback && isLoopbackHost(host)) ||
|
|
159
163
|
policy.trustedOrigins.some((o) => originOf(o) === target.origin));
|
|
160
164
|
if (target.protocol !== "https:" && !insecureOk) {
|
|
161
165
|
// an extension request to a host the org allows only as a host entry (https only): name the
|
|
@@ -164,12 +168,15 @@ async function safeFetchOnce(url, init, policy, opts) {
|
|
|
164
168
|
target.protocol === "http:" &&
|
|
165
169
|
hostEntryExempts(host, policy)
|
|
166
170
|
? ` ${host} is allowed for the organization over https only; to allow plain http, ask a super admin to allow the origin ${target.origin}.`
|
|
167
|
-
: ""
|
|
171
|
+
: policy.extension?.insecureHint !== undefined && target.protocol === "http:"
|
|
172
|
+
? ` If it is an internal endpoint: ${policy.extension.insecureHint}.`
|
|
173
|
+
: "";
|
|
168
174
|
throw new NetDeniedError("net.insecure_url", host, `The URL must use https (${host}).${hint}`);
|
|
169
175
|
}
|
|
170
176
|
const proxy = policy.proxy;
|
|
171
177
|
const proxied = proxy !== undefined &&
|
|
172
178
|
target.protocol === "https:" &&
|
|
179
|
+
!aliased &&
|
|
173
180
|
!isLoopbackHost(host) &&
|
|
174
181
|
!bypassesProxy(host, proxy.noProxy);
|
|
175
182
|
// getaddrinfo cannot be cancelled: stop waiting for it when the caller gives up
|
package/dist/overrides.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { OUTBOX_DISPATCH_FAILS } from "./infra/outbox/outbox.dispatcher.js";
|
|
|
19
19
|
import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
|
|
20
20
|
import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
|
|
21
21
|
import type { KernelQueueName } from "./infra/queue/queue-names.js";
|
|
22
|
+
import { BROKERED_ENDPOINT_PINS_SEAM, type BrokeredEndpointPin } from "./net/private-endpoint-preflight.js";
|
|
22
23
|
import { PUSH_SEND_TIMEOUT_MS } from "./push/delivery.js";
|
|
23
24
|
import { PROJECT_KNOWLEDGE_TIMEOUT, type ProjectKnowledgeTimeouts } from "./runtime/project/knowledge.service.js";
|
|
24
25
|
import { LIST_MODELS_TIMEOUT } from "./runtime/providers.js";
|
|
@@ -69,6 +70,8 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
|
69
70
|
* - `PLUGIN_PUBLIC_WRITE_LIMIT`: a lower limit for unsafe methods on `public` extension routes;
|
|
70
71
|
* - `EXTENSION_NET_SEAMS`: `ctx.net`'s DNS and dispatcher (a hostname resolving to a private address
|
|
71
72
|
* served by a loopback fake);
|
|
73
|
+
* - `BROKERED_ENDPOINT_PINS_SEAM`: the brokered pins the bootstrap's private endpoint preflight
|
|
74
|
+
* checks (a fixture plugin standing in for object-store-s3's ctx.net build);
|
|
72
75
|
* - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes);
|
|
73
76
|
* - `TOOL_WATCH_TIMINGS`: shorter watched-wait poll timings (interval, watcher timeout);
|
|
74
77
|
* - `PERMISSION_AUTO_GRANT_HOOKS`: a barrier after a Full access auto-grant's precheck (two
|
|
@@ -105,6 +108,7 @@ interface KernelSeams {
|
|
|
105
108
|
[BACKGROUND_STOP_ATTEMPT_MS]: () => number;
|
|
106
109
|
[PLUGIN_PUBLIC_WRITE_LIMIT]: number;
|
|
107
110
|
[EXTENSION_NET_SEAMS]: ExtensionNetSeams;
|
|
111
|
+
[BROKERED_ENDPOINT_PINS_SEAM]: readonly BrokeredEndpointPin[];
|
|
108
112
|
[APP_INTERCEPTOR]: NestInterceptor;
|
|
109
113
|
[PERMISSION_AUTO_GRANT_HOOKS]: PermissionAutoGrantHooks;
|
|
110
114
|
[TOOL_WATCH_TIMINGS]: Partial<ToolWatchTimings>;
|
package/dist/overrides.js
CHANGED
|
@@ -16,6 +16,7 @@ import { PLUGIN_PUBLIC_WRITE_LIMIT } from "./http/plugin-route-access.js";
|
|
|
16
16
|
import { OUTBOX_DISPATCH_FAILS } from "./infra/outbox/outbox.dispatcher.js";
|
|
17
17
|
import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
|
|
18
18
|
import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
|
|
19
|
+
import { BROKERED_ENDPOINT_PINS_SEAM, } from "./net/private-endpoint-preflight.js";
|
|
19
20
|
import { PUSH_SEND_TIMEOUT_MS } from "./push/delivery.js";
|
|
20
21
|
import { PROJECT_KNOWLEDGE_TIMEOUT, } from "./runtime/project/knowledge.service.js";
|
|
21
22
|
import { LIST_MODELS_TIMEOUT } from "./runtime/providers.js";
|
|
@@ -59,6 +60,7 @@ const SEAM_TOKENS = [
|
|
|
59
60
|
BACKGROUND_STOP_ATTEMPT_MS,
|
|
60
61
|
PLUGIN_PUBLIC_WRITE_LIMIT,
|
|
61
62
|
EXTENSION_NET_SEAMS,
|
|
63
|
+
BROKERED_ENDPOINT_PINS_SEAM,
|
|
62
64
|
APP_INTERCEPTOR,
|
|
63
65
|
PERMISSION_AUTO_GRANT_HOOKS,
|
|
64
66
|
TOOL_WATCH_TIMINGS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NpmFetchConfig } from "./npm.js";
|
|
2
|
-
import { type Provenance } from "./provenance.js";
|
|
2
|
+
import { type Provenance, type ProvenanceResult } from "./provenance.js";
|
|
3
3
|
declare const POLICY_VERSION = 1;
|
|
4
4
|
export interface OfficialNpmRevision {
|
|
5
5
|
name: string;
|
|
@@ -53,6 +53,31 @@ export declare function verifyPublisher(body: unknown, revision: OfficialNpmRevi
|
|
|
53
53
|
export declare function officialPublisherProblem(verified: VerifiedPublisher): string | undefined;
|
|
54
54
|
/** Checks both signatures, transparency evidence and publisher identity with the bundled roots. */
|
|
55
55
|
export declare function verifyOfficialPublisher(body: unknown, revision: OfficialNpmRevision): OfficialPublisherProof;
|
|
56
|
+
/**
|
|
57
|
+
* The official release workflow's certificate claims, without the per-build commit: what an
|
|
58
|
+
* official proof ({@link verifyOfficialPublisher}) established, for normalizing its publisher
|
|
59
|
+
* identity without the attestation bundle.
|
|
60
|
+
*/
|
|
61
|
+
export declare const OFFICIAL_PUBLISHER_CERTIFICATE: Readonly<Omit<PublisherCertificate, "commit">>;
|
|
62
|
+
/** The result of {@link fetchPublisherAttestation}: verified, or why not. */
|
|
63
|
+
export type PublisherAttestation = {
|
|
64
|
+
ok: true;
|
|
65
|
+
verified: VerifiedPublisher;
|
|
66
|
+
} | {
|
|
67
|
+
ok: false;
|
|
68
|
+
reason: string;
|
|
69
|
+
transient: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* One fetch of a revision's attestations for both its review: the display-only provenance and
|
|
73
|
+
* the publisher verified as any GitHub Actions publisher ({@link verifyPublisher}). Never throws:
|
|
74
|
+
* a missing, unreadable or unverifiable attestation is `ok: false` (transient for a network or
|
|
75
|
+
* registry hiccup). Integrity was checked by the caller.
|
|
76
|
+
*/
|
|
77
|
+
export declare function fetchAttestationEvidence(cfg: NpmFetchConfig, revision: OfficialNpmRevision, signal?: AbortSignal): Promise<{
|
|
78
|
+
provenance: ProvenanceResult;
|
|
79
|
+
attestation: PublisherAttestation;
|
|
80
|
+
}>;
|
|
56
81
|
/** Uses the same bounded registry client as the review's display-only provenance. */
|
|
57
82
|
export declare function fetchOfficialPublisher(cfg: NpmFetchConfig, revision: OfficialNpmRevision, signal?: AbortSignal): Promise<OfficialPublisherProof>;
|
|
58
83
|
/** A failed publisher check; `transient` failures (network, timeout, 5xx) may pass on a retry soon. */
|
|
@@ -5,7 +5,7 @@ import { toSignedEntity, toTrustMaterial, Verifier } from "@sigstore/verify";
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
7
7
|
import npmPublishKeys from "./npm-publish-keys.json" with { type: "json" };
|
|
8
|
-
import { fetchNpmAttestations, isTransientAttestationsFailure, PROVENANCE_TIMEOUT_MS, SLSA_PROVENANCE_V1, sha512Hex, } from "./provenance.js";
|
|
8
|
+
import { fetchNpmAttestations, fetchProvenanceWithBody, isTransientAttestationsFailure, PROVENANCE_TIMEOUT_MS, SLSA_PROVENANCE_V1, sha512Hex, } from "./provenance.js";
|
|
9
9
|
import trustedRoot from "./sigstore-trusted-root.json" with { type: "json" };
|
|
10
10
|
const NPM_PUBLISH = "https://github.com/npm/attestation/tree/main/specs/publish/v0.1";
|
|
11
11
|
const REGISTRY = "https://registry.npmjs.org";
|
|
@@ -222,6 +222,53 @@ export function verifyOfficialPublisher(body, revision) {
|
|
|
222
222
|
policyVersion: POLICY_VERSION,
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* The official release workflow's certificate claims, without the per-build commit: what an
|
|
227
|
+
* official proof ({@link verifyOfficialPublisher}) established, for normalizing its publisher
|
|
228
|
+
* identity without the attestation bundle.
|
|
229
|
+
*/
|
|
230
|
+
export const OFFICIAL_PUBLISHER_CERTIFICATE = Object.freeze({
|
|
231
|
+
issuer: GITHUB_ISSUER,
|
|
232
|
+
identity: WORKFLOW_IDENTITY,
|
|
233
|
+
repository: REPOSITORY,
|
|
234
|
+
repositoryId: REPOSITORY_ID,
|
|
235
|
+
ownerId: OWNER_ID,
|
|
236
|
+
workflow: WORKFLOW,
|
|
237
|
+
ref: MAIN_REF,
|
|
238
|
+
});
|
|
239
|
+
/**
|
|
240
|
+
* One fetch of a revision's attestations for both its review: the display-only provenance and
|
|
241
|
+
* the publisher verified as any GitHub Actions publisher ({@link verifyPublisher}). Never throws:
|
|
242
|
+
* a missing, unreadable or unverifiable attestation is `ok: false` (transient for a network or
|
|
243
|
+
* registry hiccup). Integrity was checked by the caller.
|
|
244
|
+
*/
|
|
245
|
+
export async function fetchAttestationEvidence(cfg, revision, signal) {
|
|
246
|
+
const timeout = AbortSignal.timeout(PROVENANCE_TIMEOUT_MS);
|
|
247
|
+
const got = await fetchProvenanceWithBody(cfg, revision.name, revision.version, signal ? AbortSignal.any([signal, timeout]) : timeout, { integrity: revision.integrity });
|
|
248
|
+
if (got.body === undefined) {
|
|
249
|
+
const reason = got.provenance.checked ? "no attestations" : got.provenance.reason;
|
|
250
|
+
return {
|
|
251
|
+
provenance: got.provenance,
|
|
252
|
+
attestation: { ok: false, reason, transient: got.transient === true },
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
return {
|
|
257
|
+
provenance: got.provenance,
|
|
258
|
+
attestation: { ok: true, verified: verifyPublisher(got.body, revision) },
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
return {
|
|
263
|
+
provenance: got.provenance,
|
|
264
|
+
attestation: {
|
|
265
|
+
ok: false,
|
|
266
|
+
reason: e instanceof Error ? e.message : String(e),
|
|
267
|
+
transient: false,
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
225
272
|
/** Uses the same bounded registry client as the review's display-only provenance. */
|
|
226
273
|
export async function fetchOfficialPublisher(cfg, revision, signal) {
|
|
227
274
|
const timeout = AbortSignal.timeout(PROVENANCE_TIMEOUT_MS);
|
|
@@ -51,6 +51,17 @@ export declare function sha512Hex(integrity: string): string | undefined;
|
|
|
51
51
|
export declare function fetchProvenance(cfg: NpmFetchConfig, name: string, version: string, signal: AbortSignal, opts?: {
|
|
52
52
|
integrity?: string;
|
|
53
53
|
}): Promise<ProvenanceResult>;
|
|
54
|
+
/**
|
|
55
|
+
* {@link fetchProvenance} that also returns the attestations answer it parsed, for the caller to
|
|
56
|
+
* verify the publisher from the same fetch. Never throws.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fetchProvenanceWithBody(cfg: NpmFetchConfig, name: string, version: string, signal: AbortSignal, opts?: {
|
|
59
|
+
integrity?: string;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
provenance: ProvenanceResult;
|
|
62
|
+
body?: unknown;
|
|
63
|
+
transient?: boolean;
|
|
64
|
+
}>;
|
|
54
65
|
/** Fetches bounded attestation evidence without accepting it as publisher proof. */
|
|
55
66
|
export declare function fetchNpmAttestations(cfg: NpmFetchConfig, name: string, version: string, signal: AbortSignal): Promise<unknown>;
|
|
56
67
|
/**
|
|
@@ -60,6 +60,30 @@ export async function fetchProvenance(cfg, name, version, signal, opts = {}) {
|
|
|
60
60
|
return notChecked(e instanceof NpmAttestationsError ? e.message : `cannot read the attestations: ${errMsg(e)}`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* {@link fetchProvenance} that also returns the attestations answer it parsed, for the caller to
|
|
65
|
+
* verify the publisher from the same fetch. Never throws.
|
|
66
|
+
*/
|
|
67
|
+
export async function fetchProvenanceWithBody(cfg, name, version, signal, opts = {}) {
|
|
68
|
+
let body;
|
|
69
|
+
try {
|
|
70
|
+
body = await fetchNpmAttestations(cfg, name, version, signal);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
return {
|
|
74
|
+
provenance: notChecked(e instanceof NpmAttestationsError
|
|
75
|
+
? e.message
|
|
76
|
+
: `cannot read the attestations: ${errMsg(e)}`),
|
|
77
|
+
transient: isTransientAttestationsFailure(e),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return { provenance: parseAttestations(body, opts.integrity), body };
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
return { provenance: notChecked(`cannot read the attestations: ${errMsg(e)}`), body };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
63
87
|
/** Fetches bounded attestation evidence without accepting it as publisher proof. */
|
|
64
88
|
export async function fetchNpmAttestations(cfg, name, version, signal) {
|
|
65
89
|
if (!NPM_NAME_RE.test(name) || name.length > 214 || !SEMVER_RE.test(version)) {
|
|
@@ -61,9 +61,9 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
61
61
|
reason: "Delivers other orgs' config copies of an extension (which differ, which secrets each holds) to the super admin's browser; an agent works in its own org",
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
|
-
route: "POST /api/v1/admin/
|
|
64
|
+
route: "POST /api/v1/admin/extension-permissions/:name/approve",
|
|
65
65
|
category: "human-only",
|
|
66
|
-
reason: "
|
|
66
|
+
reason: "Human security consent: a person approves an extension revision's permission review, full access included with one acknowledgement per realm; refused unattended",
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
route: "POST /api/v1/admin/extensions/:name/install",
|
|
@@ -145,12 +145,12 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
145
145
|
{
|
|
146
146
|
route: "POST /api/v1/admin/catalog/imports/:stagingId/confirm",
|
|
147
147
|
category: "human-only",
|
|
148
|
-
reason: "
|
|
148
|
+
reason: "Human security consent: confirms an import review and its revision's permissions, full access with one acknowledgement per realm",
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
route: "POST /api/v1/admin/catalog/imports/:stagingId/update",
|
|
152
152
|
category: "human-only",
|
|
153
|
-
reason: "
|
|
153
|
+
reason: "Human security consent: confirms an import review and its revision's permissions together with the platform update it applies, full access with one acknowledgement per realm",
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
156
|
route: "GET /api/v1/admin/catalog/items/:id/icon",
|
|
@@ -488,7 +488,7 @@ let AutomationsOperations = class AutomationsOperations {
|
|
|
488
488
|
}),
|
|
489
489
|
defineOperation({
|
|
490
490
|
id: "automations.runs",
|
|
491
|
-
description: "A task's run history, latest first (default 50, at most 200): each tick with its status, skip reason, error, conversation and the tools refused for lack of an approval. Takes the id from automations.list.",
|
|
491
|
+
description: "A task's run history, latest first (default 50, at most 200): each tick with its status, skip reason, error, conversation and the tools refused for lack of an approval (automations.grants-add can approve those). An entry `review:<command|write|read>` is a call the command review held: it always needs a person and is never grantable. Takes the id from automations.list.",
|
|
492
492
|
input: RunsQuery.extend({ automationId: Id }).strict(),
|
|
493
493
|
example: { automationId: EXAMPLE_ID },
|
|
494
494
|
authz: { orgAction: "automations.use" },
|
|
@@ -469,7 +469,7 @@ let CatalogAdminOperations = class CatalogAdminOperations {
|
|
|
469
469
|
}),
|
|
470
470
|
defineOperation({
|
|
471
471
|
id: "plugins.set-scope",
|
|
472
|
-
description: "Change where a platform plugin is on (super admin), for every org at once: pass the scope (and orgs for named) and the scopeHash plugins.scope-preview returned for that same target. Orgs that lose it have it removed by the scope sync; a preview that is out of date is refused.",
|
|
472
|
+
description: "Change where a platform plugin is on (super admin), for every org at once: pass the scope (and orgs for named) and the scopeHash plugins.scope-preview returned for that same target. Orgs that lose it have it removed by the scope sync; a preview that is out of date is refused. This operation only narrows: a scope reaching orgs the current one does not is not applied (applied: false) and you widen it yourself in the admin console, where it opens.",
|
|
473
473
|
input: z.object({ itemId: ItemId, ...CatalogScopeBody.shape }).strict(),
|
|
474
474
|
example: {
|
|
475
475
|
itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c",
|
|
@@ -550,10 +550,31 @@ let CatalogAdminOperations = class CatalogAdminOperations {
|
|
|
550
550
|
scope: input.scope,
|
|
551
551
|
...(input.orgs !== undefined && { orgs: input.orgs }),
|
|
552
552
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
553
|
+
try {
|
|
554
|
+
return {
|
|
555
|
+
applied: true,
|
|
556
|
+
item: await this.withoutPluginNames(input.itemId, target, () => this.scope.setScope(ctx.actorAccountId, input.itemId, { ...target, scopeHash: input.scopeHash },
|
|
557
|
+
// the Platform tool only narrows; widening is the person's, on the web
|
|
558
|
+
{ auditDetail: viaAgent("plugins.set-scope", ctx), onlyNarrows: true })),
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
catch (e) {
|
|
562
|
+
if (e instanceof ApiError && e.code === "plugin.scope_widening_not_allowed") {
|
|
563
|
+
return { applied: false, code: e.code, message: e.message };
|
|
564
|
+
}
|
|
565
|
+
throw e;
|
|
566
|
+
}
|
|
556
567
|
},
|
|
568
|
+
handoff: (input, result) => result?.applied === false
|
|
569
|
+
? {
|
|
570
|
+
kind: "handoff",
|
|
571
|
+
title: {
|
|
572
|
+
zh: "在管理后台扩大插件范围",
|
|
573
|
+
en: "Widen the plugin's scope in the admin console",
|
|
574
|
+
},
|
|
575
|
+
target: { type: "link", url: `/admin/plugins/${encodeURIComponent(input.itemId)}` },
|
|
576
|
+
}
|
|
577
|
+
: null,
|
|
557
578
|
}),
|
|
558
579
|
defineOperation({
|
|
559
580
|
id: "plugins.set-disabled",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { ExtensionPermissions } from "../../extensions/permissions.service.js";
|
|
3
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
4
|
+
import { PlatformOperations } from "../registry.js";
|
|
5
|
+
export declare class ExtensionPermissionOperations implements OnModuleInit {
|
|
6
|
+
private readonly registry;
|
|
7
|
+
private readonly permissions;
|
|
8
|
+
private readonly kdb;
|
|
9
|
+
constructor(registry: PlatformOperations, permissions: ExtensionPermissions, kdb: KernelDb);
|
|
10
|
+
onModuleInit(): void;
|
|
11
|
+
}
|