(rawUrl)
| 57 | // Security: only follow HTTPS URLs (defense-in-depth). Parse the URL instead |
| 58 | // of relying on a string prefix so every redirect is checked unambiguously. |
| 59 | function validateUrl(rawUrl) { |
| 60 | let parsed; |
| 61 | try { |
| 62 | parsed = new URL(rawUrl); |
| 63 | } catch (err) { |
| 64 | throw new Error(`Invalid download URL ${rawUrl}: ${err.message}`); |
| 65 | } |
| 66 | if (parsed.protocol !== 'https:' || !parsed.hostname || parsed.username || parsed.password) { |
| 67 | throw new Error(`Refusing non-HTTPS or credentialed URL: ${rawUrl}`); |
| 68 | } |
| 69 | return parsed.href; |
| 70 | } |
| 71 | |
| 72 | function validateExactTarMemberListing(listing, expectedNames) { |
| 73 | if (listing.includes('\0')) { |
no outgoing calls
no test coverage detected