From 2b0a18c4ca147911e70c12c43c72051187a878e6 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi Date: Fri, 25 Sep 2026 19:14:51 +0530 Subject: [PATCH 1/4] Public pages can be reported, and staff can take one down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A page set to "Anyone with the link" is served to anonymous viewers from a domain that is not ours to explain away, and until now nobody could tell us a page was malicious and nobody but its author could remove it. The only takedown path was asking the author or hand-deleting the R2 manifest. Reporting and takedown stay separate on purpose. `page.report` is open to anyone who can open the page and only writes a row; one report has never been able to unpublish anything, or the button becomes a way to silence a competitor's page from a browser with no account. Taking a page down is an adminProcedure call a person (or the triage agent acting as one) makes after looking. Takedown drops the manifest rather than the data. The usercontent Worker trusts nothing else, so a page with no manifest 404s for every caller — including someone holding a ticket minted before the decision — while the row, its versions and its objects stay put for review or reversal. writePageManifest is where that is enforced, so no later publish or visibility toggle can quietly resurrect the page. Reporter addresses are stored as a keyed HMAC, never raw: the rate limiter and any grouping of a flooder's reports work off the hash, and a leaked reports table does not hand out the addresses of everyone who reported. Also adds the disclaimer the public viewer never had, and a Report control in its chrome. Migration is additive — a new page_reports table and three nullable columns on pages. Rehearsed under concurrent reads and inserts on a Neon branch of production, 3 of 3 with no deadlock or lock timeout; pages is 1.3 MB / 1,819 rows and auth.users takes only a brief ShareRowExclusive from the FK. SUPER-2452 --- .../PublicPageView/PublicPageView.tsx | 11 +- .../ReportPageDialog/ReportPageDialog.tsx | 191 + .../components/ReportPageDialog/constants.ts | 32 + .../components/ReportPageDialog/index.ts | 1 + .../0127_page_reports_and_takedown.sql | 28 + packages/db/drizzle/meta/0127_snapshot.json | 11336 ++++++++++++++++ packages/db/drizzle/meta/_journal.json | 7 + packages/db/src/schema/enums.ts | 17 + packages/db/src/schema/schema.ts | 57 + packages/i18n/locales/cs/messages.po | 78 + packages/i18n/locales/de/messages.po | 78 + packages/i18n/locales/en/messages.po | 78 + packages/i18n/locales/es/messages.po | 78 + packages/i18n/locales/fr/messages.po | 78 + packages/i18n/locales/id/messages.po | 78 + packages/i18n/locales/it/messages.po | 78 + packages/i18n/locales/ja/messages.po | 78 + packages/i18n/locales/ko/messages.po | 78 + packages/i18n/locales/nl/messages.po | 78 + packages/i18n/locales/pl/messages.po | 78 + packages/i18n/locales/pt-BR/messages.po | 78 + packages/i18n/locales/ru/messages.po | 78 + packages/i18n/locales/tr/messages.po | 78 + packages/i18n/locales/vi/messages.po | 78 + packages/i18n/locales/zh-CN/messages.po | 78 + packages/i18n/locales/zh-TW/messages.po | 78 + packages/i18n/src/server-errors.ts | 30 + packages/trpc/src/router/page/access.test.ts | 15 + packages/trpc/src/router/page/access.ts | 7 + packages/trpc/src/router/page/page.ts | 3 + packages/trpc/src/router/page/preview.test.ts | 24 +- packages/trpc/src/router/page/preview.ts | 3 +- packages/trpc/src/router/page/reports.ts | 259 + packages/trpc/src/router/page/schema.test.ts | 43 + packages/trpc/src/router/page/schema.ts | 28 + packages/trpc/src/router/page/storage.ts | 5 + 36 files changed, 13416 insertions(+), 7 deletions(-) create mode 100644 apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx create mode 100644 apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/constants.ts create mode 100644 apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/index.ts create mode 100644 packages/db/drizzle/0127_page_reports_and_takedown.sql create mode 100644 packages/db/drizzle/meta/0127_snapshot.json create mode 100644 packages/trpc/src/router/page/reports.ts diff --git a/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx b/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx index 80f479905c4..cc41ab7b88f 100644 --- a/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx +++ b/apps/web/src/app/page/[slug]/components/PublicPageView/PublicPageView.tsx @@ -6,6 +6,7 @@ import { PageFrame } from "@superset/ui/page-comments"; import { Globe } from "lucide-react"; import Link from "next/link"; import { OpenInSupersetButton } from "../OpenInSupersetButton"; +import { ReportPageDialog } from "./components/ReportPageDialog"; interface PublicPageViewProps { title: string; @@ -30,7 +31,8 @@ export function PublicPageView({ aria-label={t({ message: "Shared with everyone" })} /> {title} -
+
+ {signedIn ? ( ) : ( @@ -51,6 +53,13 @@ export function PublicPageView({
+ +
+ + This page was published by a Superset user. Its contents are + unverified. + +
); } diff --git a/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx b/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx new file mode 100644 index 00000000000..2462ccabb64 --- /dev/null +++ b/apps/web/src/app/page/[slug]/components/PublicPageView/components/ReportPageDialog/ReportPageDialog.tsx @@ -0,0 +1,191 @@ +"use client"; + +import { useLingui as useTranslation } from "@lingui/react"; +import { Trans, useLingui } from "@lingui/react/macro"; +import { Button } from "@superset/ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@superset/ui/dialog"; +import { Input } from "@superset/ui/input"; +import { Label } from "@superset/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@superset/ui/select"; +import { Textarea } from "@superset/ui/textarea"; +import { useMutation } from "@tanstack/react-query"; +import { Flag } from "lucide-react"; +import { useState } from "react"; +import { useTRPC } from "@/trpc/react"; +import { REPORT_REASONS, type ReportReason } from "./constants"; + +interface ReportPageDialogProps { + slug: string; + signedIn: boolean; +} + +export function ReportPageDialog({ slug, signedIn }: ReportPageDialogProps) { + const { t } = useLingui(); + const { _: translate } = useTranslation(); + const trpc = useTRPC(); + const [open, setOpen] = useState(false); + const [reason, setReason] = useState(""); + const [details, setDetails] = useState(""); + const [email, setEmail] = useState(""); + + const report = useMutation(trpc.page.report.mutationOptions()); + + const reset = () => { + setReason(""); + setDetails(""); + setEmail(""); + report.reset(); + }; + + const submit = () => { + if (!reason) return; + report.mutate({ + slug, + reason, + details: details.trim() || undefined, + reporterEmail: !signedIn && email.trim() ? email.trim() : undefined, + }); + }; + + return ( + { + setOpen(next); + if (!next) reset(); + }} + > + + + + + {report.isSuccess ? ( + <> + + + Thanks, we got it + + + + Someone on the Superset team will review this page. We only + follow up if we need more from you. + + + + + + + + ) : ( + <> + + + Report this page + + + + Tell us what is wrong with it. Reporting does not remove the + page on its own. + + + + +
+
+ + +
+ +
+ +