@void/platform 1.11.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 +23 -6
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
CREATE TABLE "project_security_settings" (
|
|
2
|
+
"project_id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"model" text,
|
|
4
|
+
"provider_notice_version" integer,
|
|
5
|
+
"provider_notice_by_user_id" text,
|
|
6
|
+
"provider_notice_at" timestamp with time zone,
|
|
7
|
+
"monthly_cap_cents" integer,
|
|
8
|
+
"cap_ceiling_cents" integer,
|
|
9
|
+
"cap_updated_by_user_id" text,
|
|
10
|
+
"cap_updated_at" timestamp with time zone,
|
|
11
|
+
"next_finding_number" integer DEFAULT 1 NOT NULL,
|
|
12
|
+
"policy_override" text DEFAULT 'inherit' NOT NULL,
|
|
13
|
+
"updated_by_user_id" text,
|
|
14
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
15
|
+
CONSTRAINT "project_security_settings_monthly_cap" CHECK (("project_security_settings"."monthly_cap_cents" IS NULL OR "project_security_settings"."monthly_cap_cents" BETWEEN 0 AND 100000000)),
|
|
16
|
+
CONSTRAINT "project_security_settings_cap_ceiling" CHECK (("project_security_settings"."cap_ceiling_cents" IS NULL OR "project_security_settings"."cap_ceiling_cents" BETWEEN 0 AND 100000000)),
|
|
17
|
+
CONSTRAINT "project_security_settings_next_finding" CHECK ("project_security_settings"."next_finding_number" > 0),
|
|
18
|
+
CONSTRAINT "project_security_settings_policy_override" CHECK (("project_security_settings"."policy_override" IN ('inherit', 'always', 'never'))),
|
|
19
|
+
CONSTRAINT "project_security_settings_notice" CHECK (("project_security_settings"."provider_notice_version" IS NULL) = ("project_security_settings"."provider_notice_at" IS NULL))
|
|
20
|
+
);
|
|
21
|
+
--> statement-breakpoint
|
|
22
|
+
CREATE TABLE "security_finding_events" (
|
|
23
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
24
|
+
"finding_id" text NOT NULL,
|
|
25
|
+
"project_id" text NOT NULL,
|
|
26
|
+
"scan_id" text,
|
|
27
|
+
"actor_kind" text NOT NULL,
|
|
28
|
+
"actor_user_id" text,
|
|
29
|
+
"actor_role" text,
|
|
30
|
+
"action" text NOT NULL,
|
|
31
|
+
"resolution" text,
|
|
32
|
+
"comment" text,
|
|
33
|
+
"severity_from" text,
|
|
34
|
+
"severity_to" text,
|
|
35
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
36
|
+
CONSTRAINT "security_finding_events_actor_kind" CHECK (("security_finding_events"."actor_kind" IN ('user', 'installation_admin', 'scanner', 'system'))),
|
|
37
|
+
CONSTRAINT "security_finding_events_action" CHECK (("security_finding_events"."action" IN ('created', 'seen_again', 'seen_again_stale', 'severity_changed', 'promoted', 'not_seen', 'resolved', 'reopened', 'commented', 'severity_edited'))),
|
|
38
|
+
CONSTRAINT "security_finding_events_resolution" CHECK (("security_finding_events"."resolution" IS NULL OR ("security_finding_events"."resolution" IN ('fixed', 'false_positive', 'accepted_risk')))),
|
|
39
|
+
CONSTRAINT "security_finding_events_severity_from" CHECK (("security_finding_events"."severity_from" IS NULL OR ("security_finding_events"."severity_from" IN ('critical', 'high', 'medium', 'low', 'informational')))),
|
|
40
|
+
CONSTRAINT "security_finding_events_severity_to" CHECK (("security_finding_events"."severity_to" IS NULL OR ("security_finding_events"."severity_to" IN ('critical', 'high', 'medium', 'low', 'informational')))),
|
|
41
|
+
CONSTRAINT "security_finding_events_comment" CHECK ("security_finding_events"."comment" IS NULL OR char_length("security_finding_events"."comment") BETWEEN 1 AND 4000)
|
|
42
|
+
);
|
|
43
|
+
--> statement-breakpoint
|
|
44
|
+
CREATE TABLE "security_findings" (
|
|
45
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
46
|
+
"project_id" text NOT NULL,
|
|
47
|
+
"number" integer NOT NULL,
|
|
48
|
+
"fingerprint_key" text NOT NULL,
|
|
49
|
+
"model_fingerprint" text,
|
|
50
|
+
"verdict" text NOT NULL,
|
|
51
|
+
"verdict_source" text DEFAULT 'static' NOT NULL,
|
|
52
|
+
"severity" text,
|
|
53
|
+
"severity_override" text,
|
|
54
|
+
"confidence" text,
|
|
55
|
+
"title" text NOT NULL,
|
|
56
|
+
"category" text NOT NULL,
|
|
57
|
+
"cwe" text,
|
|
58
|
+
"file" text,
|
|
59
|
+
"line_start" integer,
|
|
60
|
+
"line_end" integer,
|
|
61
|
+
"detail" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
62
|
+
"sink_path" text,
|
|
63
|
+
"sink_content_hash" text,
|
|
64
|
+
"outside_diff" boolean DEFAULT false NOT NULL,
|
|
65
|
+
"source" text DEFAULT 'scanner' NOT NULL,
|
|
66
|
+
"state" text DEFAULT 'open' NOT NULL,
|
|
67
|
+
"resolution" text,
|
|
68
|
+
"resolved_by_user_id" text,
|
|
69
|
+
"resolved_at" timestamp with time zone,
|
|
70
|
+
"resolved_sink_hash" text,
|
|
71
|
+
"resolved_severity" text,
|
|
72
|
+
"not_seen_in_latest" boolean DEFAULT false NOT NULL,
|
|
73
|
+
"possible_duplicate_of" text,
|
|
74
|
+
"reopen_count" integer DEFAULT 0 NOT NULL,
|
|
75
|
+
"revision" integer DEFAULT 1 NOT NULL,
|
|
76
|
+
"fix_checked_scan_id" text,
|
|
77
|
+
"first_scan_id" text NOT NULL,
|
|
78
|
+
"last_seen_scan_id" text NOT NULL,
|
|
79
|
+
"first_deployment_id" text,
|
|
80
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
81
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
82
|
+
CONSTRAINT "security_findings_project_number" UNIQUE("project_id","number"),
|
|
83
|
+
CONSTRAINT "security_findings_project_fingerprint" UNIQUE("project_id","fingerprint_key"),
|
|
84
|
+
CONSTRAINT "security_findings_number" CHECK ("security_findings"."number" > 0),
|
|
85
|
+
CONSTRAINT "security_findings_verdict" CHECK (("security_findings"."verdict" IN ('confirmed', 'needs_validation'))),
|
|
86
|
+
CONSTRAINT "security_findings_verdict_source" CHECK (("security_findings"."verdict_source" IN ('static', 'runtime'))),
|
|
87
|
+
CONSTRAINT "security_findings_severity" CHECK (("security_findings"."severity" IS NULL OR ("security_findings"."severity" IN ('critical', 'high', 'medium', 'low', 'informational')))),
|
|
88
|
+
CONSTRAINT "security_findings_severity_override" CHECK (("security_findings"."severity_override" IS NULL OR ("security_findings"."severity_override" IN ('critical', 'high', 'medium', 'low', 'informational')))),
|
|
89
|
+
CONSTRAINT "security_findings_resolved_severity" CHECK (("security_findings"."resolved_severity" IS NULL OR ("security_findings"."resolved_severity" IN ('critical', 'high', 'medium', 'low', 'informational')))),
|
|
90
|
+
CONSTRAINT "security_findings_source" CHECK (("security_findings"."source" IN ('scanner', 'server'))),
|
|
91
|
+
CONSTRAINT "security_findings_state" CHECK (("security_findings"."state" IN ('open', 'resolved'))),
|
|
92
|
+
CONSTRAINT "security_findings_resolution" CHECK (("security_findings"."resolution" IS NULL) = ("security_findings"."state" = 'open') AND ("security_findings"."resolution" IS NULL OR ("security_findings"."resolution" IN ('fixed', 'false_positive', 'accepted_risk')))),
|
|
93
|
+
CONSTRAINT "security_findings_resolved_at" CHECK ("security_findings"."state" = 'open' OR "security_findings"."resolved_at" IS NOT NULL),
|
|
94
|
+
CONSTRAINT "security_findings_counts" CHECK ("security_findings"."reopen_count" >= 0 AND "security_findings"."revision" > 0),
|
|
95
|
+
CONSTRAINT "security_findings_lines" CHECK ("security_findings"."line_start" IS NULL OR "security_findings"."line_end" IS NULL OR "security_findings"."line_end" >= "security_findings"."line_start"),
|
|
96
|
+
CONSTRAINT "security_findings_detail_size" CHECK (octet_length("security_findings"."detail"::text) <= 32768)
|
|
97
|
+
);
|
|
98
|
+
--> statement-breakpoint
|
|
99
|
+
CREATE TABLE "security_memory_rejected" (
|
|
100
|
+
"project_id" text NOT NULL,
|
|
101
|
+
"fingerprint_key" text NOT NULL,
|
|
102
|
+
"reason" text NOT NULL,
|
|
103
|
+
"scan_id" text NOT NULL,
|
|
104
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
105
|
+
CONSTRAINT "security_memory_rejected_project_id_fingerprint_key_pk" PRIMARY KEY("project_id","fingerprint_key"),
|
|
106
|
+
CONSTRAINT "security_memory_rejected_reason" CHECK (octet_length("security_memory_rejected"."reason") <= 1024)
|
|
107
|
+
);
|
|
108
|
+
--> statement-breakpoint
|
|
109
|
+
CREATE TABLE "security_notifications" (
|
|
110
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
111
|
+
"kind" text NOT NULL,
|
|
112
|
+
"project_id" text,
|
|
113
|
+
"scan_ids" text[] DEFAULT '{}'::text[] NOT NULL,
|
|
114
|
+
"request_id" text,
|
|
115
|
+
"scan_bypass_id" text,
|
|
116
|
+
"dedupe_key" text NOT NULL,
|
|
117
|
+
"status" text DEFAULT 'pending' NOT NULL,
|
|
118
|
+
"attempts" integer DEFAULT 0 NOT NULL,
|
|
119
|
+
"next_attempt_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
120
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
121
|
+
"sent_at" timestamp with time zone,
|
|
122
|
+
CONSTRAINT "security_notifications_dedupe_key" UNIQUE("dedupe_key"),
|
|
123
|
+
CONSTRAINT "security_notifications_kind" CHECK (("security_notifications"."kind" IN ('findings', 'reopen', 'cap_project', 'cap_platform', 'public_held', 'public_now_public', 'public_canceled', 'scan_bypass', 'streak_project', 'streak_installation', 'digest', 'webhook'))),
|
|
124
|
+
CONSTRAINT "security_notifications_status" CHECK (("security_notifications"."status" IN ('pending', 'sent', 'failed', 'skipped'))),
|
|
125
|
+
CONSTRAINT "security_notifications_project" CHECK ("security_notifications"."kind" = 'webhook' OR ("security_notifications"."project_id" IS NULL) = ("security_notifications"."kind" IN ('cap_platform', 'streak_installation', 'digest'))),
|
|
126
|
+
CONSTRAINT "security_notifications_attempts" CHECK ("security_notifications"."attempts" >= 0)
|
|
127
|
+
);
|
|
128
|
+
--> statement-breakpoint
|
|
129
|
+
CREATE TABLE "security_platform_spend" (
|
|
130
|
+
"month" date PRIMARY KEY NOT NULL,
|
|
131
|
+
"spent_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
132
|
+
"reserved_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
133
|
+
"alerted_80_at" timestamp with time zone,
|
|
134
|
+
"alerted_100_at" timestamp with time zone,
|
|
135
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
136
|
+
CONSTRAINT "security_platform_spend_month" CHECK (EXTRACT(DAY FROM "security_platform_spend"."month") = 1),
|
|
137
|
+
CONSTRAINT "security_platform_spend_nonnegative" CHECK ("security_platform_spend"."spent_nano_usd" >= 0 AND "security_platform_spend"."reserved_nano_usd" >= 0)
|
|
138
|
+
);
|
|
139
|
+
--> statement-breakpoint
|
|
140
|
+
CREATE TABLE "security_project_events" (
|
|
141
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
142
|
+
"project_id" text NOT NULL,
|
|
143
|
+
"actor_kind" text NOT NULL,
|
|
144
|
+
"actor_user_id" text,
|
|
145
|
+
"actor_role" text,
|
|
146
|
+
"action" text NOT NULL,
|
|
147
|
+
"cap_kind" text,
|
|
148
|
+
"old_cents" integer,
|
|
149
|
+
"new_cents" integer,
|
|
150
|
+
"request_id" text,
|
|
151
|
+
"request_state" text,
|
|
152
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
153
|
+
CONSTRAINT "security_project_events_actor_kind" CHECK (("security_project_events"."actor_kind" IN ('user', 'installation_admin', 'system'))),
|
|
154
|
+
CONSTRAINT "security_project_events_action" CHECK (("security_project_events"."action" IN ('cap_changed', 'public_requested', 'public_held', 'public_passed', 'public_canceled', 'scan_bypassed', 'protection_on', 'protection_off'))),
|
|
155
|
+
CONSTRAINT "security_project_events_cap_kind" CHECK (("security_project_events"."cap_kind" IS NULL OR ("security_project_events"."cap_kind" IN ('own', 'ceiling')))),
|
|
156
|
+
CONSTRAINT "security_project_events_old_cents" CHECK (("security_project_events"."old_cents" IS NULL OR "security_project_events"."old_cents" BETWEEN 0 AND 100000000)),
|
|
157
|
+
CONSTRAINT "security_project_events_new_cents" CHECK (("security_project_events"."new_cents" IS NULL OR "security_project_events"."new_cents" BETWEEN 0 AND 100000000)),
|
|
158
|
+
CONSTRAINT "security_project_events_request_state" CHECK (("security_project_events"."request_state" IS NULL OR ("security_project_events"."request_state" IN ('waiting_scan', 'held_findings', 'held_no_result', 'needs_deploy', 'passed', 'bypassed', 'canceled'))))
|
|
159
|
+
);
|
|
160
|
+
--> statement-breakpoint
|
|
161
|
+
CREATE TABLE "security_project_spend" (
|
|
162
|
+
"project_id" text NOT NULL,
|
|
163
|
+
"month" date NOT NULL,
|
|
164
|
+
"spent_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
165
|
+
"reserved_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
166
|
+
"scans" integer DEFAULT 0 NOT NULL,
|
|
167
|
+
"alerted_80_at" timestamp with time zone,
|
|
168
|
+
"alerted_100_at" timestamp with time zone,
|
|
169
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
170
|
+
CONSTRAINT "security_project_spend_project_id_month_pk" PRIMARY KEY("project_id","month"),
|
|
171
|
+
CONSTRAINT "security_project_spend_month" CHECK (EXTRACT(DAY FROM "security_project_spend"."month") = 1),
|
|
172
|
+
CONSTRAINT "security_project_spend_nonnegative" CHECK ("security_project_spend"."spent_nano_usd" >= 0 AND "security_project_spend"."reserved_nano_usd" >= 0 AND "security_project_spend"."scans" >= 0)
|
|
173
|
+
);
|
|
174
|
+
--> statement-breakpoint
|
|
175
|
+
CREATE TABLE "security_public_requests" (
|
|
176
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
177
|
+
"project_id" text NOT NULL,
|
|
178
|
+
"state" text NOT NULL,
|
|
179
|
+
"held_reason" text,
|
|
180
|
+
"requested_by_user_id" text,
|
|
181
|
+
"requested_via" text NOT NULL,
|
|
182
|
+
"target_deployment_id" text NOT NULL,
|
|
183
|
+
"gate_scan_id" text,
|
|
184
|
+
"blockers" integer DEFAULT 0 NOT NULL,
|
|
185
|
+
"blocker_ids" text[] DEFAULT '{}'::text[] NOT NULL,
|
|
186
|
+
"cancel_cause" text,
|
|
187
|
+
"closed_by_user_id" text,
|
|
188
|
+
"closed_at" timestamp with time zone,
|
|
189
|
+
"revision" integer DEFAULT 1 NOT NULL,
|
|
190
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
191
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
192
|
+
CONSTRAINT "security_public_requests_state" CHECK (("security_public_requests"."state" IN ('waiting_scan', 'held_findings', 'held_no_result', 'needs_deploy', 'passed', 'bypassed', 'canceled'))),
|
|
193
|
+
CONSTRAINT "security_public_requests_requested_via" CHECK (("security_public_requests"."requested_via" IN ('project', 'admin', 'operator'))),
|
|
194
|
+
CONSTRAINT "security_public_requests_cancel_cause" CHECK (("security_public_requests"."cancel_cause" IS NULL) = ("security_public_requests"."state" <> 'canceled') AND ("security_public_requests"."cancel_cause" IS NULL OR ("security_public_requests"."cancel_cause" IN ('protect', 'gate_off', 'policy_off')))),
|
|
195
|
+
CONSTRAINT "security_public_requests_closed" CHECK (("security_public_requests"."closed_at" IS NULL) = ("security_public_requests"."state" IN ('waiting_scan', 'held_findings', 'held_no_result', 'needs_deploy'))),
|
|
196
|
+
CONSTRAINT "security_public_requests_blockers" CHECK ("security_public_requests"."blockers" >= 0),
|
|
197
|
+
CONSTRAINT "security_public_requests_revision" CHECK ("security_public_requests"."revision" > 0)
|
|
198
|
+
);
|
|
199
|
+
--> statement-breakpoint
|
|
200
|
+
CREATE TABLE "security_scan_bypasses" (
|
|
201
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
202
|
+
"project_id" text NOT NULL,
|
|
203
|
+
"request_id" text NOT NULL,
|
|
204
|
+
"deployment_id" text NOT NULL,
|
|
205
|
+
"actor_kind" text NOT NULL,
|
|
206
|
+
"actor_user_id" text NOT NULL,
|
|
207
|
+
"actor_role" text,
|
|
208
|
+
"reason" text NOT NULL,
|
|
209
|
+
"request_state" text NOT NULL,
|
|
210
|
+
"held_reason" text,
|
|
211
|
+
"gate_scan_id" text,
|
|
212
|
+
"blockers" integer DEFAULT 0 NOT NULL,
|
|
213
|
+
"blocker_ids" text[] DEFAULT '{}'::text[] NOT NULL,
|
|
214
|
+
"notified_at" timestamp with time zone,
|
|
215
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
216
|
+
CONSTRAINT "security_scan_bypasses_actor_kind" CHECK (("security_scan_bypasses"."actor_kind" IN ('user', 'installation_admin'))),
|
|
217
|
+
CONSTRAINT "security_scan_bypasses_reason" CHECK (char_length("security_scan_bypasses"."reason") BETWEEN 1 AND 4000),
|
|
218
|
+
CONSTRAINT "security_scan_bypasses_request_state" CHECK (("security_scan_bypasses"."request_state" IN ('waiting_scan', 'held_no_result', 'needs_deploy'))),
|
|
219
|
+
CONSTRAINT "security_scan_bypasses_blockers" CHECK ("security_scan_bypasses"."blockers" >= 0)
|
|
220
|
+
);
|
|
221
|
+
--> statement-breakpoint
|
|
222
|
+
CREATE TABLE "security_scans" (
|
|
223
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
224
|
+
"project_id" text NOT NULL,
|
|
225
|
+
"deployment_id" text,
|
|
226
|
+
"base_deployment_id" text,
|
|
227
|
+
"base_scan_id" text,
|
|
228
|
+
"status" text NOT NULL,
|
|
229
|
+
"status_reason" text,
|
|
230
|
+
"failure_cause" text,
|
|
231
|
+
"error_class" text,
|
|
232
|
+
"refusal_category" text,
|
|
233
|
+
"superseded_by_scan_id" text,
|
|
234
|
+
"trigger" text NOT NULL,
|
|
235
|
+
"public_request_id" text,
|
|
236
|
+
"tier" text,
|
|
237
|
+
"coverage" text,
|
|
238
|
+
"coverage_notes" text[] DEFAULT '{}'::text[] NOT NULL,
|
|
239
|
+
"backlog_files" integer DEFAULT 0 NOT NULL,
|
|
240
|
+
"dropped_files" integer DEFAULT 0 NOT NULL,
|
|
241
|
+
"dropped_bytes" bigint DEFAULT 0 NOT NULL,
|
|
242
|
+
"files_scanned" integer DEFAULT 0 NOT NULL,
|
|
243
|
+
"input_bytes" bigint DEFAULT 0 NOT NULL,
|
|
244
|
+
"input_prefix" text,
|
|
245
|
+
"input_r2_key" text,
|
|
246
|
+
"ledger_summary" jsonb,
|
|
247
|
+
"model_requested" text,
|
|
248
|
+
"model_used" text,
|
|
249
|
+
"engine" text,
|
|
250
|
+
"engine_version" text,
|
|
251
|
+
"skill_commit" text,
|
|
252
|
+
"policy_mode_at_enqueue" text,
|
|
253
|
+
"public_at_enqueue" boolean,
|
|
254
|
+
"attempt" integer DEFAULT 0 NOT NULL,
|
|
255
|
+
"lease_until" timestamp with time zone,
|
|
256
|
+
"model_calls" integer DEFAULT 0 NOT NULL,
|
|
257
|
+
"tokens_in" bigint DEFAULT 0 NOT NULL,
|
|
258
|
+
"tokens_out" bigint DEFAULT 0 NOT NULL,
|
|
259
|
+
"cost_nano_usd" bigint,
|
|
260
|
+
"metered_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
261
|
+
"reserved_nano_usd" bigint DEFAULT 0 NOT NULL,
|
|
262
|
+
"summary" text,
|
|
263
|
+
"first_queued_at" timestamp with time zone,
|
|
264
|
+
"queued_at" timestamp with time zone,
|
|
265
|
+
"started_at" timestamp with time zone,
|
|
266
|
+
"finished_at" timestamp with time zone,
|
|
267
|
+
"notified_at" timestamp with time zone,
|
|
268
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
269
|
+
CONSTRAINT "security_scans_status" CHECK (("security_scans"."status" IN ('pending_input', 'queued', 'running', 'succeeded', 'incomplete', 'failed', 'refused', 'timed_out', 'superseded', 'skipped', 'canceled'))),
|
|
270
|
+
CONSTRAINT "security_scans_trigger" CHECK (("security_scans"."trigger" IN ('deploy', 'recovery', 'exposure', 'rescan', 'gate', 'local', 'sweep', 'backfill', 'fallback'))),
|
|
271
|
+
CONSTRAINT "security_scans_deployment" CHECK ("security_scans"."deployment_id" IS NOT NULL OR "security_scans"."trigger" = 'local'),
|
|
272
|
+
CONSTRAINT "security_scans_failure_cause" CHECK (("security_scans"."failure_cause" IS NULL OR ("security_scans"."failure_cause" IN ('installation', 'project')))),
|
|
273
|
+
CONSTRAINT "security_scans_tier" CHECK (("security_scans"."tier" IS NULL OR ("security_scans"."tier" IN ('source_diff', 'built_diff', 'full')))),
|
|
274
|
+
CONSTRAINT "security_scans_coverage" CHECK (("security_scans"."coverage" IS NULL OR ("security_scans"."coverage" IN ('complete', 'partial')))),
|
|
275
|
+
CONSTRAINT "security_scans_engine" CHECK (("security_scans"."engine" IS NULL OR ("security_scans"."engine" IN ('void_loop', 'agent_sdk', 'codex_sdk')))),
|
|
276
|
+
CONSTRAINT "security_scans_policy_mode" CHECK (("security_scans"."policy_mode_at_enqueue" IS NULL OR ("security_scans"."policy_mode_at_enqueue" IN ('disabled', 'public', 'all')))),
|
|
277
|
+
CONSTRAINT "security_scans_running_lease" CHECK ("security_scans"."status" <> 'running' OR "security_scans"."lease_until" IS NOT NULL),
|
|
278
|
+
CONSTRAINT "security_scans_counts" CHECK ("security_scans"."attempt" >= 0 AND "security_scans"."backlog_files" >= 0 AND "security_scans"."dropped_files" >= 0 AND "security_scans"."dropped_bytes" >= 0 AND "security_scans"."files_scanned" >= 0 AND "security_scans"."input_bytes" >= 0 AND "security_scans"."model_calls" >= 0 AND "security_scans"."tokens_in" >= 0 AND "security_scans"."tokens_out" >= 0 AND "security_scans"."metered_nano_usd" >= 0 AND "security_scans"."reserved_nano_usd" >= 0 AND ("security_scans"."cost_nano_usd" IS NULL OR "security_scans"."cost_nano_usd" >= 0)),
|
|
279
|
+
CONSTRAINT "security_scans_ledger_size" CHECK ("security_scans"."ledger_summary" IS NULL OR octet_length("security_scans"."ledger_summary"::text) <= 8192),
|
|
280
|
+
CONSTRAINT "security_scans_summary_size" CHECK ("security_scans"."summary" IS NULL OR octet_length("security_scans"."summary") <= 16384)
|
|
281
|
+
);
|
|
282
|
+
--> statement-breakpoint
|
|
283
|
+
ALTER TABLE "project_security_settings" ADD CONSTRAINT "project_security_settings_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
284
|
+
ALTER TABLE "security_finding_events" ADD CONSTRAINT "security_finding_events_finding_id_security_findings_id_fk" FOREIGN KEY ("finding_id") REFERENCES "public"."security_findings"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
285
|
+
ALTER TABLE "security_finding_events" ADD CONSTRAINT "security_finding_events_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
286
|
+
ALTER TABLE "security_findings" ADD CONSTRAINT "security_findings_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
287
|
+
ALTER TABLE "security_memory_rejected" ADD CONSTRAINT "security_memory_rejected_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
288
|
+
ALTER TABLE "security_notifications" ADD CONSTRAINT "security_notifications_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
289
|
+
ALTER TABLE "security_project_events" ADD CONSTRAINT "security_project_events_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
290
|
+
ALTER TABLE "security_project_spend" ADD CONSTRAINT "security_project_spend_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
291
|
+
ALTER TABLE "security_public_requests" ADD CONSTRAINT "security_public_requests_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
292
|
+
ALTER TABLE "security_scan_bypasses" ADD CONSTRAINT "security_scan_bypasses_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
293
|
+
ALTER TABLE "security_scan_bypasses" ADD CONSTRAINT "security_scan_bypasses_request_fk" FOREIGN KEY ("request_id") REFERENCES "public"."security_public_requests"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
294
|
+
ALTER TABLE "security_scans" ADD CONSTRAINT "security_scans_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
295
|
+
CREATE INDEX "idx_security_finding_events_project_created" ON "security_finding_events" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
296
|
+
CREATE INDEX "idx_security_finding_events_finding_created" ON "security_finding_events" USING btree ("finding_id","created_at");--> statement-breakpoint
|
|
297
|
+
CREATE INDEX "idx_security_findings_urgent" ON "security_findings" USING btree ("project_id") WHERE "security_findings"."verdict" = 'confirmed' AND COALESCE("security_findings"."severity_override", "security_findings"."severity") IN ('critical', 'high') AND "security_findings"."state" = 'open';--> statement-breakpoint
|
|
298
|
+
CREATE INDEX "idx_security_findings_project_state" ON "security_findings" USING btree ("project_id","state","number");--> statement-breakpoint
|
|
299
|
+
CREATE INDEX "idx_security_memory_rejected_project_created" ON "security_memory_rejected" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
300
|
+
CREATE INDEX "idx_security_notifications_due" ON "security_notifications" USING btree ("next_attempt_at") WHERE "security_notifications"."status" = 'pending';--> statement-breakpoint
|
|
301
|
+
CREATE INDEX "idx_security_notifications_project_created" ON "security_notifications" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
302
|
+
CREATE INDEX "idx_security_project_events_project_created" ON "security_project_events" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
303
|
+
CREATE UNIQUE INDEX "security_public_requests_open_project" ON "security_public_requests" USING btree ("project_id") WHERE ("security_public_requests"."state" IN ('waiting_scan', 'held_findings', 'held_no_result', 'needs_deploy'));--> statement-breakpoint
|
|
304
|
+
CREATE INDEX "idx_security_public_requests_state_updated" ON "security_public_requests" USING btree ("state","updated_at");--> statement-breakpoint
|
|
305
|
+
CREATE INDEX "idx_security_public_requests_project_created" ON "security_public_requests" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
306
|
+
CREATE INDEX "idx_security_scan_bypasses_created" ON "security_scan_bypasses" USING btree ("created_at");--> statement-breakpoint
|
|
307
|
+
CREATE INDEX "idx_security_scan_bypasses_project_created" ON "security_scan_bypasses" USING btree ("project_id","created_at");--> statement-breakpoint
|
|
308
|
+
CREATE INDEX "idx_security_scan_bypasses_request" ON "security_scan_bypasses" USING btree ("request_id");--> statement-breakpoint
|
|
309
|
+
CREATE INDEX "idx_security_scans_project_status_finished" ON "security_scans" USING btree ("project_id","status","finished_at");--> statement-breakpoint
|
|
310
|
+
CREATE UNIQUE INDEX "security_scans_running_project" ON "security_scans" USING btree ("project_id") WHERE "security_scans"."status" = 'running';--> statement-breakpoint
|
|
311
|
+
CREATE INDEX "idx_security_scans_waiting" ON "security_scans" USING btree ("status","first_queued_at") WHERE ("security_scans"."status" IN ('pending_input', 'queued', 'running'));--> statement-breakpoint
|
|
312
|
+
CREATE INDEX "idx_security_scans_input_hold" ON "security_scans" USING btree ("input_prefix") WHERE "security_scans"."input_prefix" IS NOT NULL AND ("security_scans"."status" IN ('pending_input', 'queued'));--> statement-breakpoint
|
|
313
|
+
CREATE INDEX "idx_security_scans_deployment" ON "security_scans" USING btree ("project_id","deployment_id");
|