@void/platform 1.10.0 → 1.12.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/dist/ai-logging.d.mts +8 -12
- package/dist/ai-logging.mjs +7 -10
- package/dist/browser-page.mjs +2 -2
- package/dist/email-protocol.mjs +16 -14
- package/dist/index.d.mts +30 -4
- package/dist/index.mjs +120 -69
- package/dist/installer.d.mts +2 -0
- package/dist/installer.mjs +13 -13
- package/dist/plans.mjs +22 -10
- package/dist/runtime/api/assets/admin/client.js +44 -38
- package/dist/runtime/api/assets/admin/style.css +1 -1
- package/dist/runtime/api/index.js +3748 -329
- package/dist/runtime/dispatch/index.js +8 -8
- package/dist/runtime/drizzle/0065_security_audits.sql +313 -0
- package/dist/runtime/drizzle/meta/_journal.json +7 -0
- package/dist/runtime/emailGateway/index.js +5 -5
- package/dist/runtime/manifest.json +23 -16
- package/dist/runtime/proxy/index.js +5 -5
- package/dist/security-local-check.d.mts +28 -0
- package/dist/security-local-check.mjs +140 -0
- package/dist/security-lockfile.d.mts +34 -0
- package/dist/security-lockfile.mjs +181 -0
- package/dist/security-models.d.mts +88 -0
- package/dist/security-models.mjs +186 -0
- package/dist/security-policy.d.mts +245 -0
- package/dist/security-policy.mjs +491 -0
- package/package.json +24 -7
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { SecurityModelId } from "./security-models.mjs";
|
|
2
|
+
/** `platform_settings` key that holds the policy. */
|
|
3
|
+
export declare const SECURITY_POLICY_SETTINGS_KEY = "securityAudits.policy";
|
|
4
|
+
export declare const SECURITY_MODES: readonly ["disabled", "public", "all"];
|
|
5
|
+
export type SecurityMode = (typeof SECURITY_MODES)[number];
|
|
6
|
+
/** Names shown in the admin panel and CLI output. */
|
|
7
|
+
export declare const SECURITY_MODE_LABELS: Readonly<Record<SecurityMode, string>>;
|
|
8
|
+
export type SecurityLimitRange = Readonly<{
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
default: number;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Allowed whole-number range and default of every limit. Concurrency and timeout come
|
|
15
|
+
* from the spec. The token and call ranges are ours: at their top, the most expensive
|
|
16
|
+
* priced model reserves $12 per scan.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SECURITY_LIMIT_RANGES: {
|
|
19
|
+
/** Running scans per installation. */
|
|
20
|
+
readonly concurrency: {
|
|
21
|
+
readonly min: 1;
|
|
22
|
+
readonly max: 10;
|
|
23
|
+
readonly default: 2;
|
|
24
|
+
};
|
|
25
|
+
/** Wall clock per scan, the only timeout setting. */
|
|
26
|
+
readonly timeoutMinutes: {
|
|
27
|
+
readonly min: 5;
|
|
28
|
+
readonly max: 60;
|
|
29
|
+
readonly default: 20;
|
|
30
|
+
};
|
|
31
|
+
readonly maxInputTokens: {
|
|
32
|
+
readonly min: 50_000;
|
|
33
|
+
readonly max: 2_000_000;
|
|
34
|
+
readonly default: 1_200_000;
|
|
35
|
+
};
|
|
36
|
+
readonly maxOutputTokens: {
|
|
37
|
+
readonly min: 5000;
|
|
38
|
+
readonly max: 200_000;
|
|
39
|
+
readonly default: 120_000;
|
|
40
|
+
};
|
|
41
|
+
readonly modelCallsPerScan: {
|
|
42
|
+
readonly min: 10;
|
|
43
|
+
readonly max: 200;
|
|
44
|
+
readonly default: 80;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type SecurityLimitKey = keyof typeof SECURITY_LIMIT_RANGES;
|
|
48
|
+
export type SecurityPolicyLimits = Readonly<Record<SecurityLimitKey, number>>;
|
|
49
|
+
export declare const SECURITY_LIMIT_KEYS: ReadonlyArray<SecurityLimitKey>;
|
|
50
|
+
export type SecurityPolicyBudgets = Readonly<{
|
|
51
|
+
platformCapOn: boolean;
|
|
52
|
+
/** Whole-installation cap in USD per calendar month (UTC). */
|
|
53
|
+
platformMonthlyUsd: number;
|
|
54
|
+
/** Applies `projectDefaultMonthlyUsd` to every project. */
|
|
55
|
+
projectCapsOn: boolean;
|
|
56
|
+
projectDefaultMonthlyUsd: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** Highest USD amount a cap may be set to. */
|
|
59
|
+
export declare const SECURITY_MAX_MONTHLY_USD = 1e6;
|
|
60
|
+
/** Scheduled full sweeps (spec §20 Phase 2). Off by default: they cost money. */
|
|
61
|
+
export type SecuritySweeps = Readonly<{
|
|
62
|
+
on: boolean;
|
|
63
|
+
everyDays: number;
|
|
64
|
+
}>;
|
|
65
|
+
export type SecurityThirdPartyNotice = Readonly<{
|
|
66
|
+
acceptedByUserId: string;
|
|
67
|
+
/** ISO 8601 timestamp. */
|
|
68
|
+
acceptedAt: string;
|
|
69
|
+
version: number;
|
|
70
|
+
}>;
|
|
71
|
+
export type SecurityEntitlement = Readonly<{
|
|
72
|
+
/** ISO 8601 timestamp of the last probe. */
|
|
73
|
+
checkedAt: string;
|
|
74
|
+
/** Checks 1–4 passed. */
|
|
75
|
+
ok: boolean;
|
|
76
|
+
/** Names of the failed required checks. */
|
|
77
|
+
missing: ReadonlyArray<string>;
|
|
78
|
+
/** Probe check 5, per third-party host. */
|
|
79
|
+
hosts: Readonly<{
|
|
80
|
+
openai: boolean;
|
|
81
|
+
anthropic: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/** While failing: when the probe first failed in this run of failures. */
|
|
84
|
+
failingSince?: string;
|
|
85
|
+
}>;
|
|
86
|
+
export type SecurityPolicy = Readonly<{
|
|
87
|
+
mode: SecurityMode;
|
|
88
|
+
defaultModel: SecurityModelId;
|
|
89
|
+
blockedModels: ReadonlyArray<SecurityModelId>;
|
|
90
|
+
thirdPartyNotice: SecurityThirdPartyNotice | null;
|
|
91
|
+
limits: SecurityPolicyLimits;
|
|
92
|
+
budgets: SecurityPolicyBudgets;
|
|
93
|
+
entitlement: SecurityEntitlement | null;
|
|
94
|
+
/** "Scan before a project goes public" (spec §5.5). */
|
|
95
|
+
publicGate: boolean;
|
|
96
|
+
sweeps: SecuritySweeps;
|
|
97
|
+
/** Spec §8.5: re-scan once on the `@cf` default after a third-party scan fails. */
|
|
98
|
+
fallbackToCf: boolean;
|
|
99
|
+
/** Spec §20: a weekly summary email to installation admins. */
|
|
100
|
+
digest: boolean;
|
|
101
|
+
revision: number;
|
|
102
|
+
}>;
|
|
103
|
+
/** A fresh probe is needed to leave `disabled` or to turn the public gate on. */
|
|
104
|
+
export declare const SECURITY_ENTITLEMENT_MAX_AGE_MS: number;
|
|
105
|
+
/**
|
|
106
|
+
* Error codes (the `error` field) the API returns for security audits, with their HTTP
|
|
107
|
+
* status. The CLI matches on these strings.
|
|
108
|
+
*/
|
|
109
|
+
export declare const SECURITY_ERRORS: {
|
|
110
|
+
readonly modelNotAllowed: {
|
|
111
|
+
readonly code: "security model not allowed";
|
|
112
|
+
readonly status: 422;
|
|
113
|
+
};
|
|
114
|
+
readonly providerNoticeNotAccepted: {
|
|
115
|
+
readonly code: "provider notice not accepted";
|
|
116
|
+
readonly status: 422;
|
|
117
|
+
};
|
|
118
|
+
readonly entitlementMissing: {
|
|
119
|
+
readonly code: "security entitlement missing";
|
|
120
|
+
readonly status: 409;
|
|
121
|
+
};
|
|
122
|
+
readonly findingChanged: {
|
|
123
|
+
readonly code: "finding changed";
|
|
124
|
+
readonly status: 409;
|
|
125
|
+
};
|
|
126
|
+
readonly budgetAbovePlatformLimit: {
|
|
127
|
+
readonly code: "security budget above platform limit";
|
|
128
|
+
readonly status: 422;
|
|
129
|
+
};
|
|
130
|
+
readonly publicGateNeedsZeroTrust: {
|
|
131
|
+
readonly code: "security public gate needs zero trust";
|
|
132
|
+
readonly status: 409;
|
|
133
|
+
};
|
|
134
|
+
readonly publicGateNeedsPolicy: {
|
|
135
|
+
readonly code: "security public gate needs policy";
|
|
136
|
+
readonly status: 409;
|
|
137
|
+
};
|
|
138
|
+
readonly publicGateOn: {
|
|
139
|
+
readonly code: "security public gate on";
|
|
140
|
+
readonly status: 409;
|
|
141
|
+
};
|
|
142
|
+
readonly noPublicRequest: {
|
|
143
|
+
readonly code: "no public request";
|
|
144
|
+
readonly status: 409;
|
|
145
|
+
};
|
|
146
|
+
readonly publicRequestClosed: {
|
|
147
|
+
readonly code: "public request closed";
|
|
148
|
+
readonly status: 409;
|
|
149
|
+
};
|
|
150
|
+
readonly publicRequestHasUrgentFindings: {
|
|
151
|
+
readonly code: "security public request has urgent findings";
|
|
152
|
+
readonly status: 409;
|
|
153
|
+
};
|
|
154
|
+
readonly scanBypassReasonRequired: {
|
|
155
|
+
readonly code: "scan bypass reason required";
|
|
156
|
+
readonly status: 422;
|
|
157
|
+
};
|
|
158
|
+
readonly policyUnreadable: {
|
|
159
|
+
readonly code: "security policy unreadable";
|
|
160
|
+
readonly status: 503;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
export type SecurityErrorName = keyof typeof SECURITY_ERRORS;
|
|
164
|
+
export type SecurityError = (typeof SECURITY_ERRORS)[SecurityErrorName];
|
|
165
|
+
export declare function defaultSecurityBudgets(): SecurityPolicyBudgets;
|
|
166
|
+
/** `sweeps.everyDays`: a whole number of days in `SECURITY_SWEEP_DAYS_RANGE`. */
|
|
167
|
+
export declare function parseSecuritySweepDays(value: unknown): number;
|
|
168
|
+
/**
|
|
169
|
+
* The security webhook URL (spec §20): `https` only, no user name or password (the body
|
|
170
|
+
* is signed instead), at most 2048 characters. Returns the normalized URL.
|
|
171
|
+
*/
|
|
172
|
+
export declare function parseSecurityWebhookUrl(value: unknown): string;
|
|
173
|
+
/** The policy of an installation that never saved one: Off, nothing accepted or probed. */
|
|
174
|
+
export declare function defaultSecurityPolicy(): SecurityPolicy;
|
|
175
|
+
export declare function isSecurityMode(value: unknown): value is SecurityMode;
|
|
176
|
+
/** A change to some limits. Unknown keys are refused so a typo is not silently ignored. */
|
|
177
|
+
export declare function parseSecurityLimitsPatch(value: unknown): Partial<SecurityPolicyLimits>;
|
|
178
|
+
/** A USD amount for a monthly cap: 0 to `SECURITY_MAX_MONTHLY_USD`, whole cents. */
|
|
179
|
+
export declare function parseSecurityUsd(value: unknown, label: string): number;
|
|
180
|
+
/**
|
|
181
|
+
* Strict check of a policy about to be written: every known field present and valid,
|
|
182
|
+
* and the fields agree. Unknown fields are ignored.
|
|
183
|
+
*/
|
|
184
|
+
export declare function parseSecurityPolicy(value: unknown): SecurityPolicy;
|
|
185
|
+
/**
|
|
186
|
+
* Reader of the stored policy row. Data another release could have written still reads:
|
|
187
|
+
* unknown blocked models are dropped, a default this release cannot run falls back,
|
|
188
|
+
* limits are clamped. Anything else the strict parser refuses throws here too.
|
|
189
|
+
*/
|
|
190
|
+
export declare function readSecurityPolicy(value: unknown): SecurityPolicy;
|
|
191
|
+
/** The last probe passed checks 1–4 less than 24 hours before `now` (ms). */
|
|
192
|
+
export declare function isSecurityEntitlementFresh(entitlement: SecurityEntitlement | null, now: number): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* `platform_settings` key of the per-plan monthly scan caps (M27). Kept out of
|
|
195
|
+
* `plans:catalog`: an older API rebuilds the catalog from known keys on every write, so
|
|
196
|
+
* a cap stored there would be lost after a rollback (same as `plans:ai-logging`).
|
|
197
|
+
*/
|
|
198
|
+
export declare const PLAN_SECURITY_CAPS_SETTING = "plans:security-caps";
|
|
199
|
+
/** Plan ID -> monthly cap in whole cents, or `null` = no cap for that plan. Missing = policy default. */
|
|
200
|
+
export interface PlanSecurityCaps {
|
|
201
|
+
readonly [planId: string]: number | null;
|
|
202
|
+
}
|
|
203
|
+
/** A read caps row and how many entries it left out. */
|
|
204
|
+
export interface PlanSecurityCapsRead {
|
|
205
|
+
readonly caps: PlanSecurityCaps;
|
|
206
|
+
readonly dropped: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* One plan's cap: whole cents, `none` (no cap from the plan, even with project caps
|
|
210
|
+
* on) or `inherit` (the policy's default project cap applies while project caps are on).
|
|
211
|
+
*/
|
|
212
|
+
export type SecurityPlanCap = number | "none" | "inherit";
|
|
213
|
+
/** One stored entry as a plan cap; `undefined` when it is neither whole cents nor `null`. */
|
|
214
|
+
export declare function readStoredPlanSecurityCap(entry: unknown): SecurityPlanCap | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* Reads a stored caps row. Lenient: an entry that is not a plan ID with whole cents or
|
|
217
|
+
* `null` is left out (that plan inherits) and counted in `dropped`, so one bad entry
|
|
218
|
+
* never stops plan edits or scans. A row that is not an object reads as empty.
|
|
219
|
+
*/
|
|
220
|
+
export declare function readPlanSecurityCaps(value: unknown): PlanSecurityCapsRead;
|
|
221
|
+
/** The cap of one plan in a caps row. */
|
|
222
|
+
export declare function planSecurityCap(caps: PlanSecurityCaps, planId: string): SecurityPlanCap;
|
|
223
|
+
/**
|
|
224
|
+
* Reads a plan change's `securityCap` field: a USD amount (whole cents), `none` or
|
|
225
|
+
* `inherit`. `undefined` keeps the plan's current cap. An amount comes back in cents.
|
|
226
|
+
*/
|
|
227
|
+
export declare function parsePlanSecurityCapInput(value: unknown): SecurityPlanCap | undefined;
|
|
228
|
+
/** A caps row with one plan's cap changed; `inherit` leaves the plan out. */
|
|
229
|
+
export declare function withPlanSecurityCap(caps: PlanSecurityCaps, planId: string, cap: SecurityPlanCap): PlanSecurityCaps;
|
|
230
|
+
/** `$50.00 / month`, `no cap` or `policy default`, for the CLI and the admin panel. */
|
|
231
|
+
export declare function formatPlanSecurityCap(cap: SecurityPlanCap): string;
|
|
232
|
+
/** `text` as a whole number written with 1 to `maxDigits` ASCII digits, else `null`. */
|
|
233
|
+
export declare function parseSecurityDigits(text: string, maxDigits: number): number | null;
|
|
234
|
+
/** A finding label as the page prints it (`F-12`): its number, else `null`. */
|
|
235
|
+
export declare function parseSecurityFindingLabel(text: string): number | null;
|
|
236
|
+
/**
|
|
237
|
+
* A finding trace of `{ file, line, note }` steps as `file:line note` lines, as the CLI
|
|
238
|
+
* and the project page print it; `null` for another shape. Callers clean the text.
|
|
239
|
+
*/
|
|
240
|
+
export declare function securityTraceLines(value: unknown): Array<string> | null;
|
|
241
|
+
/**
|
|
242
|
+
* A dollar amount typed in a budget form, such as `50`, `12.50` or `$12.50`. Empty text
|
|
243
|
+
* is `null` (no cap of its own); text that is not an amount is `undefined`.
|
|
244
|
+
*/
|
|
245
|
+
export declare function parseSecurityUsdText(text: string): number | null | undefined;
|