validateURLScheme rejects non-https URLs before any fetch (defense-in-depth).
(rawURL string)
| 506 | |
| 507 | // validateURLScheme rejects non-https URLs before any fetch (defense-in-depth). |
| 508 | func validateURLScheme(rawURL string) error { |
| 509 | parsed, err := url.Parse(rawURL) |
| 510 | if err != nil || parsed.Scheme != "https" || parsed.Host == "" || parsed.User != nil { |
| 511 | return fmt.Errorf("refusing non-https URL: %s", rawURL) |
| 512 | } |
| 513 | return nil |
| 514 | } |
| 515 | |
| 516 | // validateLoopbackURL accepts only plain HTTP to an exact loopback authority. |
| 517 | func validateLoopbackURL(rawURL string) error { |
no outgoing calls
no test coverage detected