Skip to content

fix: HTTP hardening, port validation, remove dead code (L3+L4+L5+L6)#98

Open
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/l3-l4-l5-l6-cleanup-hardening
Open

fix: HTTP hardening, port validation, remove dead code (L3+L4+L5+L6)#98
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/l3-l4-l5-l6-cleanup-hardening

Conversation

@0x-SquidSol
Copy link
Copy Markdown
Contributor

Summary

Four low-severity cleanups for mainnet hardening:

L3 — HTTP server hardening:

  • Health server had no timeouts or connection limits
  • Added requestTimeout (10s), headersTimeout (5s), keepAliveTimeout (5s), maxConnections (50)

L4 — Port validation:

  • Number("abc") = NaN, Number("") = 0 caused silent misconfiguration
  • Now validates as integer 1-65535 with descriptive error

L5 — Dead code removal:

  • Deleted src/config/mainnet-markets.tsMAINNET_HYPERP_MINTS and MainnetHyperpAsset were never imported

L6 — Redundant counter removal:

  • Removed failureCount from MarketCrankState — functionally identical to consecutiveFailures
  • Replaced with consecutiveFailures in getStatus()
  • Removed dead lastSuccessfulCrankTime, lastOracleUpdateTime, and unused checkCrankHealth interval

Test plan

  • All 133 tests pass
  • Net -22 lines removed

🤖 Generated with Claude Code

L3: Add request/header/keepalive timeouts and maxConnections to the
health HTTP server to prevent slowloris-style resource exhaustion.

L4: Validate KEEPER_HEALTH_PORT as integer 1-65535. Previously
Number("abc")=NaN or Number("")=0 caused silent misconfiguration.

L5: Delete src/config/mainnet-markets.ts — exported MAINNET_HYPERP_MINTS
and MainnetHyperpAsset were never imported anywhere in the codebase.

L6: Remove failureCount from MarketCrankState — it was functionally
identical to consecutiveFailures (both increment on failure, both
reset on success). Replace with consecutiveFailures in getStatus().
Also remove dead lastSuccessfulCrankTime/lastOracleUpdateTime vars
and the unused checkCrankHealth interval (health endpoint computes
these values fresh from the markets Map).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 34 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 34 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2eab2c21-b681-4368-bb0e-4af0a7a9897c

📥 Commits

Reviewing files that changed from the base of the PR and between 3280971 and 3f0fda5.

📒 Files selected for processing (5)
  • src/config/mainnet-markets.ts
  • src/index.ts
  • src/services/crank-types.ts
  • src/services/crank.ts
  • tests/services/crank.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant