Skip to content

chore: pre-revamp audit — cleanup, reliability, security, and list-data fixes - #15

Merged
Majorfi merged 16 commits into
mainfrom
chore/pre-revamp-audit-fixes
Jul 12, 2026
Merged

Majorfi merged 16 commits into
mainfrom
chore/pre-revamp-audit-fixes

Conversation

@Majorfi

@Majorfi Majorfi commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Pre-revamp audit pass: a global review of the project (excluding the lists/ data), followed by a /simplify cleanup, a /security-review, and correction of the published list data so schema validation can run as a blocking CI gate.

What's in here (5 commits)

refactor(generators) — cleanup + reliability

  • Dead code removed: unused helpers.Contains, the common/sort package, logs.Debug/Trace/Pretty, a corrupted dead yearn type block, no-op conditionals, commented-out generator entries.
  • Dedup: the 5 external-list builders collapse into one buildExternalTokenList; the 5 multicall call builders into one newCall; mapNetworkNameToChainID unified; the untyped RPC map replaced with typed GetEVMRPC/GetSolanaRPC.
  • Reliability: fail loud instead of silently wiping a list on read/unmarshal errors; a proportional-shrink guard that refuses to save when a fetch drops >50% of tokens; version bumps compare only persisted fields (ends per-run version churn); a mutex around the shared ALL_EXISTING_TOKENS map; comma-ok / nil guards against panics; a bounded NewMulticall retry; and a fix for the O(n²) velo pagination.

fix(security) — bearer token exfiltration
Choosing the credentialed request branch via strings.Contains(uri, "api.1inch.dev") on an attacker-controlled URI (Solana on-chain metadata) let a URL like https://evil.com/api.1inch.dev attach the BEARER_FOR_1INCH secret to a request sent to the attacker's host. Now the URI is parsed and the host matched exactly.

ci — hardening + validation
Third-party actions pinned to release SHAs (not @master); ACCESS_TOKEN steps gated to non-PR events; test.yml rebuilt as a secret-free build/vet/verify check; Go version unified on 1.23; verify.mjs wired into CI as a blocking gate with EVM checksum + duplicate detection; schema consolidated (single source, base58 addresses and punctuated list names allowed); package.json fixed.

docs — generators, chains, and README synced with the code.

fix(lists) — legacy DD/MM/YYYY timestamps converted to RFC3339, the empty Sushiswap name filled, and orphan/dead list files removed. All lists now pass scripts/verify.mjs.

Verification

go build ./..., go vet ./..., gofmt -l, and node scripts/verify.mjs all pass clean.

Out of scope (for the revamp)

  • The lists/5/ Goerli sub-directory still exists (its files are schema-valid). Fully retiring Goerli means removing chain 5 from the chains/ registry, which is still referenced by blockscout and ajna-static.
  • The admin ACCESS_TOKEN PAT is now SHA-pinned and PR-gated, but replacing it with a GitHub App / ruleset bypass is a repo-config change that must be done in GitHub settings.

Note

The /simplify cleanup and the P0–P3 fixes are intermixed within several files (e.g. files.go, multicall.go), so they could not be split into fully separate commits without hunk-level staging; they are grouped by disjoint file sets instead.

Majorfi added 5 commits July 11, 2026 13:21
Cleanup: delete unused helpers/types (Contains, common/sort, logs Debug/Trace/Pretty, dead yearn types), consolidate the 5 external-list builders into buildExternalTokenList, unify the multicall call builders into newCall, replace the untyped RPC map with typed GetEVMRPC/GetSolanaRPC, and dedupe mapNetworkNameToChainID.

Reliability: fail loud instead of wiping a list on read/unmarshal errors, add a proportional-shrink guard before saving, compare only persisted fields for version bumps, guard ALL_EXISTING_TOKENS with a mutex, add comma-ok/nil guards against panics, bound the NewMulticall retry loop, and fix the O(n^2) velo pagination. Also omit empty list-level logoURI.
…ration

