{"record":{"id":"88acc97f7cd4a2f9","repo":"santifer/career-ops","slug":"himalayas-invalid-url-url","errorCode":null,"errorMessage":"himalayas: invalid URL: ${url}","messagePattern":"himalayas: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/himalayas.mjs","lineNumber":20,"sourceCode":"/** @typedef {import('./_types.js').Provider} Provider */\n\n// Himalayas provider - board-wide remote jobs API\n// (https://himalayas.app/jobs/api?limit=50). Returns { jobs: [...] }. The\n// full feed is fetched so scan.mjs's title_filter / location_filter can do\n// the local gating consistently with other zero-token board providers.\n//\n// Wire in via a `job_boards:` entry with `provider: himalayas`.\n\nconst FEED_URL = 'https://himalayas.app/jobs/api?limit=50';\nconst TRUSTED_HOST = 'himalayas.app';\n\n/** @param {string} url */\nfunction assertHimalayasUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`himalayas: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`himalayas: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`himalayas: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\nfunction cleanText(value) {\n  return typeof value === 'string' ? value.trim() : '';\n}\n\nfunction cleanHimalayasUrl(value) {\n  const raw = cleanText(value);\n  if (!raw) return '';\n  try {\n    const parsed = new URL(raw);\n    const host = parsed.hostname.toLowerCase();","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/himalayas.mjs#L2-L38","documentation":"Thrown by assertHimalayasUrl when new URL(url) throws — the supplied string is not a parseable absolute URL. In the shipped code assertHimalayasUrl is only ever called with the hardcoded constant FEED_URL ('https://himalayas.app/jobs/api?limit=50'), which always parses, so from the public contract this branch is effectively unreachable. It exists as an SSRF defense-in-depth guard: it would fire if the FEED_URL constant is edited to a malformed string, or if the function is reused to validate caller-supplied URLs.","triggerScenarios":"A fork/maintenance edit that changes FEED_URL to a malformed value (missing scheme, stray characters); reusing assertHimalayasUrl on user/entry-supplied input that is not an absolute URL; a build that mangles the constant. In the unmodified shipped provider, the constant parses cleanly so this never fires.","commonSituations":"A developer forking the provider to point at a staging endpoint and typoing the URL; extending the provider to accept entry.api and routing unvalidated input through the assert.","solutions":["Restore FEED_URL to a well-formed absolute URL (scheme + host + path), e.g. https://himalayas.app/jobs/api?limit=50.","If extending the provider to accept a configurable URL, validate/normalise it before passing to assertHimalayasUrl.","Add a unit test asserting new URL(FEED_URL) does not throw so a bad edit is caught at test time."],"exampleFix":"// before\nconst FEED_URL = 'himalayas.app/jobs/api?limit=50'; // missing scheme\n\n// after\nconst FEED_URL = 'https://himalayas.app/jobs/api?limit=50';","handlingStrategy":"validation","validationCode":"// Guard the constant at module load so a bad edit fails loud, in a test,\n// rather than at first fetch. Apply the same check before any caller URL.\nfunction parseOrThrow(url) {\n  try { return new URL(url); }\n  catch { throw new Error(`himalayas: 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 himalayasProvider.fetch(entry, ctx);\n} catch (err) {\n  if (/himalayas: invalid URL/.test(err.message)) {\n    // Only reachable if FEED_URL was edited to a malformed value — fix the constant.\n    console.error(`himalayas: FEED_URL constant is malformed — ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Keep FEED_URL a well-formed absolute URL and unit-test new URL(FEED_URL) so a typo fails at test time.","If forking to a configurable URL, validate it with new URL() in a try/catch before calling the assert.","Never route untrusted entry input through the SSRF assert without pre-validation."],"tags":["ssrf","url-validation","himalayas","defense-in-depth"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}