@hyperframes/gcp-cloud-run 0.9.52 → 0.9.53
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/Dockerfile +3 -0
- package/README.md +6 -0
- package/dist/index.js +7 -0
- package/dist/server.js +7 -0
- package/package.json +2 -2
- package/terraform/main.tf +6 -0
- package/terraform/smoke-safety.test.ts +16 -0
- package/terraform/variables.tf +6 -0
package/Dockerfile
CHANGED
|
@@ -211,6 +211,9 @@ RUN bun run --cwd packages/parsers build \
|
|
|
211
211
|
|
|
212
212
|
# Cloud Run injects PORT (default 8080). The server reads it.
|
|
213
213
|
ENV PORT=8080
|
|
214
|
+
# Render pages reach only their own project server and public addresses: not this
|
|
215
|
+
# service's port, the metadata server or other loopback and private hosts.
|
|
216
|
+
ENV PRODUCER_RESTRICT_PAGE_NETWORK=true
|
|
214
217
|
EXPOSE 8080
|
|
215
218
|
|
|
216
219
|
WORKDIR /app/packages/gcp-cloud-run
|
package/README.md
CHANGED
|
@@ -105,6 +105,12 @@ terraform -chdir=node_modules/@hyperframes/gcp-cloud-run/terraform apply \
|
|
|
105
105
|
Terraform outputs `render_bucket_name`, `service_url`, `workflow_name`, and
|
|
106
106
|
`region` — pass them straight into the SDK.
|
|
107
107
|
|
|
108
|
+
### Page network restriction
|
|
109
|
+
|
|
110
|
+
The service sets `PRODUCER_RESTRICT_PAGE_NETWORK=true`, so a rendered page reaches only its own project files and public internet addresses. Loopback, private, link-local and IPv6 addresses are refused for anything the page loads. An asset on a VPC-only host or behind private DNS is missing from the video. ffmpeg's https inputs may open only https, so an https source that redirects to http, or encrypted HLS, does not load.
|
|
111
|
+
|
|
112
|
+
Keep it on when you render compositions you did not write. To turn it off, apply the module with `-var restrict_page_network=false`, or set `TF_VAR_restrict_page_network=false` before `hyperframes cloudrun deploy`.
|
|
113
|
+
|
|
108
114
|
## Using the SDK
|
|
109
115
|
|
|
110
116
|
```ts
|
package/dist/index.js
CHANGED
|
@@ -771,6 +771,13 @@ function createApp(deps) {
|
|
|
771
771
|
const app = new Hono();
|
|
772
772
|
app.get("/healthz", (c) => c.json({ status: "ok" }));
|
|
773
773
|
app.post("/", async (c) => {
|
|
774
|
+
const sentByBrowserPage = c.req.header("origin") !== void 0;
|
|
775
|
+
if (sentByBrowserPage) {
|
|
776
|
+
return c.json(
|
|
777
|
+
{ error: "FORBIDDEN", message: "requests from a browser page are refused" },
|
|
778
|
+
403
|
|
779
|
+
);
|
|
780
|
+
}
|
|
774
781
|
let body;
|
|
775
782
|
try {
|
|
776
783
|
body = await c.req.json();
|
package/dist/server.js
CHANGED
|
@@ -768,6 +768,13 @@ function createApp(deps) {
|
|
|
768
768
|
const app = new Hono();
|
|
769
769
|
app.get("/healthz", (c) => c.json({ status: "ok" }));
|
|
770
770
|
app.post("/", async (c) => {
|
|
771
|
+
const sentByBrowserPage = c.req.header("origin") !== void 0;
|
|
772
|
+
if (sentByBrowserPage) {
|
|
773
|
+
return c.json(
|
|
774
|
+
{ error: "FORBIDDEN", message: "requests from a browser page are refused" },
|
|
775
|
+
403
|
|
776
|
+
);
|
|
777
|
+
}
|
|
771
778
|
let body;
|
|
772
779
|
try {
|
|
773
780
|
body = await c.req.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/gcp-cloud-run",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.53",
|
|
4
4
|
"description": "Google Cloud Run + Workflows adapter for HyperFrames distributed rendering — request handler, client-side SDK, and Terraform module.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"hono": "^4.13.16",
|
|
46
46
|
"puppeteer-core": "^25.8.0",
|
|
47
47
|
"tar": "^7.5.22",
|
|
48
|
-
"@hyperframes/producer": "^0.9.
|
|
48
|
+
"@hyperframes/producer": "^0.9.53"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^25.0.10",
|
package/terraform/main.tf
CHANGED
|
@@ -105,6 +105,12 @@ resource "google_cloud_run_v2_service" "render" {
|
|
|
105
105
|
value = google_storage_bucket.render.name
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
env {
|
|
109
|
+
# Render pages reach only their own project server and public addresses.
|
|
110
|
+
name = "PRODUCER_RESTRICT_PAGE_NETWORK"
|
|
111
|
+
value = var.restrict_page_network ? "true" : "false"
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
startup_probe {
|
|
109
115
|
http_get {
|
|
110
116
|
path = "/healthz"
|
|
@@ -70,3 +70,19 @@ describe("GCP smoke ownership and protocol safety", () => {
|
|
|
70
70
|
expect(cleanup).toContain("exit 7");
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
|
+
|
|
74
|
+
describe("GCP render image", () => {
|
|
75
|
+
it("holds render pages to their project server and public addresses", () => {
|
|
76
|
+
expect(dockerfile).toMatch(/^ENV PRODUCER_RESTRICT_PAGE_NETWORK=true$/m);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("lets a deployment turn the restriction off through Terraform, on by default", () => {
|
|
80
|
+
const main = readFileSync(join(import.meta.dir, "main.tf"), "utf-8");
|
|
81
|
+
const variables = readFileSync(join(import.meta.dir, "variables.tf"), "utf-8");
|
|
82
|
+
expect(main).toContain('name = "PRODUCER_RESTRICT_PAGE_NETWORK"');
|
|
83
|
+
expect(main).toContain('value = var.restrict_page_network ? "true" : "false"');
|
|
84
|
+
expect(variables).toMatch(
|
|
85
|
+
/variable "restrict_page_network" \{\s*type\s*= bool[\s\S]*?default\s*= true\s*\}/,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
});
|
package/terraform/variables.tf
CHANGED
|
@@ -47,6 +47,12 @@ variable "request_timeout_seconds" {
|
|
|
47
47
|
default = 3600
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
variable "restrict_page_network" {
|
|
51
|
+
type = bool
|
|
52
|
+
description = "Hold render pages to public addresses: loopback, private, link-local and IPv6 hosts are refused, and ffmpeg https inputs may open only https. Set false only when every composition is trusted and needs VPC-only or private-DNS hosts."
|
|
53
|
+
default = true
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
variable "min_instances" {
|
|
51
57
|
type = number
|
|
52
58
|
description = "Min Cloud Run instances. Default 0 (scale-to-zero) is cheapest but means the first render after idle pays a cold start (image pull + Chrome + bun boot, ~20-30s). Set to 1 to keep one warm if first-render latency matters."
|