Choosing the credentialed request branch via strings.Contains on an attacker-controlled URI (Solana on-chain metadata) let a URL like https://evil.com/api.1inch.dev attach the BEARER_FOR_1INCH secret to a request sent to the attacker's host. Parse the URI and match u.Hostname() exactly instead.
Pin the third-party push/branch-protection actions to release SHAs instead of @master, gate the ACCESS_TOKEN steps to non-PR events, and rebuild test.yml as a secret-free build/vet/verify check. Unify the Go version on 1.23 via go-version-file. Wire scripts/verify.mjs into CI (npm run verify) with EVM checksum + duplicate detection, relax the schema for base58 addresses and list names with punctuation, drop the orphan root schema.json, and fix package.json (remove missing main, add verify script).
Document the 7 missing generators, remove the empty legacy category, list all 25 registry chains, and replace the stale hardcoded chain/protocol lists in the README with pointers to the docs.
Convert legacy DD/MM/YYYY timestamps to RFC3339, fill the empty Sushiswap list name and drop its empty logoURI, and delete orphan/dead list files (wido, yearn-extended, ethereum-etherscan, polygon-zkevm, scan-*, empty Goerli 5.json) that no active generator produces. All lists now pass scripts/verify.mjs.
Comment thread .github/workflows/build-pairs.yml Fixed
Comment thread .github/workflows/build.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Majorfi and others added 5 commits July 11, 2026 13:30
Addresses the CodeQL 'Workflow does not contain permissions' finding by adding an explicit read-only permissions block. The bot push/branch-protection steps use ACCESS_TOKEN, not GITHUB_TOKEN, so contents:read is sufficient.
…t-fixes

# Conflicts:
#	generators/buildTokenList.yearn.go
Following the revert of the model omitempty, the list-level logoURI is always serialized (empty for sushiswap, whose upstream list has none). Accept an empty string alongside a valid URI in the schema, and restore the empty logoURI in the committed sushiswap lists to match generator output.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Pre-revamp audit/hardening pass across generators, verification tooling, CI workflows, and published list data, with the goal of making schema/consistency checks (including checksum + duplicate detection) reliable enough to run as a blocking CI gate.

Changes:

  • Adds/updates scripts/verify.mjs + consolidates the tokenlist schema under scripts/schema.json, wiring verification into CI via npm run verify.
  • Refactors generator internals for reliability and maintainability (typed RPC accessors, multicall retry bounds, shared external-list builder, safer decoding / nil guards, concurrency protection).
  • Normalizes/removes list data files so verification can pass (RFC3339 timestamps, fill missing list names, delete orphan/empty/dead lists).

Reviewed changes

