openship 0.2.1 → 0.2.3
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 +208 -0
- package/dist/index.js +1875 -492
- package/dist/server/index.js +12463 -58813
- package/dist/server/lua/rules_guard.lua +16 -2
- package/dist/server/migrations/0050_add_service_deployment_image_digest.sql +1 -0
- package/dist/server/migrations/0051_add_update_status.sql +19 -0
- package/dist/server/migrations/0052_add_notice_target.sql +2 -0
- package/dist/server/migrations/0053_colossal_sandman.sql +14 -0
- package/dist/server/migrations/0054_add_instance_smtp.sql +5 -0
- package/dist/server/migrations/0055_rainy_klaw.sql +22 -0
- package/dist/server/migrations/0056_moaning_daredevil.sql +2 -0
- package/dist/server/migrations/meta/0050_snapshot.json +8708 -0
- package/dist/server/migrations/meta/0051_snapshot.json +8862 -0
- package/dist/server/migrations/meta/0052_snapshot.json +8874 -0
- package/dist/server/migrations/meta/0053_snapshot.json +8962 -0
- package/dist/server/migrations/meta/0054_snapshot.json +8992 -0
- package/dist/server/migrations/meta/0055_snapshot.json +9170 -0
- package/dist/server/migrations/meta/0056_snapshot.json +9191 -0
- package/dist/server/migrations/meta/_journal.json +49 -0
- package/package.json +9 -5
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
local rules = ngx.shared.rules
|
|
14
14
|
if not rules then return end
|
|
15
15
|
|
|
16
|
+
-- Rate-limit counters live in their OWN dict so a high-cardinality flood (a new
|
|
17
|
+
-- rl: key per source IP per second) can't LRU-evict the rulesets and silently
|
|
18
|
+
-- disable enforcement. Fall back to `rules` on a box whose config predates the
|
|
19
|
+
-- separate dict (still works, just shares the zone until the next reload).
|
|
20
|
+
local counters = ngx.shared.rl_counters or rules
|
|
21
|
+
|
|
16
22
|
local host = ngx.var.host
|
|
17
23
|
if not host then return end
|
|
18
24
|
|
|
@@ -78,7 +84,15 @@ if ban then
|
|
|
78
84
|
end
|
|
79
85
|
if ban.countries then
|
|
80
86
|
local cc = country_of()
|
|
81
|
-
|
|
87
|
+
-- Fail CLOSED (matches the allow-list above): if geo is unavailable we
|
|
88
|
+
-- cannot prove the client is NOT from a banned country, so block rather
|
|
89
|
+
-- than silently letting banned traffic through. A blocked host is a loud
|
|
90
|
+
-- signal to fix geo; fail-open would be a silent security hole.
|
|
91
|
+
if not cc then
|
|
92
|
+
ngx.log(ngx.WARN, "rules_guard: country ban active but geo unavailable — blocking (fail-closed)")
|
|
93
|
+
return ngx.exit(deny_status)
|
|
94
|
+
end
|
|
95
|
+
if ban.countries[cc] then return ngx.exit(deny_status) end
|
|
82
96
|
end
|
|
83
97
|
if ban.emptyUA or ban.uas then
|
|
84
98
|
local ua = ngx.var.http_user_agent
|
|
@@ -110,7 +124,7 @@ local rl = spec.rl
|
|
|
110
124
|
if rl then
|
|
111
125
|
local key = "rl:" .. host .. ":" .. (chosen.pathPrefix or "/") .. ":" .. ips
|
|
112
126
|
.. ":" .. math.floor(ngx.now())
|
|
113
|
-
local c =
|
|
127
|
+
local c = counters:incr(key, 1, 0, 2) -- init 0, 2s TTL → self-expiring buckets
|
|
114
128
|
if c and c > rl.limit then
|
|
115
129
|
ngx.header["Retry-After"] = "1"
|
|
116
130
|
return ngx.exit(rl.status)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "service_deployment" ADD COLUMN "image_digest" text;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
CREATE TABLE "update_status" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"organization_id" text NOT NULL,
|
|
4
|
+
"project_id" text NOT NULL,
|
|
5
|
+
"kind" text NOT NULL,
|
|
6
|
+
"behind" boolean DEFAULT false NOT NULL,
|
|
7
|
+
"latest_in_progress" boolean DEFAULT false NOT NULL,
|
|
8
|
+
"current_label" text,
|
|
9
|
+
"latest_label" text,
|
|
10
|
+
"detail" jsonb,
|
|
11
|
+
"checked_at" timestamp DEFAULT now() NOT NULL,
|
|
12
|
+
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
13
|
+
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
14
|
+
);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
ALTER TABLE "update_status" ADD CONSTRAINT "update_status_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "update_status" ADD CONSTRAINT "update_status_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
18
|
+
CREATE UNIQUE INDEX "uq_update_status_project" ON "update_status" USING btree ("project_id");--> statement-breakpoint
|
|
19
|
+
CREATE INDEX "idx_update_status_org_behind" ON "update_status" USING btree ("organization_id","behind");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE TABLE "billing_usage_snapshot" (
|
|
2
|
+
"organization_id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"balance" double precision,
|
|
4
|
+
"credits_used" double precision,
|
|
5
|
+
"cpu_time_minutes" double precision,
|
|
6
|
+
"memory_gb_minutes" double precision,
|
|
7
|
+
"disk_io_gb" double precision,
|
|
8
|
+
"network_gb" double precision,
|
|
9
|
+
"period_start" timestamp,
|
|
10
|
+
"period_end" timestamp,
|
|
11
|
+
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
ALTER TABLE "billing_usage_snapshot" ADD CONSTRAINT "billing_usage_snapshot_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "instance_settings" ADD COLUMN "smtp_host" text;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "instance_settings" ADD COLUMN "smtp_port" integer;--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "instance_settings" ADD COLUMN "smtp_user" text;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "instance_settings" ADD COLUMN "smtp_password_encrypted" text;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "instance_settings" ADD COLUMN "smtp_from" text;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
CREATE TABLE "server_module_status" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"organization_id" text,
|
|
4
|
+
"server_id" text NOT NULL,
|
|
5
|
+
"module_name" text NOT NULL,
|
|
6
|
+
"installed_version" text,
|
|
7
|
+
"migration_version" text,
|
|
8
|
+
"available_version" text,
|
|
9
|
+
"behind" boolean DEFAULT false NOT NULL,
|
|
10
|
+
"latest_in_progress" boolean DEFAULT false NOT NULL,
|
|
11
|
+
"current_label" text,
|
|
12
|
+
"latest_label" text,
|
|
13
|
+
"detail" jsonb,
|
|
14
|
+
"checked_at" timestamp DEFAULT now() NOT NULL,
|
|
15
|
+
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
16
|
+
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
17
|
+
);
|
|
18
|
+
--> statement-breakpoint
|
|
19
|
+
ALTER TABLE "server_module_status" ADD CONSTRAINT "server_module_status_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
20
|
+
ALTER TABLE "server_module_status" ADD CONSTRAINT "server_module_status_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
21
|
+
CREATE UNIQUE INDEX "uq_server_module_status" ON "server_module_status" USING btree ("server_id","module_name");--> statement-breakpoint
|
|
22
|
+
CREATE INDEX "idx_server_module_status_org_behind" ON "server_module_status" USING btree ("organization_id","behind");
|