{"record":{"id":"c491ceb41413f773","repo":"santifer/career-ops","slug":"jobbankca-url-must-use-https-url","errorCode":null,"errorMessage":"jobbankca: URL must use HTTPS: ${url}","messagePattern":"jobbankca: URL must use HTTPS: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/jobbankca.mjs","lineNumber":100,"sourceCode":"    : [];\n  return { keywords };\n}\n\n/** @param {string} keyword @param {number} page */\nexport function buildFeedUrl(keyword, page) {\n  const params = new URLSearchParams({ searchstring: keyword, locationstring: '', page: String(page) });\n  return `${FEED_URL}?${params.toString()}`;\n}\n\n/** @param {string} url */\nexport function assertJobBankUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`jobbankca: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`jobbankca: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`jobbankca: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n// Resolve an Atom element's inner text: unwrap CDATA, else decode entities.\nfunction extractText(inner) {\n  const cdata = inner.match(/^\\s*<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>\\s*$/);\n  if (cdata) return cdata[1].trim();\n  return decodeEntities(inner).trim();\n}\n\nfunction tagText(block, tag) {\n  const m = block.match(new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)</${tag}>`, 'i'));\n  return m ? extractText(m[1]) : '';\n}\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/jobbankca.mjs#L82-L118","documentation":"assertJobBankUrl rejects any URL whose parsed protocol is not 'https:'. The Job Bank provider only talks to the trusted federal feed over TLS; http://, ftp://, or custom schemes are refused to prevent plaintext traffic and downgrade/SSRF tricks. The check runs after URL parsing succeeds and before the hostname allowlist check.","triggerScenarios":"Calling assertJobBankUrl with e.g. 'http://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed' or any non-https scheme that still parses as a valid URL.","commonSituations":"Config entry written with http:// instead of https://; a local testing URL (http://localhost) plugged into the provider config; a migration from an older non-TLS mirror URL.","solutions":["Change the URL scheme in the portals.yml job_boards entry to https://","Confirm the certificate is valid — if you used http because of TLS errors, fix the cert rather than downgrading","If you need an http test endpoint, do not use this provider; it hard-requires https"],"exampleFix":"// before\nassertJobBankUrl('http://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed');\n// after\nassertJobBankUrl('https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed');","handlingStrategy":"validation","validationCode":"function isHttpsUrl(url) {\n  try { return new URL(url).protocol === 'https:'; } catch { return false; }\n}","typeGuard":"function assertHttps(u) {\n  const p = URL.canParse(u) ? new URL(u) : null;\n  if (!p || p.protocol !== 'https:') throw new TypeError(`not https: ${u}`);\n  return p;\n}","tryCatchPattern":"try {\n  assertJobBankUrl(u);\n} catch (e) {\n  if (/must use HTTPS/.test(e.message)) {\n    u = u.replace(/^http:/, 'https:'); // or fail the entry\n  } else throw e;\n}","preventionTips":["Default all feed URLs to https:// in templates and examples","Never configure http:// mirrors for this provider","Add a config lint that flags non-https job board URLs"],"tags":["url-validation","https","ssrf-protection","security"],"backgroundTag":"invalid-url-format","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"}