mirror of
https://github.com/Kong/insomnia.git
synced 2026-11-05 20:43:52 -05:00
Potential fix for pull request finding 'CodeQL / Resource exhaustion'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
a93a46e7ec
commit
9c1ffcfd96
1 file changed
+3
@@ -12,8 +12,11 @@ const HTTPS_OPTIONS = {
|
||||
};
|
||||
|
||||
const MAX_REPLY_DELAY_MS = 60_000;
|
||||
const REPLY_DELAY_OPT_IN_HEADER = 'x-allow-reply-delay';
|
||||
const REPLY_DELAY_OPT_IN_VALUE = '1';
|
||||
|
||||
function delayResponse(req) {
|
||||
if (req.headers[REPLY_DELAY_OPT_IN_HEADER] !== REPLY_DELAY_OPT_IN_VALUE) return Promise.resolve();
|
||||
const requestedDelayMs = Number(req.headers['x-reply-delay-ms']);
|
||||
if (!Number.isFinite(requestedDelayMs) || requestedDelayMs <= 0) return Promise.resolve();
|
||||
const safeDelayMs = Math.min(Math.trunc(requestedDelayMs), MAX_REPLY_DELAY_MS);
|
||||
|
||||
Reference in new issue
Block a user