feat: add ssrf protection

This commit is contained in:
2026-04-23 18:52:18 +02:00
parent 542a99d23a
commit adce8abe0b
4 changed files with 349 additions and 0 deletions
+12
View File
@@ -1,4 +1,5 @@
import type { HttpCheckRequest, CheckResult } from '../types.js';
import { isBlockedURL } from '../utils/ssrf.js';
import { sleep } from './utils.js';
const DEFAULT_HEADERS: Record<string, string> = {
@@ -11,6 +12,17 @@ export async function executeHttpCheck(check: HttpCheckRequest): Promise<CheckRe
let lastError = '';
const headers = { ...DEFAULT_HEADERS, ...check.headers };
const blockedReason = isBlockedURL(check.target);
if (blockedReason) {
return {
name: check.name,
status: 'down',
responseTimeMs: 0,
error: blockedReason,
attempts: 0,
};
}
for (let i = 0; i <= check.retries; i++) {
attempts++;
const controller = new AbortController();