From 98325ac8879bf914e04d5f51080bc2465ca5fbaf Mon Sep 17 00:00:00 2001 From: Hydra Date: Fri, 13 Nov 2026 19:07:17 +0200 Subject: [PATCH 1/2] fix(cloud): suppress installation release notices in managed dashboards --- .../notices/notices-sdk-parity.test.ts | 22 ++++- .../updates/useUpdates.requests.test.tsx | 17 ++++ apps/web/content/docs/api/notices.mdx | 4 + docs/dashboard-design.md | 3 + packages/core/src/updates/advisories.ts | 26 +++++- packages/core/test/advisory-audience.test.ts | 92 +++++++++++++++++++ .../engine/modules/notices/notice.service.ts | 13 ++- 7 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 packages/core/test/advisory-audience.test.ts diff --git a/apps/api/test/modules/notices/notices-sdk-parity.test.ts b/apps/api/test/modules/notices/notices-sdk-parity.test.ts index 39bbeb693..cc2d638e5 100644 --- a/apps/api/test/modules/notices/notices-sdk-parity.test.ts +++ b/apps/api/test/modules/notices/notices-sdk-parity.test.ts @@ -16,9 +16,29 @@ const app = new Hono().onError(handleApiError) const fetcher = ((url, init) => app.request(url as string, init)) as typeof fetch; const remote = new OpenshipClient({ baseUrl: "http://openship.test", fetch: fetcher }); const operator = new OpenshipOperatorClient({ baseUrl: "http://openship.test", internalToken: env.INTERNAL_TOKEN!, fetch: fetcher }); -afterEach(async () => { await db.delete(schema.systemNotice); }); +const originalCloudMode = env.CLOUD_MODE; +afterEach(async () => { + env.CLOUD_MODE = originalCloudMode; + await db.delete(schema.systemNotice); +}); describe("shared public notices and explicit operator administration", () => { + it.each([true, false])("filters legacy installation releases only on managed Cloud (Cloud=%s)", async (cloud) => { + env.CLOUD_MODE = cloud; + const release = await operator.notices.create({ + title: "OpenShip 0.9.0 is released", message: "Read the release notes and downloads.", severity: "recommended", targetType: "platform", + actionLabel: "View release notes", actionUrl: "https://github.com/oblien/openship/releases/tag/v0.9.0", + }); + const maintenance = await operator.notices.create({ title: "Planned maintenance", message: "Deployments may pause.", severity: "critical", actionLabel: "Service status", actionUrl: "https://status.openship.io" }); + const workload = await operator.notices.create({ title: "Update an affected app", message: "Review its runtime.", targetType: "app", targetId: "affected-app", actionLabel: "Release notes", actionUrl: "https://github.com/oblien/openship/releases/tag/v0.9.0" }); + const { advisories } = await remote.notices.list(); + const ids = advisories.map((notice) => notice.id); + expect(ids).toContain(maintenance.id); + expect(ids).toContain(workload.id); + expect(ids.includes(release.id)).toBe(!cloud); + expect((await operator.notices.listAll()).find((notice) => notice.id === release.id)?.active).toBe(true); + }); + it("preserves advisory presentation and canonical persisted timestamps across both interfaces", async () => { const actor = await seedOwner(); const ship = createShip({ platform: getPlatformKernel(), identity: { resolve: async () => ({ user: (await repos.user.findById(actor.userId))!, sessionId: "notices" }) } }); diff --git a/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx b/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx index 743d047a3..f6d4dca39 100644 --- a/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx +++ b/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx @@ -192,6 +192,23 @@ afterEach(async () => { }); describe("release check requests (#661)", () => { + it("keeps legacy release broadcasts out of a new Cloud session while retaining service and workload notices", async () => { + delete window.desktop; + deployment.selfHosted = false; + const release = { + ...critical, id: "legacy-release", severity: "recommended", announce: false, affects: "*", + title: "OpenShip 0.9.0 is released", target: { type: "platform" }, + action: { kind: "open-url", label: "View release notes", url: "https://github.com/oblien/openship/releases/tag/v0.9.0" }, + }; + const workload = { ...release, id: "workload-update", target: { type: "project", id: "affected-project" } }; + fetcher.mockImplementation(async () => new Response(JSON.stringify({ advisories: [release, critical, workload] }))); + await mount(); + expect(state[0].state?.advisories.map((notice) => notice.id)).toEqual([critical.id, workload.id]); + expect(state[0].state?.updateAvailable).toBe(false); + expect(state[0].latest).toBeNull(); + expect(localStorage.length).toBe(0); + }); + it.each(["desktop", "selfhosted", "cloud"])( "scopes signed control-plane advisories correctly in %s", async (mode) => { diff --git a/apps/web/content/docs/api/notices.mdx b/apps/web/content/docs/api/notices.mdx index a391240ca..9c60c9ffe 100644 --- a/apps/web/content/docs/api/notices.mdx +++ b/apps/web/content/docs/api/notices.mdx @@ -30,6 +30,10 @@ curl "$OPENSHIP_URL/api/notices" The response contains active `advisories`, including a title, message, severity, and optional action or target. Scheduled start and end times determine when a notice appears. +Managed Cloud excludes OpenShip installation-release and download notices from this feed. +Publish installation upgrades through the release advisory feed for Desktop and self-hosted +operators; use public notices for customer-facing maintenance, outages and workload notices. + ## Publish a notice The SDK example uses a configured `operator`, available to trusted installation code. The REST example diff --git a/docs/dashboard-design.md b/docs/dashboard-design.md index bae3d6b4f..021c92f3c 100644 --- a/docs/dashboard-design.md +++ b/docs/dashboard-design.md @@ -174,6 +174,9 @@ The banner settings menu can hide runtime security banners, including critical o for the current browser/account/workspace. Settings → Notifications restores them. Keep this visibility choice separate from security checks, notification delivery and per-project automatic-refresh consent. Operator maintenance notices stay independent. +Managed Cloud hides installation releases and upgrade prompts, including legacy operator +notices linking to OpenShip releases or downloads. Maintenance, outages and affected +workload security notices remain available to Cloud customers. When the signed advisory has no patched release in the observed runtime's major, show the required version-change guidance and open the existing saved deployment configuration. Do not offer another image refresh as a fix or silently upgrade a major. diff --git a/packages/core/src/updates/advisories.ts b/packages/core/src/updates/advisories.ts index 96d74c395..33b71b96a 100644 --- a/packages/core/src/updates/advisories.ts +++ b/packages/core/src/updates/advisories.ts @@ -5,13 +5,34 @@ import { reportCaughtError as observeCaughtError } from "../diagnostics/reporter"; import type { Advisory, AdvisoryManifest, AdvisoryMode, AdvisorySeverity, LatestRelease, UpdateState } from "./types"; -import { ADVISORY_MODES } from "./types"; +import { ADVISORY_MODES, GITHUB_REPO } from "./types"; import { changelogUrl } from "./changelog"; import { compareSemver, satisfiesRange } from "./semver"; const SEVERITY_RANK: Record = { critical: 0, recommended: 1, info: 2 }; const VALID_SEVERITY = new Set(["critical", "recommended", "info"]); +/** Installation releases belong to operators, not managed Cloud customers. + * Older operator notices have no audience metadata; their canonical release + * link still identifies them without relying on titles, severity or notice IDs. */ +export function isPlatformReleaseAdvisory(advisory: Advisory): boolean { + if (advisory.target && advisory.target.type !== "platform") return false; + if (advisory.action?.kind === "update") return true; + if (advisory.action?.kind !== "open-url" || !advisory.action.url) return false; + try { + const url = new URL(advisory.action.url); + const release = new URL(`https://github.com/${GITHUB_REPO}/releases`); + const changelog = new URL(changelogUrl()); + const within = (path: string) => url.pathname === path || url.pathname.startsWith(`${path}/`); + return ( + (url.origin === release.origin && within(release.pathname)) || + (url.origin === changelog.origin && (within(changelog.pathname) || within("/download"))) + ); + } catch { + return false; + } +} + /** * Parse + validate an UNTRUSTED manifest (fetched from GitHub raw). Malformed * entries are dropped rather than trusted — this is third-party-authored data @@ -94,6 +115,8 @@ export function parseManifest(raw: unknown): AdvisoryManifest { * is optional so a caller that genuinely doesn't know it still gets * version-matching behaviour; pass it wherever it's known (it always is in the * dashboard and the desktop app) so a desktop-only notice never lands on a VPS. + * Managed Cloud also excludes installation-release prompts regardless of legacy + * audience metadata; its software is updated by the operator. */ export function matchAdvisories( currentVersion: string, @@ -102,6 +125,7 @@ export function matchAdvisories( ): Advisory[] { return manifest.advisories .filter((a) => { + if (mode === "cloud" && isPlatformReleaseAdvisory(a)) return false; // No `modes` = every mode (legacy default). With `modes`, an unknown // caller mode can't be matched, so the advisory is skipped rather than // shown to the wrong audience. diff --git a/packages/core/test/advisory-audience.test.ts b/packages/core/test/advisory-audience.test.ts new file mode 100644 index 000000000..7b300cccf --- /dev/null +++ b/packages/core/test/advisory-audience.test.ts @@ -0,0 +1,92 @@ +import { describe, expect, it } from "vitest"; +import { matchAdvisories, resolveUpdateState } from "../src/updates/advisories"; +import type { Advisory } from "../src/updates/types"; + +const release: Advisory = { + id: "legacy-release-notice", + severity: "recommended", + announce: false, + affects: "*", + title: "OpenShip 0.9.0 is released", + message: "View the release notes and downloads.", + action: { + kind: "open-url", + label: "View release notes", + url: "https://github.com/oblien/openship/releases/tag/v0.9.0", + }, + target: { type: "platform" }, +}; +const matches = (advisory: Advisory, mode: "cloud" | "desktop" | "selfhosted") => + matchAdvisories("0.9.12", { advisories: [advisory] }, mode); + +describe("managed Cloud advisory audience", () => { + it("hides the legacy unexpired release notice on Cloud without suppressing operator installs", () => { + expect(matches(release, "cloud")).toEqual([]); + expect(matches(release, "desktop")).toEqual([release]); + expect(matches(release, "selfhosted")).toEqual([release]); + }); + + it.each([ + "https://github.com/oblien/openship/releases", + "https://github.com/oblien/openship/releases/download/v0.9.0/Openship.dmg", + "https://openship.io/changelog", + "https://openship.io/changelog/v0-9-0", + "https://openship.io/download", + ])("excludes installation-release links without depending on their title: %s", (url) => { + const notice = { + ...release, + title: "A translated announcement", + target: undefined, + action: { ...release.action!, url }, + }; + expect(matches(notice, "cloud")).toEqual([]); + expect(matches(notice, "desktop")).toEqual([notice]); + }); + + it("does not offer native installation updates to Cloud, even with critical severity", () => { + const notice: Advisory = { + ...release, + severity: "critical", + modes: ["cloud"], + action: { kind: "update", label: "Update now" }, + }; + const state = resolveUpdateState({ + currentVersion: "0.9.12", + latestRelease: null, + manifest: { advisories: [notice] }, + mode: "cloud", + }); + expect(state.advisories).toEqual([]); + }); + + it.each(["app", "project", "mail"] as const)( + "preserves affected %s notices even when they link to a release", + (type) => { + const notice = { ...release, target: { type, id: "affected-workload" } }; + expect(matches(notice, "cloud")).toEqual([notice]); + }, + ); + + it.each([ + "https://status.openship.io/maintenance", + "https://github.com/oblien/openship/security/advisories/GHSA-example", + "https://github.com/oblien/openship/releases-incident", + "https://github.com/another/project/releases/tag/v1.0.0", + "https://github.com.example.test/oblien/openship/releases/tag/v0.9.0", + "https://openship.io/changelog-incident", + "https://openship.io.example.test/changelog", + ])("keeps unrelated maintenance and security notices: %s", (url) => { + const notice = { + ...release, + severity: "critical" as const, + action: { ...release.action!, url }, + }; + expect(matches(notice, "cloud")).toEqual([notice]); + }); + + it("keeps operational notices without a release action and still respects explicit audiences", () => { + const notice = { ...release, action: undefined }; + expect(matches(notice, "cloud")).toEqual([notice]); + expect(matches({ ...notice, modes: ["selfhosted"] }, "cloud")).toEqual([]); + }); +}); diff --git a/packages/platform/src/engine/modules/notices/notice.service.ts b/packages/platform/src/engine/modules/notices/notice.service.ts index 1b75a8331..a38336f39 100644 --- a/packages/platform/src/engine/modules/notices/notice.service.ts +++ b/packages/platform/src/engine/modules/notices/notice.service.ts @@ -1,6 +1,7 @@ /** Retained notice presentation and persistence, independent of HTTP. */ import { repos } from "@repo/db"; -import { AppError, type AdvisorySeverity, type AdvisoryTarget } from "@repo/core"; +import { AppError, isPlatformReleaseAdvisory, type AdvisorySeverity, type AdvisoryTarget } from "@repo/core"; +import { env, runtimeTargetId } from "../../config/env"; import type { Static } from "@sinclair/typebox"; import type { CreateNoticeInput, NoticeAdvisorySchema } from "@repo/contracts"; @@ -49,7 +50,15 @@ function toAdvisory(n: { export async function list() { const notices = await repos.notice.listActive(); - return { advisories: notices.map(toAdvisory) }; + const advisories = notices.map(toAdvisory); + // Filter at the source so already-installed Cloud clients also stop receiving + // legacy installation-release broadcasts. Operator history remains intact. + return { + advisories: + env.CLOUD_MODE || runtimeTargetId === "cloud-saas" + ? advisories.filter((notice) => !isPlatformReleaseAdvisory(notice)) + : advisories, + }; } export async function listAll() { return repos.notice.list(); } From a8954590e48f714808ec31ea9a69213296fd0745 Mon Sep 17 00:00:00 2001 From: Hydra Date: Fri, 13 Nov 2026 19:38:51 +0200 Subject: [PATCH 2/2] fix(cloud): use only verified security in the update banner --- .../notices/notices-sdk-parity.test.ts | 22 +---- apps/dashboard/src/app/(dashboard)/layout.tsx | 7 +- .../updates/useUpdates.requests.test.tsx | 37 +++++--- .../src/components/updates/useUpdates.ts | 8 +- apps/web/content/docs/api/notices.mdx | 4 - docs/dashboard-design.md | 6 +- packages/core/src/updates/advisories.ts | 26 +----- packages/core/test/advisory-audience.test.ts | 92 ------------------- .../engine/modules/notices/notice.service.ts | 13 +-- 9 files changed, 39 insertions(+), 176 deletions(-) delete mode 100644 packages/core/test/advisory-audience.test.ts diff --git a/apps/api/test/modules/notices/notices-sdk-parity.test.ts b/apps/api/test/modules/notices/notices-sdk-parity.test.ts index cc2d638e5..39bbeb693 100644 --- a/apps/api/test/modules/notices/notices-sdk-parity.test.ts +++ b/apps/api/test/modules/notices/notices-sdk-parity.test.ts @@ -16,29 +16,9 @@ const app = new Hono().onError(handleApiError) const fetcher = ((url, init) => app.request(url as string, init)) as typeof fetch; const remote = new OpenshipClient({ baseUrl: "http://openship.test", fetch: fetcher }); const operator = new OpenshipOperatorClient({ baseUrl: "http://openship.test", internalToken: env.INTERNAL_TOKEN!, fetch: fetcher }); -const originalCloudMode = env.CLOUD_MODE; -afterEach(async () => { - env.CLOUD_MODE = originalCloudMode; - await db.delete(schema.systemNotice); -}); +afterEach(async () => { await db.delete(schema.systemNotice); }); describe("shared public notices and explicit operator administration", () => { - it.each([true, false])("filters legacy installation releases only on managed Cloud (Cloud=%s)", async (cloud) => { - env.CLOUD_MODE = cloud; - const release = await operator.notices.create({ - title: "OpenShip 0.9.0 is released", message: "Read the release notes and downloads.", severity: "recommended", targetType: "platform", - actionLabel: "View release notes", actionUrl: "https://github.com/oblien/openship/releases/tag/v0.9.0", - }); - const maintenance = await operator.notices.create({ title: "Planned maintenance", message: "Deployments may pause.", severity: "critical", actionLabel: "Service status", actionUrl: "https://status.openship.io" }); - const workload = await operator.notices.create({ title: "Update an affected app", message: "Review its runtime.", targetType: "app", targetId: "affected-app", actionLabel: "Release notes", actionUrl: "https://github.com/oblien/openship/releases/tag/v0.9.0" }); - const { advisories } = await remote.notices.list(); - const ids = advisories.map((notice) => notice.id); - expect(ids).toContain(maintenance.id); - expect(ids).toContain(workload.id); - expect(ids.includes(release.id)).toBe(!cloud); - expect((await operator.notices.listAll()).find((notice) => notice.id === release.id)?.active).toBe(true); - }); - it("preserves advisory presentation and canonical persisted timestamps across both interfaces", async () => { const actor = await seedOwner(); const ship = createShip({ platform: getPlatformKernel(), identity: { resolve: async () => ({ user: (await repos.user.findById(actor.userId))!, sessionId: "notices" }) } }); diff --git a/apps/dashboard/src/app/(dashboard)/layout.tsx b/apps/dashboard/src/app/(dashboard)/layout.tsx index abb88ac76..cc8c81f0c 100644 --- a/apps/dashboard/src/app/(dashboard)/layout.tsx +++ b/apps/dashboard/src/app/(dashboard)/layout.tsx @@ -173,10 +173,9 @@ export default async function DashboardLayout({ children }: { children: React.Re hostDomain={deploymentInfo.hostDomain} >
- {/* Update + platform-status surface — full app width, ABOVE the sidebar. - Renders nothing unless there's an advisory / platform notice (SaaS: - partial outage, maintenance) / available update / what's-new, so it - adds no chrome when idle. */} + {/* Full-width update surface. Managed Cloud shows workload security; + Desktop and self-hosted also show installation updates, operator + notices and what's new. Empty state adds no chrome. */} {children}
diff --git a/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx b/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx index f6d4dca39..611d94b00 100644 --- a/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx +++ b/apps/dashboard/src/components/updates/useUpdates.requests.test.tsx @@ -64,6 +64,7 @@ async function mount() { ); } const releaseRequests = () => fetcher.mock.calls.filter(([url]) => String(url).includes("github")); +const noticeRequests = () => fetcher.mock.calls.filter(([url]) => String(url).endsWith("/notices")); beforeEach(async () => { vi.resetModules(); @@ -154,17 +155,17 @@ describe("advisory dismissal within an app session", () => { expect(state[0].state?.advisories).toEqual([critical, next]); }); - it("also shares dismissal for operator notices in the cloud dashboard", async () => { + it("also shares dismissal for verified security notices in the cloud dashboard", async () => { delete window.desktop; deployment.selfHosted = false; - // Every consumer receives its own readable response body. - fetcher.mockImplementation( - async () => new Response(JSON.stringify({ advisories: [critical] })), - ); + feed.overview = affectedOverview; await mount(); expect(check).toHaveBeenCalledOnce(); - expect(state[0].state?.advisories).toEqual([critical]); - await act(async () => state[0].dismissAdvisory(critical.id)); + expect(state[0].state?.advisories).toEqual([ + expect.objectContaining({ title: "Affected runtime", severity: "critical" }), + ]); + const noticeId = state[0].state!.advisories[0].id; + await act(async () => state[0].dismissAdvisory(noticeId)); await act(async () => state[1].reload()); expect(state[0].state?.advisories).toEqual([]); expect(state[1].state?.advisories).toEqual([]); @@ -192,7 +193,7 @@ afterEach(async () => { }); describe("release check requests (#661)", () => { - it("keeps legacy release broadcasts out of a new Cloud session while retaining service and workload notices", async () => { + it.each([false, true])("only loads verified security for a new Cloud session (affected=%s)", async (affected) => { delete window.desktop; deployment.selfHosted = false; const release = { @@ -200,15 +201,29 @@ describe("release check requests (#661)", () => { title: "OpenShip 0.9.0 is released", target: { type: "platform" }, action: { kind: "open-url", label: "View release notes", url: "https://github.com/oblien/openship/releases/tag/v0.9.0" }, }; - const workload = { ...release, id: "workload-update", target: { type: "project", id: "affected-project" } }; - fetcher.mockImplementation(async () => new Response(JSON.stringify({ advisories: [release, critical, workload] }))); + check.mockResolvedValue({ ...snapshot, manifest: { advisories: [release] } }); + fetcher.mockImplementation(async () => new Response(JSON.stringify({ advisories: [release, critical] }))); + if (affected) feed.overview = affectedOverview; await mount(); - expect(state[0].state?.advisories.map((notice) => notice.id)).toEqual([critical.id, workload.id]); + expect(noticeRequests()).toHaveLength(0); + expect(state[0].state?.advisories).toEqual(affected + ? [expect.objectContaining({ title: "Affected runtime", severity: "critical" })] + : []); expect(state[0].state?.updateAvailable).toBe(false); expect(state[0].latest).toBeNull(); expect(localStorage.length).toBe(0); }); + it.each(["desktop", "selfhosted"])("keeps release and operator announcements for %s", async (mode) => { + if (mode === "selfhosted") delete window.desktop; + const release = { ...critical, id: "release-notice", severity: "recommended" as const }; + check.mockResolvedValue({ ...snapshot, manifest: { advisories: [release] } }); + fetcher.mockImplementation(async () => new Response(JSON.stringify({ advisories: [critical] }))); + await mount(); + expect(noticeRequests().length).toBeGreaterThan(0); + expect(state[0].state?.advisories.map((notice) => notice.id)).toEqual([critical.id, release.id]); + }); + it.each(["desktop", "selfhosted", "cloud"])( "scopes signed control-plane advisories correctly in %s", async (mode) => { diff --git a/apps/dashboard/src/components/updates/useUpdates.ts b/apps/dashboard/src/components/updates/useUpdates.ts index 120c3c79c..c4f436f34 100644 --- a/apps/dashboard/src/components/updates/useUpdates.ts +++ b/apps/dashboard/src/components/updates/useUpdates.ts @@ -304,10 +304,8 @@ function runtimeNotices(overview: SecurityOverview, scope: string): RuntimeAdvis return [...notices.values()]; } -// The SaaS advisory source: operator-pushed platform notices from our own API -// (partial outage, maintenance, upgrade advisories), returned in the SAME -// manifest shape as the GitHub advisory feed so the shared banner renders both -// identically. Same-origin on the SaaS; never throws (offline → no notices). +// Operator announcements for Desktop and self-hosted instances. Managed Cloud's +// update banner uses verified workload-security notices, so it skips this feed. async function fetchNotices(): Promise { try { const res = await fetch(`${getRestApiBaseUrl()}/notices`, { @@ -426,7 +424,7 @@ export function useUpdates(): UseUpdates { const [prefs, remote, notices] = await Promise.all([ getPrefs(), fetchRemote(requestKey), - fetchNotices(), + mode === "cloud" ? Promise.resolve({ advisories: [] }) : fetchNotices(), ]); if (!isCurrent()) return; setCurrentVersion(current); diff --git a/apps/web/content/docs/api/notices.mdx b/apps/web/content/docs/api/notices.mdx index 9c60c9ffe..a391240ca 100644 --- a/apps/web/content/docs/api/notices.mdx +++ b/apps/web/content/docs/api/notices.mdx @@ -30,10 +30,6 @@ curl "$OPENSHIP_URL/api/notices" The response contains active `advisories`, including a title, message, severity, and optional action or target. Scheduled start and end times determine when a notice appears. -Managed Cloud excludes OpenShip installation-release and download notices from this feed. -Publish installation upgrades through the release advisory feed for Desktop and self-hosted -operators; use public notices for customer-facing maintenance, outages and workload notices. - ## Publish a notice The SDK example uses a configured `operator`, available to trusted installation code. The REST example diff --git a/docs/dashboard-design.md b/docs/dashboard-design.md index 021c92f3c..c71a2d330 100644 --- a/docs/dashboard-design.md +++ b/docs/dashboard-design.md @@ -174,9 +174,9 @@ The banner settings menu can hide runtime security banners, including critical o for the current browser/account/workspace. Settings → Notifications restores them. Keep this visibility choice separate from security checks, notification delivery and per-project automatic-refresh consent. Operator maintenance notices stay independent. -Managed Cloud hides installation releases and upgrade prompts, including legacy operator -notices linking to OpenShip releases or downloads. Maintenance, outages and affected -workload security notices remain available to Cloud customers. +Managed Cloud's global update banner shows only verified workload-security notices. +It skips installation releases, upgrade prompts and the operator-announcements feed; +Desktop and self-hosted instances retain those feeds. When the signed advisory has no patched release in the observed runtime's major, show the required version-change guidance and open the existing saved deployment configuration. Do not offer another image refresh as a fix or silently upgrade a major. diff --git a/packages/core/src/updates/advisories.ts b/packages/core/src/updates/advisories.ts index 33b71b96a..96d74c395 100644 --- a/packages/core/src/updates/advisories.ts +++ b/packages/core/src/updates/advisories.ts @@ -5,34 +5,13 @@ import { reportCaughtError as observeCaughtError } from "../diagnostics/reporter"; import type { Advisory, AdvisoryManifest, AdvisoryMode, AdvisorySeverity, LatestRelease, UpdateState } from "./types"; -import { ADVISORY_MODES, GITHUB_REPO } from "./types"; +import { ADVISORY_MODES } from "./types"; import { changelogUrl } from "./changelog"; import { compareSemver, satisfiesRange } from "./semver"; const SEVERITY_RANK: Record = { critical: 0, recommended: 1, info: 2 }; const VALID_SEVERITY = new Set(["critical", "recommended", "info"]); -/** Installation releases belong to operators, not managed Cloud customers. - * Older operator notices have no audience metadata; their canonical release - * link still identifies them without relying on titles, severity or notice IDs. */ -export function isPlatformReleaseAdvisory(advisory: Advisory): boolean { - if (advisory.target && advisory.target.type !== "platform") return false; - if (advisory.action?.kind === "update") return true; - if (advisory.action?.kind !== "open-url" || !advisory.action.url) return false; - try { - const url = new URL(advisory.action.url); - const release = new URL(`https://github.com/${GITHUB_REPO}/releases`); - const changelog = new URL(changelogUrl()); - const within = (path: string) => url.pathname === path || url.pathname.startsWith(`${path}/`); - return ( - (url.origin === release.origin && within(release.pathname)) || - (url.origin === changelog.origin && (within(changelog.pathname) || within("/download"))) - ); - } catch { - return false; - } -} - /** * Parse + validate an UNTRUSTED manifest (fetched from GitHub raw). Malformed * entries are dropped rather than trusted — this is third-party-authored data @@ -115,8 +94,6 @@ export function parseManifest(raw: unknown): AdvisoryManifest { * is optional so a caller that genuinely doesn't know it still gets * version-matching behaviour; pass it wherever it's known (it always is in the * dashboard and the desktop app) so a desktop-only notice never lands on a VPS. - * Managed Cloud also excludes installation-release prompts regardless of legacy - * audience metadata; its software is updated by the operator. */ export function matchAdvisories( currentVersion: string, @@ -125,7 +102,6 @@ export function matchAdvisories( ): Advisory[] { return manifest.advisories .filter((a) => { - if (mode === "cloud" && isPlatformReleaseAdvisory(a)) return false; // No `modes` = every mode (legacy default). With `modes`, an unknown // caller mode can't be matched, so the advisory is skipped rather than // shown to the wrong audience. diff --git a/packages/core/test/advisory-audience.test.ts b/packages/core/test/advisory-audience.test.ts deleted file mode 100644 index 7b300cccf..000000000 --- a/packages/core/test/advisory-audience.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { matchAdvisories, resolveUpdateState } from "../src/updates/advisories"; -import type { Advisory } from "../src/updates/types"; - -const release: Advisory = { - id: "legacy-release-notice", - severity: "recommended", - announce: false, - affects: "*", - title: "OpenShip 0.9.0 is released", - message: "View the release notes and downloads.", - action: { - kind: "open-url", - label: "View release notes", - url: "https://github.com/oblien/openship/releases/tag/v0.9.0", - }, - target: { type: "platform" }, -}; -const matches = (advisory: Advisory, mode: "cloud" | "desktop" | "selfhosted") => - matchAdvisories("0.9.12", { advisories: [advisory] }, mode); - -describe("managed Cloud advisory audience", () => { - it("hides the legacy unexpired release notice on Cloud without suppressing operator installs", () => { - expect(matches(release, "cloud")).toEqual([]); - expect(matches(release, "desktop")).toEqual([release]); - expect(matches(release, "selfhosted")).toEqual([release]); - }); - - it.each([ - "https://github.com/oblien/openship/releases", - "https://github.com/oblien/openship/releases/download/v0.9.0/Openship.dmg", - "https://openship.io/changelog", - "https://openship.io/changelog/v0-9-0", - "https://openship.io/download", - ])("excludes installation-release links without depending on their title: %s", (url) => { - const notice = { - ...release, - title: "A translated announcement", - target: undefined, - action: { ...release.action!, url }, - }; - expect(matches(notice, "cloud")).toEqual([]); - expect(matches(notice, "desktop")).toEqual([notice]); - }); - - it("does not offer native installation updates to Cloud, even with critical severity", () => { - const notice: Advisory = { - ...release, - severity: "critical", - modes: ["cloud"], - action: { kind: "update", label: "Update now" }, - }; - const state = resolveUpdateState({ - currentVersion: "0.9.12", - latestRelease: null, - manifest: { advisories: [notice] }, - mode: "cloud", - }); - expect(state.advisories).toEqual([]); - }); - - it.each(["app", "project", "mail"] as const)( - "preserves affected %s notices even when they link to a release", - (type) => { - const notice = { ...release, target: { type, id: "affected-workload" } }; - expect(matches(notice, "cloud")).toEqual([notice]); - }, - ); - - it.each([ - "https://status.openship.io/maintenance", - "https://github.com/oblien/openship/security/advisories/GHSA-example", - "https://github.com/oblien/openship/releases-incident", - "https://github.com/another/project/releases/tag/v1.0.0", - "https://github.com.example.test/oblien/openship/releases/tag/v0.9.0", - "https://openship.io/changelog-incident", - "https://openship.io.example.test/changelog", - ])("keeps unrelated maintenance and security notices: %s", (url) => { - const notice = { - ...release, - severity: "critical" as const, - action: { ...release.action!, url }, - }; - expect(matches(notice, "cloud")).toEqual([notice]); - }); - - it("keeps operational notices without a release action and still respects explicit audiences", () => { - const notice = { ...release, action: undefined }; - expect(matches(notice, "cloud")).toEqual([notice]); - expect(matches({ ...notice, modes: ["selfhosted"] }, "cloud")).toEqual([]); - }); -}); diff --git a/packages/platform/src/engine/modules/notices/notice.service.ts b/packages/platform/src/engine/modules/notices/notice.service.ts index a38336f39..1b75a8331 100644 --- a/packages/platform/src/engine/modules/notices/notice.service.ts +++ b/packages/platform/src/engine/modules/notices/notice.service.ts @@ -1,7 +1,6 @@ /** Retained notice presentation and persistence, independent of HTTP. */ import { repos } from "@repo/db"; -import { AppError, isPlatformReleaseAdvisory, type AdvisorySeverity, type AdvisoryTarget } from "@repo/core"; -import { env, runtimeTargetId } from "../../config/env"; +import { AppError, type AdvisorySeverity, type AdvisoryTarget } from "@repo/core"; import type { Static } from "@sinclair/typebox"; import type { CreateNoticeInput, NoticeAdvisorySchema } from "@repo/contracts"; @@ -50,15 +49,7 @@ function toAdvisory(n: { export async function list() { const notices = await repos.notice.listActive(); - const advisories = notices.map(toAdvisory); - // Filter at the source so already-installed Cloud clients also stop receiving - // legacy installation-release broadcasts. Operator history remains intact. - return { - advisories: - env.CLOUD_MODE || runtimeTargetId === "cloud-saas" - ? advisories.filter((notice) => !isPlatformReleaseAdvisory(notice)) - : advisories, - }; + return { advisories: notices.map(toAdvisory) }; } export async function listAll() { return repos.notice.list(); }