Copilot reviewed 117 out of 123 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/verify.mjs Tightens validation (schema + checksum + duplicates) and skips non-tokenlist JSON files.
scripts/schema.json Consolidated schema; expands list-name/address allowances and adjusts optional fields.
schema.json Removes legacy top-level schema file in favor of scripts/schema.json.
README.md Documentation refresh (formatting + updated generator/chain claims).
package.json Adds npm run verify script; cleans formatting.
package-lock.json Adds lockfile to make CI installs reproducible.
go.mod Bumps Go version directive to 1.23.
generators/main.go Tweaks CLI arg handling (skip flags / popular sentinel).
generators/generators.go Removes legacy/dead generator metadata and commented entries.
generators/externalTokenList.go Introduces shared external token list rebuild helper.
generators/common/sort/sort.go Deletes unused reflection-based sort helper package.
generators/common/solana/multicallMethods.go Switches to typed Solana RPC getter + adds nil/out-value guards.
generators/common/solana/fetch.go Fixes credentialed-request host matching by parsing URL hostname.
generators/common/logs/logs.go Removes Debug/Trace/Pretty logging helpers (dead code).
generators/common/helpers/utils.go Adds sortable token key helper (GetKey).
generators/common/helpers/tokens.go Adds RWMutex around shared token cache; refactors SetToken wrapper.
generators/common/helpers/sort.go Deletes unused custom sorter.
generators/common/helpers/onChainReader.go Adds locking + dedupe + safer cache access patterns.
generators/common/helpers/files.go Hardens list read/write behavior; adds shrink-guard; avoids version churn due to non-persisted fields.
generators/common/helpers/fetch.go Fixes credentialed-request host matching by parsing URL hostname.
generators/common/ethereum/utils.go Adds type checks to prevent panics when decoding ABI return values.
generators/common/ethereum/multicallMethods.go Dedups multicall call construction via newCall.
generators/common/ethereum/multicall.go Adds bounded retry attempts when creating multicall client.
generators/common/ethereum/init.go Replaces untyped RPC map with typed EVM/Solana RPC maps + getters.
generators/buildTokenList.zkSync.go Uses chain registry logo URI instead of hardcoded URL.
generators/buildTokenList.yearn.go Removes dead/legacy type blocks and constants.
generators/buildTokenList.velo.go Fixes pagination loop behavior and avoids O(n²) dedupe work.
generators/buildTokenList.uniswap.go Switches to shared external-list builder; fixes default logo URI string.
generators/buildTokenList.uniswap-pools.go Uses typed EVM RPC getter.
generators/buildTokenList.uniswap-pairs.go Uses typed EVM RPC getter.
generators/buildTokenList.tokenRegistry.go Uses typed EVM RPC getter.
generators/buildTokenList.sushiswap.go Switches to shared external-list builder and provides name fallback.
generators/buildTokenList.sushiswap-pools.go Uses typed EVM RPC getter.
generators/buildTokenList.sushiswap-pairs.go Uses typed EVM RPC getter.
generators/buildTokenList.summary.go Refactors token counts per chain into helper; replaces deprecated ioutil usage.
generators/buildTokenList.static.filecoin.go Uses chain registry logo URI instead of hardcoded URL.
generators/buildTokenList.solanaFM.go Removes dead locals and returns directly.
generators/buildTokenList.scan.go Removes unused image collection and simplifies handler signature.
generators/buildTokenList.popular.go Avoids repeated list loads; reduces O(n²) occurrence propagation.
generators/buildTokenList.optimism.go Switches to shared external-list builder.
generators/buildTokenList.messari.go Reuses shared network->chainId mapping.
generators/buildTokenList.inkypump.go Uses chain registry logo URI instead of hardcoded URL.
generators/buildTokenList.filecoin.go Uses chain registry logo URI; minor cleanup.
generators/buildTokenList.defillama.go Reuses shared network->chainId mapping.
generators/buildTokenList.cowswap.go Switches to shared external-list builder.
generators/buildTokenList.consensys.go Switches to shared external-list builder.
generators/buildTokenList.ajna.go Uses typed EVM RPC getter.
docs/Generators.md Updates generator catalog and removes legacy generation method mention.
docs/Chains.md Updates supported chain list.
.github/workflows/test.yml Replaces secret-bearing job with secret-free build/vet + npm verify gate.
.github/workflows/build.yml Pins third-party actions by SHA; PR-gates secret-bearing steps; modernizes actions versions.
.github/workflows/build-pairs.yml Pins third-party actions by SHA; modernizes actions versions.
lists/uniswap-pools.json Converts legacy timestamp format to RFC3339.
lists/uniswap-pairs.json Converts legacy timestamp format to RFC3339.
lists/sushiswap.json Fills missing list name.
lists/sushiswap-pools.json Converts legacy timestamp format to RFC3339.
lists/sushiswap-pairs.json Converts legacy timestamp format to RFC3339.
lists/portals.json Converts legacy timestamp format to RFC3339.
lists/ledger.json Converts legacy timestamp format to RFC3339.
lists/scan-8453.json Removes dead/orphan list file.
lists/scan-1101.json Removes empty/orphan list file.
lists/scan-1.json Removes empty/orphan list file.
lists/polygon-zkevm.json Removes dead/orphan list file.
lists/5.json Removes empty/orphan list file.
lists/8453/scan-8453.json Removes dead/orphan per-chain list file.
lists/81457/sushiswap.json Fills missing list name (per-chain).
lists/59144/sushiswap.json Fills missing list name (per-chain).
lists/56/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/56/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/56/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/56/ledger.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/534352/sushiswap.json Fills missing list name (per-chain).
lists/43114/sushiswap.json Fills missing list name (per-chain).
lists/43114/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/43114/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/43114/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/42220/sushiswap.json Fills missing list name (per-chain).
lists/42161/yearn-extended.json Removes dead/orphan per-chain list file.
lists/42161/uniswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/42161/uniswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/42161/sushiswap.json Fills missing list name (per-chain).
lists/42161/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/42161/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/42161/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/324/sushiswap.json Fills missing list name (per-chain).
lists/314/sushiswap.json Fills missing list name (per-chain).
lists/250/yearn-extended.json Removes dead/orphan per-chain list file.
lists/250/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/250/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/250/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/uniswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/uniswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/sushiswap.json Fills missing list name (per-chain).
lists/137/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/ledger.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/137/etherscan.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1101/sushiswap.json Fills missing list name (per-chain).
lists/1101/polygon-zkevm.json Removes dead/orphan per-chain list file.
lists/1088/sushiswap.json Fills missing list name (per-chain).
lists/100/sushiswap.json Fills missing list name (per-chain).
lists/100/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/100/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/100/etherscan.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/10/yearn-extended.json Removes dead/orphan per-chain list file.
lists/10/uniswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/10/uniswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/10/sushiswap.json Fills missing list name (per-chain).
lists/10/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/10/etherscan.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/uniswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/uniswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/sushiswap.json Fills missing list name (per-chain).
lists/1/sushiswap-pools.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/sushiswap-pairs.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/portals.json Converts legacy timestamp format to RFC3339 (per-chain).
lists/1/ledger.json Converts legacy timestamp format to RFC3339 (per-chain).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread generators/externalTokenList.go Resolved
Comment thread scripts/verify.mjs Resolved
…ep base58 dedup case-sensitive

buildExternalTokenList passed the previously-persisted tokens to SaveTokenListInJsonFile, which merges them back into NextTokensMap and re-introduced tokens removed upstream (blocking removals and major bumps). Pass the freshly built list instead so NextTokensMap reflects only current upstream tokens.

verify.mjs lowercased every address when building the duplicate-detection key, which could flag two distinct case-sensitive base58 (Solana) addresses as duplicates. Only lowercase EVM 0x addresses.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 117 out of 123 changed files in this pull request and generated 3 comments.

Comment thread generators/main.go Resolved
Comment thread scripts/verify.mjs Resolved
Comment thread scripts/verify.mjs Resolved
…rect Ajv error path

main.go exited 0 on an unknown generator name, masking CLI misuse from CI/scripts that check exit codes; exit 1 instead. verify.mjs read the failing pointer from error.dataPath, but Ajv v7+ exposes it on error.instancePath, so validation errors printed an empty path.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 117 out of 123 changed files in this pull request and generated 2 comments.

Comment thread generators/buildTokenList.popular.go Resolved
Comment thread generators/buildTokenList.popular.go Resolved
…dress

The occurrence map used common.HexToAddress(addr).Hex() as its key, which collapses non-EVM (Solana base58) addresses to the zero address and ignores chainId, causing cross-chain collisions and wrong OccurrenceFloat values in popular.json. Use helpers.GetKey(chainID, address) instead (chainId-prefixed, checksums EVM and preserves base58).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 117 out of 123 changed files in this pull request and generated 2 comments.

Comment thread scripts/verify.mjs Resolved
Comment thread scripts/verify.mjs Resolved
… JSON parse failures

A null/non-object entry in a list's tokens array would throw on token.chainId and crash the verifier instead of reporting; guard it and use a local chainId. The JSON.parse catch referenced error.argument/reason/value (absent on SyntaxError), printing an unhelpful message; use error.message.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 117 out of 123 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

generators/common/helpers/fetch.go:33

  • The bearer token branch only checks hostname. If a non-HTTPS URL is ever provided (e.g., http://api.1inch.dev/...), this would send BEARER_FOR_1INCH over cleartext HTTP. Since this code attaches credentials, it should refuse non-HTTPS schemes for the credentialed host.
    generators/common/solana/fetch.go:32
  • The bearer token branch only checks hostname. If a non-HTTPS URL is ever provided (e.g., http://api.1inch.dev/...), this would send BEARER_FOR_1INCH over cleartext HTTP. Since this code attaches credentials, it should refuse non-HTTPS schemes for the credentialed host.

Comment thread scripts/verify.mjs Resolved
Comment thread scripts/verify.mjs Resolved
Comment thread generators/common/ethereum/multicall.go Resolved
Comment thread generators/common/ethereum/init.go Resolved
…cter address validation

Guard the 7 on-chain call sites against a nil GetEVMRPC client (Init skips chains it can't dial), so a dial failure logs and skips that chain instead of panicking. Close the ethclient in NewMulticall when GetAbi fails before retrying, to avoid leaking connections across attempts. In verify.mjs, enforce address type by chainId (base58 only on Solana, 0x only on EVM chains), and guard the Ajv address format against throwing on invalid input.

Not changed: the flagged FetchBasicInformations path does not panic — ExecuteByBatch already guards a nil Client and reading a nil map in Go is safe.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 117 out of 123 changed files in this pull request and generated 6 comments.

Comment thread scripts/verify.mjs Resolved
Comment thread generators/common/helpers/fetch.go Resolved
Comment thread generators/common/solana/fetch.go Resolved
Comment thread generators/buildTokenList.summary.go Resolved
Comment thread scripts/schema.json Resolved
Comment thread scripts/schema.json Resolved
…ema docs, stricter address typing

Handle http.NewRequest errors in the credentialed fetch branches (both fetch.go copies) so a nil request can't panic on Header.Set. Handle json.MarshalIndent/os.WriteFile errors when writing summary.json. Update the schema chainId/address descriptions to reflect that non-EVM (Solana/base58) chains are supported.

Rejected: the suggestion to replace 'new Ajv.default()' with 'new Ajv()' — verified it throws 'Ajv is not a constructor' under this project's Ajv v7 + ESM setup, so the existing form is correct and was kept.
@Majorfi
Majorfi merged commit be52690 into main Jul 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants