Skip to content
This repository was archived by the owner on Jul 5, 2026. It is now read-only.

fix(explorer): validate chain analytics rows#275

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-unvalidated-data-in-explorer-route
Jun 26, 2026
Merged

fix(explorer): validate chain analytics rows#275
JSONbored merged 1 commit into
mainfrom
codex/fix-unvalidated-data-in-explorer-route

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The chain analytics query builders trusted top-level arrays and cast rows to typed shapes, which allowed malformed API rows to throw during SSR/client rendering and let oversized arrays amplify CPU/memory usage.

Description

  • Harden src/lib/metagraphed/queries.ts by treating /api/v1/chain/* rows as untrusted display data and adding row-level normalizers for activity, calls, signers, fee days, and fee payers.
  • Add bounded caps (MAX_CHAIN_ACTIVITY_DAYS, MAX_CHAIN_CALLS, MAX_CHAIN_SIGNERS, MAX_CHAIN_FEE_DAYS, MAX_CHAIN_FEE_PAYERS) and a helper normalizeChainRows to slice and normalize arrays before mapping into typed results.
  • Validate and coerce fields defensively using existing helpers (coerceFiniteNumber, firstString) and validate signer identifiers with isValidSs58 before producing account links.
  • Wire the chain queries (chainActivityQuery, chainCallsQuery, chainSignersQuery, chainFeesQuery) to return the normalized/capped rows instead of unvalidated casts.

Testing

  • npx prettier --check src/lib/metagraphed/queries.ts — succeeded.
  • git diff --check — succeeded.
  • npm run typecheck — blocked because project dependencies were not installed locally and type definitions for vite/client were unavailable; npm install also failed due to registry policy (403) while fetching a dependency (zod), so full type-checking could not be performed in this environment.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-ui ea6bc7d Commit Preview URL

Branch Preview URL
Jun 26 2026, 12:53 PM

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored added the maintainer-only Owner-only work — yields no Gittensor points. label Jun 26, 2026
@JSONbored JSONbored self-assigned this Jun 26, 2026
@JSONbored JSONbored merged commit 4cfe58a into main Jun 26, 2026
7 checks passed
@JSONbored JSONbored deleted the codex/fix-unvalidated-data-in-explorer-route branch June 26, 2026 12:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

aardvark codex frontend maintainer-only Owner-only work — yields no Gittensor points.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant