- 集成 tauri-plugin-opener:Cargo/lib.rs/capabilities/npm 四处接线,新增 src/openExternal.ts(桌面走 opener,浏览器回退 window.open,相对路径绝对化) - 关于页 4 个链接、活动栏官网菜单、代理错误横幅 2 处健康检查链接全部改走 openExternal,桌面端可正常跳转 - 设置→外观 主题顺序调整为 深色/浅色/跟随系统 - release 二进制重编并验证(浏览器实测关于页链接可开文档页) - 附带工作区中未提交的扁平化重构现状(另一会话进行中) - homepage 落地页与文档终检通过(8787 / 与 /docs 双 200)
37 lines
989 B
Go
37 lines
989 B
Go
package proxy
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
var blockedHosts = map[string]struct{}{
|
|
"169.254.169.254": {},
|
|
"metadata.google.internal": {},
|
|
}
|
|
|
|
// ValidateURL applies MVP SSRF basics. Week 2 should add configurable CIDR
|
|
// deny-lists and DNS-rebinding protection before exposing this beyond localhost.
|
|
func ValidateURL(raw string) (*url.URL, error) {
|
|
u, err := url.Parse(raw)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("invalid url: %w", err)
|
|
}
|
|
if u.Scheme != "http" && u.Scheme != "https" {
|
|
return nil, fmt.Errorf("only http/https schemes are allowed")
|
|
}
|
|
if u.Hostname() == "" {
|
|
return nil, fmt.Errorf("url host is required")
|
|
}
|
|
host := strings.ToLower(strings.TrimSuffix(u.Hostname(), "."))
|
|
if _, blocked := blockedHosts[host]; blocked {
|
|
return nil, fmt.Errorf("blocked metadata host")
|
|
}
|
|
if ip := net.ParseIP(host); ip != nil && ip.Equal(net.ParseIP("169.254.169.254")) {
|
|
return nil, fmt.Errorf("blocked metadata address")
|
|
}
|
|
return u, nil
|
|
}
|