{"record":{"id":"7f27540777bf4ef6","repo":"santifer/career-ops","slug":"arbeitnow-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"arbeitnow: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}","messagePattern":"arbeitnow: untrusted hostname \"(.+?)\" — must be (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/arbeitnow.mjs","lineNumber":34,"sourceCode":"// Wire in via a `job_boards:` entry with `provider: arbeitnow`.\n\nconst FEED_BASE = 'https://www.arbeitnow.com/api/job-board-api';\nconst TRUSTED_HOST = 'www.arbeitnow.com';\nconst PER_PAGE = 100;\nconst DEFAULT_MAX_PAGES = 3;\nconst MAX_PAGES_CAP = 50;\n\n/** @param {string} url */\nfunction assertArbeitnowUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`arbeitnow: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`arbeitnow: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`arbeitnow: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n/** Resolve the page cap: a positive integer `max_pages` on the entry, capped. */\nfunction resolveMaxPages(entry) {\n  const v = entry?.max_pages;\n  if (Number.isInteger(v) && v > 0) return Math.min(v, MAX_PAGES_CAP);\n  return DEFAULT_MAX_PAGES;\n}\n\n/**\n * Normalize a single Arbeitnow job. Exported for unit tests.\n *\n * Field mapping → the normalized Job shape:\n *   - title:    `title`, trimmed (items without one are dropped).\n *   - url:      `url` — an absolute `https:` posting URL host-locked to\n *               www.arbeitnow.com (an off-host or non-https URL is untrusted and","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/arbeitnow.mjs#L16-L52","documentation":"assertArbeitnowUrl's final check requires the hostname to equal the hardcoded TRUSTED_HOST ('www.arbeitnow.com'). A URL that parses and is HTTPS but points at a different host (arbeitnow.com without www, a mirror, a lookalike) throws this. It prevents the provider from being pointed at an arbitrary server.","triggerScenarios":"URL host is not exactly 'www.arbeitnow.com' — e.g. 'https://arbeitnow.com/api/job-board-api' (missing www), a proxy/mirror host like 'arbeitnow.internal' or 'localhost', or a typo'd host ('wwww.arbeitnow.com').","commonSituations":"Dropping the www when hand-typing the API URL; pointing the provider at a corporate proxy or local stub during development; DNS-based redirects that don't change the URL string but a config rewrite did; forks swapping in a mirror endpoint.","solutions":["Use the canonical host https://www.arbeitnow.com/api/job-board-api (FEED_BASE) — note the www is required by this validator.","For local testing, stub ctx.fetchJson rather than substituting localhost URLs into the validator.","If a mirror is genuinely needed, change TRUSTED_HOST/FEED_BASE in providers/arbeitnow.mjs deliberately, with review — never bypass the check.","Copy URLs from the provider constants instead of typing them, to avoid www/typo drift."],"exampleFix":"// before\nconst url = 'https://arbeitnow.com/api/job-board-api?page=1'; // no www\n// after\nconst url = 'https://www.arbeitnow.com/api/job-board-api?page=1';","handlingStrategy":"validation","validationCode":"const u = new URL(url);\nif (u.hostname !== 'www.arbeitnow.com') throw new Error(`untrusted host ${u.hostname} — use www.arbeitnow.com`);","typeGuard":"function isTrustedArbeitnowUrl(s) {\n  try { const u = new URL(s); return u.protocol === 'https:' && u.hostname === 'www.arbeitnow.com'; } catch { return false; }\n}","tryCatchPattern":"try {\n  await provider.fetch(entry, ctx);\n} catch (err) {\n  if (String(err.message).includes('untrusted hostname')) {\n    console.error(`Host mismatch (${err.message}) — remember the canonical host includes \"www\"`);\n  }\n  throw err;\n}","preventionTips":["Use FEED_BASE verbatim; the validator requires the www. subdomain exactly.","Never point the provider at proxies, mirrors, or localhost — stub ctx.fetchJson for tests.","Treat a hostname mismatch in production as a possible redirect/rewrite compromise, not just a typo."],"tags":["url","ssrf","security","allowlist"],"backgroundTag":"invalid-url","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}