Add limit to bulk hash prefix

This commit is contained in:
Ajay Ramachandran 2021-12-04 22:34:50 -05:00
parent edd11cc99c
commit e3042f7623

View file

@ -32,7 +32,8 @@ export async function getRating(req: Request, res: Response): Promise<Response>
} catch(error) {
return res.status(400).send("Bad parameter: hashPrefixes (invalid JSON)");
}
if (hashPrefixes.some((hashPrefix) => !hashPrefix || !hashPrefixTester(hashPrefix))) {
if (hashPrefixes.length === 0 || hashPrefixes.length > 75
|| hashPrefixes.some((hashPrefix) => !hashPrefix || !hashPrefixTester(hashPrefix))) {
return res.status(400).send("Hash prefix does not match format requirements."); // Exit early on faulty prefix
}