mirror of
https://github.com/GabrielVidal1/ask-form.git
synced 2026-12-04 18:17:27 +01:00
- Change default ASK_FORM_AUTO_UPGRADE to notify, enforce HTTPS/no-downgrade redirects, block pre-release auto-installs, and run smoke tests with an empty environment - Validate browser URLs (http/https only) and relay URLs, write secrets atomically at 0600, add --token-file/--key-file, and harden systemd/launchd unit generation - Enforce TLS 1.2 + strict semver tag validation in install.sh and npm publish scripts - Validate and quote origins/keys in Claude.ai and MCP plugin zips - Pin GitHub Actions to commit SHAs, scope job permissions, and document relay trust boundaries
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package update
|
|
|
|
import "testing"
|
|
|
|
func TestRepoRejectsCleartextNonLoopback(t *testing.T) {
|
|
t.Setenv("ASK_FORM_UPDATE_URL", "http://evil.example/repo")
|
|
if got := Repo(); got != DefaultRepo {
|
|
t.Fatalf("cleartext non-loopback accepted: %q", got)
|
|
}
|
|
t.Setenv("ASK_FORM_UPDATE_URL", "http://127.0.0.1:9999/repo/")
|
|
if got := Repo(); got != "http://127.0.0.1:9999/repo" {
|
|
t.Fatalf("loopback test server rejected: %q", got)
|
|
}
|
|
t.Setenv("ASK_FORM_UPDATE_URL", "https://mirror.example.com/ask-form/")
|
|
if got := Repo(); got != "https://mirror.example.com/ask-form" {
|
|
t.Fatalf("https mirror rejected: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestDueRefusesPrereleasesAndParseValidatesPre(t *testing.T) {
|
|
if ok, _ := Due("v0.19.0", "v0.20.0-rc1", true); ok {
|
|
t.Fatal("auto-upgrade must never install a pre-release")
|
|
}
|
|
if ok, _ := Due("v0.19.0", "v0.20.0-alpha.1", false); ok {
|
|
t.Fatal("minor auto-upgrade must never install a pre-release")
|
|
}
|
|
if _, ok := Parse("v1.2.3-bad/path"); ok {
|
|
t.Fatal("Parse accepted slash in pre-release")
|
|
}
|
|
if _, ok := Parse("v1.2.3-bad space"); ok {
|
|
t.Fatal("Parse accepted space in pre-release")
|
|
}
|
|
if v, ok := Parse("v1.2.3-rc.1"); !ok || v.Pre != "rc.1" {
|
|
t.Fatalf("Parse rejected valid pre-release: %+v %v", v, ok)
|
|
}
|
|
}
|