Files
insights/.semgrep/rules/security/tooltip-link-needs-doclink-or-interactive.test.tsx
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

72 lines
3.9 KiB
TypeScript

// @ts-nocheck
// Test fixture for tooltip-link-needs-doclink-or-interactive rule.
//
// Each test case is a single-line JSX expression assigned to a const so the
// annotation comment is on the line directly above the matched expression.
// The rule matches the Tooltip JSX element; Semgrep reports the match start
// at the line where that element's expression begins.
import { Link, Tooltip } from '@hanzo/elements'
// ─── Positive cases — rule must match ───
// Shape 1: Link inside a Fragment wrapper.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case1Fragment = <Tooltip title={<>Some prose. <Link to="https://hanzo.ai/docs/foo">Learn more</Link></>}><span>trigger</span></Tooltip>
// Shape 2: Link inside a <span> wrapper.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case2SpanWrap = <Tooltip title={<span>Body copy. Read about <Link to="https://hanzo.ai/docs/foo">the thing</Link>.</span>}><IconInfo /></Tooltip>
// Shape 3: Link inside a <div> wrapper.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case3DivWrap = <Tooltip title={<div>Paragraph one. <Link to="https://hanzo.ai/docs/foo">Docs</Link>.</div>}><IconInfo /></Tooltip>
// Shape 4: Link as the bare value of title.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case4BareLink = <Tooltip title={<Link to="https://hanzo.ai/docs/foo">Just a link</Link>}><IconInfo /></Tooltip>
// Shape 5: closeDelayMs workaround — extends the close timer but does NOT
// make the popup hoverable, so the rule must still fire.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case5CloseDelayWorkaround = <Tooltip closeDelayMs={200} title={<>Body. <Link to="https://hanzo.ai/docs/foo">Docs</Link></>}><IconInfo /></Tooltip>
// Shape 6: Link nested two layers deep — six of the eleven audited bug cases
// had this shape (nested <div> wrappers).
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case6DeeplyNested = <Tooltip title={<div className="deprecated-space-y-2"><div>Top-level prose.</div><div>Read more in the <Link to="https://hanzo.ai/docs/foo">documentation</Link>.</div></div>}><IconInfo /></Tooltip>
// Shape 7: Plain <a href> inside title — the rule covers bare anchors too.
// ruleid: tooltip-link-needs-doclink-or-interactive
const Case7PlainAnchor = <Tooltip title={<>See <a href="/somewhere">over here</a></>}><IconInfo /></Tooltip>
// ─── Negative cases — rule must NOT match ───
// Link is the trigger (children), not inside title
// ok: tooltip-link-needs-doclink-or-interactive
const OkLinkIsTrigger = <Tooltip title="Hover me"><Link to="/somewhere">Click me</Link></Tooltip>
// Plain-string title, no Link anywhere
// ok: tooltip-link-needs-doclink-or-interactive
const OkPlainStringTitle = <Tooltip title="Just a label"><span>trigger</span></Tooltip>
// Title JSX without a Link
// ok: tooltip-link-needs-doclink-or-interactive
const OkRichTextNoLink = <Tooltip title={<span className="font-mono">code-ish content</span>}><IconInfo /></Tooltip>
// docLink prop — auto-enables interactive + adds autocapture
// ok: tooltip-link-needs-doclink-or-interactive
const OkWithDocLink = <Tooltip docLink="https://hanzo.ai/docs/foo" title={<>Body. <Link to="/x">more</Link></>}><IconInfo /></Tooltip>
// interactive bare prop (sugar for interactive={true})
// ok: tooltip-link-needs-doclink-or-interactive
const OkInteractiveBare = <Tooltip interactive title={<>Body. <Link to="/x">more</Link></>}><IconInfo /></Tooltip>
// interactive={true} — explicit literal
// ok: tooltip-link-needs-doclink-or-interactive
const OkInteractiveExplicit = <Tooltip interactive={true} title={<>Body. <Link to="/x">more</Link></>}><IconInfo /></Tooltip>
// interactive={dynamic} — developer is at least signalling intent
// ok: tooltip-link-needs-doclink-or-interactive
const OkInteractiveDynamic = <Tooltip interactive={!!something} title={<>Body. <Link to="/x">more</Link></>}><IconInfo /></Tooltip>