{"record":{"id":"45dba1f1495445e1","repo":"santifer/career-ops","slug":"careerviet-url-must-use-https-url","errorCode":null,"errorMessage":"careerviet: URL must use HTTPS: ${url}","messagePattern":"careerviet: URL must use HTTPS: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/careerviet.mjs","lineNumber":108,"sourceCode":" * apart; both wrap their <time> the same way.\n */\nconst UPDATED_DATE_RE = /Cập nhật(?:<!--[\\s\\S]*?-->)?\\s*:?\\s*(?:<\\/span>)?\\s*<time>([\\d/-]+)<\\/time>/i;\n\n/** @param {any} ctx @param {number} ms */\nfunction sleep(ctx, ms) {\n  if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);\n  return new Promise((r) => setTimeout(r, ms));\n}\n\n/** @param {string} url */\nfunction assertCareerVietUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`careerviet: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`careerviet: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`careerviet: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n/**\n * Collapse a markup fragment to its visible text.\n * @param {string} fragment\n * @returns {string}\n */\nexport function visibleText(fragment) {\n  return decodeEntities(\n    String(fragment ?? '')\n      .replace(/<!--[\\s\\S]*?-->/g, ' ')\n      .replace(/<[^>]+>/g, ' '),\n  )\n    .replace(/\\s+/g, ' ')","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/careerviet.mjs#L90-L126","documentation":"assertCareerVietUrl throws this when the URL parses but its protocol is not 'https:'. The CareerViet provider fetches only over TLS, both for transport security and as part of the SSRF guard chain; http:// or any other scheme is rejected before the request.","triggerScenarios":"A careerviet entry configured with 'http://www.careerviet.vn/...' or an internally composed URL whose scheme was mistyped or downgraded reaches assertCareerVietUrl.","commonSituations":"Writing http:// out of habit in local config; a migration/rewrite that dropped the 's'; test fixtures using http endpoints run through the production guard.","solutions":["Change the scheme to https:// in the portals entry or composing code.","Let the provider own the base URL — config should carry the site path, not an overridable scheme.","Update http:// test fixtures to https:// so they clear the guard."],"exampleFix":"// before\nconst url = 'http://www.careerviet.vn/viec-lam';\n// after\nconst url = 'https://www.careerviet.vn/viec-lam';","handlingStrategy":"validation","validationCode":"function isHttpsUrl(u) {\n  try { return new URL(u).protocol === 'https:'; } catch { return false; }\n}\nif (!isHttpsUrl(entry.careers_url)) throw new Error(`careerviet entry must use https: ${entry.careers_url}`);","typeGuard":"function isHttpsProtocol(u) { try { return new URL(u).protocol === 'https:'; } catch { return false; } }","tryCatchPattern":"try {\n  await provider.fetch(entry, ctx);\n} catch (err) {\n  if (String(err.message).startsWith('careerviet: URL must use HTTPS')) {\n    const fixed = entry.careers_url.replace(/^http:/, 'https:');\n    console.warn(`Retrying ${entry.name} with https`);\n    return provider.fetch({ ...entry, careers_url: fixed }, ctx);\n  }\n  throw err;\n}","preventionTips":["Always write https:// in careerviet entries; the site never serves plain http meaningfully.","Normalize schemes once at config load, not per request.","Keep test fixtures on https so they match the production guard."],"tags":["url","https","security","config"],"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"}