From ac9524a71e905ba92b38283d645074dcac43b5cf Mon Sep 17 00:00:00 2001 From: Marco Korinth Date: Thu, 20 Jun 2024 00:24:12 +0200 Subject: [PATCH 1/2] fix: 400 status response code for csaf.io domain due to missing useragent --- lib/informativeTests/shared/testURL.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/informativeTests/shared/testURL.js b/lib/informativeTests/shared/testURL.js index ccc717a..aab56f2 100644 --- a/lib/informativeTests/shared/testURL.js +++ b/lib/informativeTests/shared/testURL.js @@ -1,13 +1,27 @@ +import { createRequire } from 'module' import { request } from 'undici' +/** + * @type {{ + * name: string + * version: string + * }} + */ +const packageInfo = createRequire(import.meta.url)('../../../package.json') + /** * @param {string} url * @param {() => void} onError */ export default async function testURL(url, onError) { + // set user-agent to csaf-validator-lib/VERSION + const userAgent = `${packageInfo.name.split('/').at(-1)}/${packageInfo.version}` try { const res = await request(url, { method: 'HEAD', + headers: { + 'user-agent': userAgent + } }) if (res.statusCode < 200 || 400 <= res.statusCode) { onError() From f67ecce3399371cc6de2169baa0ea55b6c790357 Mon Sep 17 00:00:00 2001 From: Marco Korinth <103998475+MarcoKorinth@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:55:21 +0200 Subject: [PATCH 2/2] Update lib/informativeTests/shared/testURL.js Co-authored-by: tschmidtb51 <65305130+tschmidtb51@users.noreply.github.com> --- lib/informativeTests/shared/testURL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/informativeTests/shared/testURL.js b/lib/informativeTests/shared/testURL.js index aab56f2..78b3fa1 100644 --- a/lib/informativeTests/shared/testURL.js +++ b/lib/informativeTests/shared/testURL.js @@ -20,7 +20,7 @@ export default async function testURL(url, onError) { const res = await request(url, { method: 'HEAD', headers: { - 'user-agent': userAgent + 'User-Agent': userAgent } }) if (res.statusCode < 200 || 400 <= res.statusCode) {