Files
insights/.semgrep/rules/devex/no-at-current-in-api-urls.yaml
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

83 lines
3.8 KiB
YAML

rules:
- id: no-at-current-in-api-urls
message: |
`@current` in API URLs is deprecated. Use explicit IDs from
`currentTeamLogic` / `currentProjectLogic` / `currentOrganizationLogic`
instead — `currentTeamIdStrict` / `currentProjectIdStrict` /
`currentOrganizationIdStrict` are non-nullable selectors that throw
if accessed before the data is loaded.
Why: `@current` is implicit server-side state. The frontend has the
resolved ID; sending it explicitly removes a class of bugs caused by
frontend/backend disagreement about which project/org is "current".
Context: PR #51110 migrated the bulk of frontend calls. A small set
of bootstrap files (teamLogic, organizationLogic, projectLogic,
welcomeDialogLogic, lib/api.ts) and the toolbar still use `@current`
intentionally — they're exempted via paths.exclude below.
This rule is currently informational (WARNING severity). Findings
are the backlog of call sites still to migrate. Once the backlog
hits zero this rule's severity will be switched to ERROR so
regressions get blocked.
languages: [typescript, javascript]
severity: WARNING
paths:
include:
- 'frontend/'
- 'products/*/frontend/'
exclude:
# tests and fixtures legitimately exercise the `@current` route
- '**/*.test.ts'
- '**/*.test.tsx'
- '**/test/**'
- '**/__tests__/**'
- '**/*.stories.tsx'
- '**/*.stories.ts'
- '**/__mocks__/**'
- '**/mocks/**'
# toolbar runs in third-party page context — separate concern
- '/frontend/src/toolbar/'
# documented bootstrap exceptions: explicit ID isn't loaded yet
- '/frontend/src/scenes/teamLogic.tsx'
- '/frontend/src/scenes/organizationLogic.tsx'
- '/frontend/src/scenes/projectLogic.ts'
- '/frontend/src/scenes/welcome/welcomeDialogLogic.ts'
- '/frontend/src/lib/api.ts'
pattern-either:
# api.<verb>($URL, ...) with @current in the URL string/template literal
- patterns:
- pattern-either:
- pattern: api.get($URL, ...)
- pattern: api.post($URL, ...)
- pattern: api.put($URL, ...)
- pattern: api.patch($URL, ...)
- pattern: api.delete($URL, ...)
- pattern: api.create($URL, ...)
- pattern: api.update($URL, ...)
- metavariable-regex:
metavariable: $URL
regex: '.*@current.*'
# Semgrep's TypeScript parser treats generic-typed calls
# (api.create<T>(...)) as a different AST shape that the patterns above
# don't match — same limitation as documented in prefer-codegen-api.yaml.
# Fall back to a regex; bounds type args by `(` so nested generics like
# api.get<PaginatedResponse<Foo>>(...) still match.
- pattern-regex: '\bapi\.(get|post|put|patch|delete|create|update)<[^(]*>\s*\([^)]*@current[^)]*'
# raw fetch with full URL
- patterns:
- pattern: fetch($URL, ...)
- metavariable-regex:
metavariable: $URL
regex: '.*@current.*'
# combineUrl for query string building
- patterns:
- pattern: combineUrl($URL, ...)
- metavariable-regex:
metavariable: $URL
regex: '.*@current.*'
metadata:
category: best-practice
subcategory:
- audit