{"record":{"id":"98a29dd0ed3893ea","repo":"santifer/career-ops","slug":"jobspresso-invalid-url-url","errorCode":null,"errorMessage":"jobspresso: invalid URL: ${url}","messagePattern":"jobspresso: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/jobspresso.mjs","lineNumber":20,"sourceCode":"/** @typedef {import('./_types.js').Provider} Provider */\n\n// Jobspresso provider - public WordPress jobs feed\n// (https://jobspresso.co/?feed=job_feed). The feed is public, no-auth,\n// and XML, so it is parsed in-process with the same tiny tag extractor\n// approach as providers/personio.mjs rather than adding an XML dependency.\n//\n// Wire in via a `job_boards:` entry with `provider: jobspresso`.\n\nconst FEED_URL = 'https://jobspresso.co/?feed=job_feed';\nconst TRUSTED_HOST = 'jobspresso.co';\n\n/** @param {string} url */\nfunction assertJobspressoUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`jobspresso: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== \"https:\")\n    throw new Error(`jobspresso: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(\n      `jobspresso: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}`,\n    );\n  }\n  return url;\n}\n\n// NaN-safe Date.parse - `|| undefined` would also coerce a valid epoch 0.\nfunction toEpochMs(value) {\n  if (!value) return undefined;\n  const parsed = Date.parse(value);\n  return Number.isNaN(parsed) ? undefined : parsed;\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/jobspresso.mjs#L2-L38","documentation":"Thrown by assertJobspressoUrl when new URL(url) throws — the supplied string is not a parseable absolute URL. The shipped fetch() path only passes the hardcoded FEED_URL constant ('https://jobspresso.co/?feed=job_feed', which always parses) through the assert, so from the public contract this branch is effectively unreachable. It is an SSRF defense-in-depth guard that activates if FEED_URL is edited to a malformed value or the assert is reused on caller input.","triggerScenarios":"A fork edit changing FEED_URL to a malformed value (missing scheme, stray characters); reusing assertJobspressoUrl on unvalidated entry/user input; a build step mangling the constant. The unmodified provider never triggers this.","commonSituations":"A developer forking the provider to a staging endpoint and typoing the URL; extending the provider to accept a configurable feed URL without pre-validation.","solutions":["Restore FEED_URL to a well-formed absolute URL: https://jobspresso.co/?feed=job_feed.","Pre-validate any caller-supplied URL before passing it to assertJobspressoUrl.","Add a unit test asserting new URL(FEED_URL) does not throw."],"exampleFix":"// before\nconst FEED_URL = 'jobspresso.co/?feed=job_feed'; // missing scheme\n\n// after\nconst FEED_URL = 'https://jobspresso.co/?feed=job_feed';","handlingStrategy":"validation","validationCode":"// Validate any caller URL (or the FEED_URL constant) before the assert throws.\nfunction parseOrThrow(url) {\n  try { return new URL(url); }\n  catch { throw new Error(`jobspresso: invalid URL: ${url}`); }\n}","typeGuard":"/** True for an absolute, parseable URL string. */\nfunction isAbsoluteUrl(value) {\n  if (typeof value !== 'string' || !value.trim()) return false;\n  try { new URL(value); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  return await jobspressoProvider.fetch(entry, ctx);\n} catch (err) {\n  if (/jobspresso: invalid URL/.test(err.message)) {\n    console.error(`jobspresso: FEED_URL constant is malformed — ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Keep FEED_URL well-formed and add a unit test asserting new URL(FEED_URL) does not throw.","Pre-validate any caller-supplied URL before passing it to the SSRF assert.","Treat the assert as defense-in-depth, not as input validation for user data."],"tags":["ssrf","url-validation","jobspresso","defense-in-depth"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}