diff --git a/CHANGELOG.md b/CHANGELOG.md index f612454..45e501b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to hp (hittyping) will be documented in this file. +## [0.8.10] - 2026-11-15 + +### Fixed + +- `go install github.com/colangelo/HittyPing@latest` works: the module path was `github.com/ac/hp`, which does not match the repository, so the install failed with "module declares its path as". The binary installs as `HittyPing` + +### Added + +- Go native fuzz tests for the stats-line truncation and the host:port parsing (`just fuzz`) + +### Changed + +- README: the retired Go Report Card badge is replaced by a Go version badge + ## [0.8.9] - 2026-11-15 ### Security diff --git a/CLAUDE.md b/CLAUDE.md index cae2773..a230f6d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,6 +20,7 @@ just ci # Local CI (lint, vuln, test) just clean # Remove binary just verify-release # Download + cosign-verify the latest release (into a temp dir, never the checkout) just test-verify # Check both verify recipes pass and leave the checkout unchanged (network, cosign) +just fuzz # Fuzz the input parsers (30s each) ``` Or directly with Go: diff --git a/README.md b/README.md index 1393890..bfc3810 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@
@@ -51,7 +51,7 @@ scoop install hp ### From source ```bash -go install github.com/colangelo/HittyPing@latest +go install github.com/colangelo/HittyPing@latest # installs the binary as HittyPing (v0.8.10+) # Or clone and build git clone https://github.com/colangelo/HittyPing.git diff --git a/ROADMAP.md b/ROADMAP.md index 51744cd..f64ac64 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -74,6 +74,12 @@ If hp evolves toward interactive features, consider migrating to [Bubble Tea](ht ## Completed +### v0.8.10 - go install & Fuzzing + +- [x] Module path matches the repository, so `go install github.com/colangelo/HittyPing@latest` works +- [x] Go native fuzz tests (`just fuzz`) +- [x] Replace the retired Go Report Card badge + ### v0.8.9 - Security Refresh - [x] Container image on Go 1.27.4; go directive 1.27.4; x/crypto v0.59.0 diff --git a/fuzz_test.go b/fuzz_test.go new file mode 100644 index 0000000..50dc68c --- /dev/null +++ b/fuzz_test.go @@ -0,0 +1,56 @@ +package main + +import ( + "net" + "regexp" + "strings" + "testing" +) + +var ansiEscape = regexp.MustCompile(`\x1b\[[^A-Za-z]*[A-Za-z]?`) + +func FuzzTruncateToWidth(f *testing.F) { + f.Add("0/5 ( 0%) lost; 12/30/88ms; last: 20ms", 20) + f.Add("\x1b[1m42\x1b[0m \x1b[90mms\x1b[0m", 3) + f.Add("\x1b[12", 1) + f.Add("", 0) + f.Fuzz(func(t *testing.T, s string, w int) { + got := truncateToWidth(s, w) + if w <= 0 { + if got != reset { + t.Fatalf("truncateToWidth(%q, %d) = %q; want only a reset", s, w, got) + } + return + } + body, _ := strings.CutSuffix(got, reset) + if !strings.HasPrefix(s, body) && !strings.HasPrefix(s, got) { + t.Fatalf("truncateToWidth(%q, %d) = %q; not a prefix of the input", s, w, got) + } + if visible := len(ansiEscape.ReplaceAllString(body, "")); visible > w { + t.Fatalf("truncateToWidth(%q, %d) = %q; %d visible bytes", s, w, got, visible) + } + if len(ansiEscape.ReplaceAllString(s, "")) <= w && got != s { + t.Fatalf("truncateToWidth(%q, %d) = %q; input fits and must come back unchanged", s, w, got) + } + }) +} + +func FuzzHostname(f *testing.F) { + f.Add("example.com", "8443") + f.Add("127.0.0.1", "80") + f.Add("::1", "443") + f.Add("", "1") + f.Fuzz(func(t *testing.T, host, port string) { + if strings.ContainsAny(host, "[]") || strings.ContainsAny(port, ":[]") { + t.Skip() + } + if got := hostname(net.JoinHostPort(host, port)); got != host { + t.Fatalf("hostname(%q) = %q; want %q", net.JoinHostPort(host, port), got, host) + } + if !strings.Contains(host, ":") { + if got := hostname(host); got != host { + t.Fatalf("hostname(%q) = %q; want it unchanged", host, got) + } + } + }) +} diff --git a/go.mod b/go.mod index 20037ef..604bf88 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ac/hp +module github.com/colangelo/HittyPing go 1.27.4 diff --git a/justfile b/justfile index d793605..283ac4e 100644 --- a/justfile +++ b/justfile @@ -33,6 +33,11 @@ fmt: lint: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest run +# Fuzz the input parsers (30s each) +fuzz: + go test -run '^$' -fuzz '^FuzzTruncateToWidth$' -fuzztime 30s . + go test -run '^$' -fuzz '^FuzzHostname$' -fuzztime 30s . + # Run vulnerability check vuln: go run golang.org/x/vuln/cmd/govulncheck@latest ./... diff --git a/main.go b/main.go index 0c404d9..07b41a7 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ import ( // cleanly pause rendering before the process is actually stopped. var displayMu sync.Mutex -const version = "0.8.9" +const version = "0.8.10" //go:embed skills/hp/SKILL.md var skillText string