Skip to content

refactor(index.js): validate pagination and clamp limit to 100 to prevent 1000s and preventing internal error 500#3

Open
UdayRajVadeghar wants to merge 1 commit intokunal697:masterfrom
UdayRajVadeghar:master
Open

refactor(index.js): validate pagination and clamp limit to 100 to prevent 1000s and preventing internal error 500#3
UdayRajVadeghar wants to merge 1 commit intokunal697:masterfrom
UdayRajVadeghar:master

Conversation

@UdayRajVadeghar
Copy link

  1. Page parameter validation:
  • Checks for NaN values
  • Ensures the value is a positive integer (≥ 1)
  • Validates that parseInt matches Number to reject decimals like "1.5"
  • Sets a maximum page limit of 10,000 to prevent abuse
  • Only validates when the parameter is provided (defaults to 1 if omitted)

2)Limit parameter validation:

  • Checks for NaN values
  • Ensures the value is a positive integer (≥ 1)
  • Validates that parseInt matches Number to reject decimals like "1.5"
  • Keeps the existing maximum of 100
  • Only validates when the parameter is provided (defaults to 10 if omitted)

To sum it up these changes are done:

  • Negative numbers are rejected
  • Zero is rejected
  • Non-integer decimals are rejected (e.g., "1.5")
  • Invalid strings are rejected
  • Empty strings are rejected
  • Very large page numbers are prevented

Fixes #2

…ks for page and limit parameters in /leader endpoint.
@vercel
Copy link

vercel bot commented Nov 1, 2025

@UdayRajVadeghar is attempting to deploy a commit to the kunal697's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Clamp limit query param to 100 to protect DB & site performance

1 participant