test(indexer): negative/zero limit + depth regression coverage beyond /hooks (#317) #773
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!773
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/317-negative-limit-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #284 (the missing lower-bound test coverage I flagged in that thread).
#284 regressed on
/api/v1/hooksbecause the.min(MAX)→.clamp(1, MAX)sweep had no lower-bound test coverage — every*_limit_cappedtest only asserts the UPPER cap (limit=99999→len <= MAX). A future refactor reintroducing.min(MAX)on any route would pass CI and 500 onlimit=-1. This adds the lower-bound half (tests only, no handler changes):api_limit_lower_bound.rs—limit=-1andlimit=0→ 200 (never 500) + clamp to ≤1 row, for every SQL-backed list endpoint: pairs list/candles/trades/liquidity-events/limit-fills/placements/cancellations, tokens, traders leaderboard/trades/limit-*, oracle history, cg pairs/historical_trades (16 tests).api_orderbook_lcd_mock.rs—depth=-1/0on/cg/orderbook+/cmc/orderbook/{pair}must not 500.depthisusize, so-1is a 400 at deserialization (handler never runs) and0clamps to 1 — either way never 500 (2 tests).limit_clamp_guardrail.rs— static test (no DB) that fails if anysrc/api/**.rsline reintroduces the upper-onlyunwrap_or(…).min(…)idiom. Would have caught #284 directly. The 3 legit bare.min(uses (capacity hint, page-slice bound) lackunwrap_oron the same line and are not flagged.docs/indexer-invariants.md— numeric-caps row lists the new coverage.Verified: 16 + 2 + 1 new tests pass; existing upper-bound
*_limit_cappedsuite (security 22, hooks 4, traders 15, cg 10) unchanged.mentioned in issue #317
Security review
Commit reviewed:
971253b3a6a575ffc1bde25e6b5d4d1628bdf4cbScope: MR !773 — tests-only lower-bound regression coverage for indexer
limit/depthquery params (#317 follow-up to #284).Files reviewed
indexer/tests/api_limit_lower_bound.rs(new)indexer/tests/api_orderbook_lcd_mock.rs(2 new tests)indexer/tests/limit_clamp_guardrail.rs(new)docs/indexer-invariants.md(doc pointer update)Method
Traced attacker-controlled inputs (
limit,depth) through the exercised HTTP test paths. Confirmed this diff adds no handler, routing, auth, or SQL changes — only integration/static tests and documentation. Existing production controls (.clamp(1, MAX)on list limits;usizedeserialization +cap_orderbook_depthfor orderbook depth) are unchanged.Outcome
FINDINGS: 0 medium+
Security review: no medium+ findings on this diff.
No inline threads — nothing to flag at specific diff lines.
Notes (informational, not findings)
limit_clamp_guardrailsame-line heuristic is a useful CI guardrail but cannot catch multi-line refactors; runtime coverage inapi_limit_lower_bound.rscompensates for SQL-backed routes.mentioned in commit
ede816ee1cmentioned in merge request !806