Fail closed in listRemoteWeb when release tag HTML cannot be verified and sort entries with sortRemotesNewestFirst; bump Guest Tools agent_version and DriveShareAgentVersion to 8, single-quote escape config values with 0600 permissions, harden mount_drive_readonly (fd 3 read-only at offset 0, parent symlink/VM/byte-length checks, ENVIRON in awk); validate external HTTPS URLs via net/url in OpenURL; add regression unit tests for all three.
35 lines
908 B
Go
35 lines
908 B
Go
package app
|
|
|
|
import "testing"
|
|
|
|
func TestValidateExternalHTTPSURL(t *testing.T) {
|
|
valid := []string{
|
|
"https://github.com/Nwflower/Reims-Go",
|
|
" https://discord.gg/Tj682rW5rS ",
|
|
"https://github.com/Nwflower/Reims-Go/releases/tag/v0.2.10?foo=1#notes",
|
|
}
|
|
for _, raw := range valid {
|
|
if _, err := validateExternalHTTPSURL(raw); err != nil {
|
|
t.Errorf("validateExternalHTTPSURL(%q) unexpected error: %v", raw, err)
|
|
}
|
|
}
|
|
|
|
invalid := []string{
|
|
"",
|
|
"http://example.com",
|
|
"javascript:alert(1)",
|
|
"file:///C:/Windows/System32/calc.exe",
|
|
"https://",
|
|
"https://user:pass@example.com/path",
|
|
"https://example.com/a b",
|
|
"https://example.com/a\nfoo",
|
|
"https://example.com/\"quoted\"",
|
|
"https://example.com/a\x00b",
|
|
}
|
|
for _, raw := range invalid {
|
|
if got, err := validateExternalHTTPSURL(raw); err == nil {
|
|
t.Errorf("validateExternalHTTPSURL(%q) = %q, want error", raw, got)
|
|
}
|
|
}
|
|
}
|