mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
release: v1.4.2 — resurrect v1.4.1 work + bug-fix triple (#152)
* Revert "revert: roll source tree back to v1.4.0 to restore production"
This reverts commit e444a90b10.
* fix(v1.4.2): summaries.WEIGHT + medications array guards + healthcheck IPv4
Three production bugs surfaced after the v1.4.0 deploy stabilized:
1. `TypeError: undefined is not an object (evaluating 'E?.summaries.WEIGHT')`
on /dashboard and /insights for users without weight readings —
the optional chain stopped at `data` when it needed to also cover
`data.summaries`. Fixed: `data?.summaries?.WEIGHT` (one level deeper).
2. `TypeError: y?.filter is not a function` on /medications — the
medications query value was non-array (likely a stale
service-worker response from an older API shape). Replaced with
`Array.isArray(medications) ? medications : []` so the page is
immune to any future shape drift.
3. Healthcheck-induced 503 outage (already in 1.4.1 — included here
so 1.4.2 is the single coherent release). The docker-compose
healthcheck used `localhost` which busybox-wget resolves to IPv6
::1; Next.js standalone listens on IPv4 0.0.0.0 only. Pinned
to 127.0.0.1.
This release also includes everything from v1.4.1 (which never
published a clean GHCR tag): the per-section admin extraction, the
testcontainers integration suite, the Playwright + axe-core E2E
foundation, the moodLog SSRF fix, the central error-redaction in
WideEventBuilder + Glitchtip, the medical-citation drift fixes
(ESH 2023, Saint-Maurice attribution, steps source), and the docs
sync.
Co-Authored-By: Marc-André Bombeck <mbombeck@gmail.com>
This commit is contained in:
1 parent
956d29032f
commit
643e6ec3a0
59 files changed
+7318
-3844
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { moodLogCredentialsSchema } from "../moodlog";
|
||||
|
||||
describe("moodLogCredentialsSchema SSRF guard", () => {
|
||||
it("accepts a public moodLog URL", () => {
|
||||
const r = moodLogCredentialsSchema.safeParse({
|
||||
url: "https://moodlog.app",
|
||||
apiKey: "k".repeat(40),
|
||||
});
|
||||
expect(r.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects RFC1918 URLs", () => {
|
||||
for (const url of [
|
||||
"http://10.0.0.1",
|
||||
"http://192.168.1.1",
|
||||
"http://172.16.0.1",
|
||||
"http://127.0.0.1",
|
||||
]) {
|
||||
const r = moodLogCredentialsSchema.safeParse({
|
||||
url,
|
||||
apiKey: "k".repeat(40),
|
||||
});
|
||||
expect(r.success, `expected reject for ${url}`).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects link-local (cloud metadata) URLs", () => {
|
||||
const r = moodLogCredentialsSchema.safeParse({
|
||||
url: "http://169.254.169.254/latest/meta-data/iam/security-credentials/",
|
||||
apiKey: "k".repeat(40),
|
||||
});
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects localhost", () => {
|
||||
const r = moodLogCredentialsSchema.safeParse({
|
||||
url: "http://localhost:8080",
|
||||
apiKey: "k".repeat(40),
|
||||
});
|
||||
expect(r.success).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,19 @@
|
||||
import { z } from "zod/v4";
|
||||
import { isPublicUrl } from "@/lib/validations/notifications";
|
||||
|
||||
export const moodLogCredentialsSchema = z.object({
|
||||
url: z.string().url().max(500),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
.max(500)
|
||||
// SSRF guard: stored URL must point at a public host. The sync
|
||||
// worker fetches from this URL with the user's apiKey in the
|
||||
// Authorization header, so a stored RFC1918 / link-local target
|
||||
// would let any user pull cloud-metadata or local-network data
|
||||
// back through their account.
|
||||
.refine((u) => isPublicUrl(u), {
|
||||
message: "URL must point at a public host (no RFC1918 / link-local)",
|
||||
}),
|
||||
apiKey: z.string().min(1).max(200),
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user