(rawUrl)
| 67 | // Security: only follow HTTPS URLs (defense-in-depth). Parse the URL instead |
| 68 | // of relying on a string prefix so every redirect is checked unambiguously. |
| 69 | function validateUrl(rawUrl) { |
| 70 | let parsed; |
| 71 | try { |
| 72 | parsed = new URL(rawUrl); |
| 73 | } catch (err) { |
| 74 | throw new Error(`Invalid download URL ${rawUrl}: ${err.message}`); |
| 75 | } |
| 76 | if (parsed.protocol !== 'https:' || !parsed.hostname || parsed.username || parsed.password) { |
| 77 | throw new Error(`Refusing non-HTTPS or credentialed URL: ${rawUrl}`); |
| 78 | } |
| 79 | return parsed.href; |
| 80 | } |
| 81 | |
| 82 | // Plain HTTP is accepted only for an exact loopback authority, as in |
| 83 | // install.sh; such a fetch uses no proxy and follows no redirect. |
no outgoing calls
no test coverage detected