Update to Anubis v1.28.2 (#1)

This upgrades the Masyunis fork from Anubis v1.25.0 to the latest stable release, **v1.28.2** (“Wuk Lamat Echo 2”), while keeping the fork’s custom styling and removals.

## Approach

The Gitea repo is a tree snapshot of v1.25.0, not a git-level fork of [TecharoHQ/anubis](https://github.com/TecharoHQ/anubis). The histories share no commits, so a merge or rebase onto the upstream tag is not usable.

The first commit on this branch replaces the tree with a snapshot of the **v1.28.2** tag (`git rm -r` plus `git checkout v1.28.2 -- .`; the import tree is identical to the tag). A short patch series on top restores the Masyunis customizations.

## Customizations kept

- Masyunya mascots (`web/static/img/{happy,pensive,reject}.webp`), hashes match current `master`.
- `web/static/img/ATTRIBUTIONS.txt` stays deleted.
- Challenge footer: drop the `made_with` (Canada / maple-leaf) line and the CELPHASE mascot credit; keep “Protected by Anubis from Techaro”. The generated `web/index_templ.go` matches `go generate ./web`.
- Short README (the old `anubisc` typo is fixed).
- Version stamped `v1.28.2/masyunis` via Makefile ldflags. `anubis.go` `init()` does not overwrite a link-time version; `go run` / `go test` still report `devel` on purpose.
- Upstream `.github`, `.devcontainer`, `.husky`, and `.vscode` stay deleted.
- `"uk"` is removed from `lib/localization/locales/manifest.json` **on purpose**, because of Alpine locale problems. `uk.json` and its test entry stay; the served manifest lists 27 languages.
- `package.json` `prepare` no longer runs `husky` (the hooks directory is gone). The rest of the script is unchanged. `husky` remains in devDependencies, as upstream left it.

## Deploy notes

- **Cookie rename (v1.27):** with the default `DYNAMIC_COOKIE_SUFFIX=true`, cookie names become e.g. `techaro.lol-anubis-auth-<hash>`. Existing clients get a **one-time re-challenge**. That is expected, not a loop.
- **Docker / ko / yeet builds** skip the Makefile ldflags, so the displayed version is `<git-version>/masyunis`. It is `v1.28.2/masyunis` only when built from a `v1.28.2` tag (or via `make build` / `make prebaked-build`).
- Go 1.27.3 is required (upstream bump in v1.28.2). Thoth (`THOTH_URL` / `THOTH_TOKEN`) was removed upstream; those settings now warn and do nothing. New WASM challenge methods stay disabled unless opted in.

## Verification

- `make build` succeeds. `./var/anubis --version` prints `Anubis v1.28.2/masyunis`.
- `SKIP_INTEGRATION=1 go test ./...` passes (unit tests; integration package is skipped).
- Local challenge/reject pages (en and ru) show Masyunya, version `v1.28.2/masyunis`, and no Canada / CELPHASE / mascot-credit text. Screenshots:

![Challenge page (en)](https://git.unvr.site/attachments/36112ff0-5155-495c-8bd2-59606ee3bd64)
![Reject page (en)](https://git.unvr.site/attachments/2cad0256-1b0e-4f71-8d06-d1a447fd5263)

- Upstream Playwright tests (`make test` without `SKIP_INTEGRATION`) fail on this box because the browser download fails. A clean v1.28.2 tree fails the same three Playwright tests here, so this is not a fork regression.
- `npm audit` reports **4** findings in upstream’s lockfile (2 moderate, 2 high: `brace-expansion`, `fast-uri`, `lodash.trim`, `source-map-js`). Left alone.

Please review and merge when ready. I will not merge this myself.

Reviewed-on: #1
Co-authored-by: Lead <3+lead_bot@noreply.git.unvr.site>
This commit was merged in pull request #1.
This commit is contained in:
sol_bot Bot authored and matiashik committed 2026-11-28 12:10:27 +00:00
1 parent eb3e46d8d0
commit caf4d72880
529 files changed
+33015 -6659

No files matched your search

+2 -2
View File
@@ -59,12 +59,12 @@ func (d *Dns) forwardCachePut(host string, entries []string) {
if d.cache == nil {
return
}
d.cache.forward.Set(d.ctx, host, entries, d.cache.forwardTTL)
_ = d.cache.forward.Set(d.ctx, host, entries, d.cache.forwardTTL)
}
func (d *Dns) reverseCachePut(addr string, entries []string) {
if d.cache == nil {
return
}
d.cache.reverse.Set(d.ctx, addr, entries, d.cache.reverseTTL)
_ = d.cache.reverse.Set(d.ctx, addr, entries, d.cache.reverseTTL)
}
+30 -24
View File
@@ -18,12 +18,14 @@ var (
)
type Dns struct {
lg *slog.Logger
cache *DnsCache
ctx context.Context
}
func New(ctx context.Context, cache *DnsCache) *Dns {
func New(ctx context.Context, cache *DnsCache, lg *slog.Logger) *Dns {
return &Dns{
lg: lg,
cache: cache,
ctx: ctx,
}
@@ -31,7 +33,8 @@ func New(ctx context.Context, cache *DnsCache) *Dns {
// ReverseDNS performs a reverse DNS lookup for the given IP address and trims the trailing dot from the results.
func (d *Dns) ReverseDNS(addr string) ([]string, error) {
slog.Debug("DNS: performing reverse lookup", "addr", addr)
lg := d.lg.With()
lg.Debug("DNS: performing reverse lookup", "addr", addr)
if cached, ok := d.getCachedReverse(addr); ok {
return cached, nil
@@ -40,14 +43,14 @@ func (d *Dns) ReverseDNS(addr string) ([]string, error) {
names, err := DNSLookupAddr(addr)
if err != nil {
if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound {
slog.Debug("DNS: no PTR record found", "addr", addr)
lg.Debug("DNS: no PTR record found", "addr", addr)
return []string{}, nil
}
slog.Error("DNS: reverse lookup failed", "addr", addr, "err", err)
lg.Error("DNS: reverse lookup failed", "addr", addr, "err", err)
return nil, err
}
slog.Debug("DNS: reverse lookup successful", "addr", addr, "names", names)
lg.Debug("DNS: reverse lookup successful", "addr", addr, "names", names)
trimmedNames := make([]string, len(names))
for i, name := range names {
@@ -60,7 +63,8 @@ func (d *Dns) ReverseDNS(addr string) ([]string, error) {
// LookupHost performs a forward DNS lookup for the given hostname.
func (d *Dns) LookupHost(host string) ([]string, error) {
slog.Debug("DNS: performing forward lookup", "host", host)
lg := d.lg.With()
lg.Debug("DNS: performing forward lookup", "host", host)
if cached, ok := d.getCachedForward(host); ok {
return cached, nil
@@ -69,14 +73,14 @@ func (d *Dns) LookupHost(host string) ([]string, error) {
addrs, err := DNSLookupHost(host)
if err != nil {
if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound {
slog.Debug("DNS: no A/AAAA record found", "host", host)
lg.Debug("DNS: no A/AAAA record found", "host", host)
return []string{}, nil
}
slog.Error("DNS: forward lookup failed", "host", host, "err", err)
lg.Error("DNS: forward lookup failed", "host", host, "err", err)
return nil, err
}
slog.Debug("DNS: forward lookup successful", "host", host, "addrs", addrs)
lg.Debug("DNS: forward lookup successful", "host", host, "addrs", addrs)
d.forwardCachePut(host, addrs)
return addrs, nil
}
@@ -84,28 +88,30 @@ func (d *Dns) LookupHost(host string) ([]string, error) {
// verifyFCrDNSInternal performs the second half of the FCrDNS check, using a
// pre-fetched list of names to perform the forward lookups.
func (d *Dns) verifyFCrDNSInternal(addr string, names []string) bool {
lg := d.lg.With()
for _, name := range names {
if cached, err := d.LookupHost(name); err == nil {
if slices.Contains(cached, addr) {
slog.Info("DNS: forward lookup confirmed original IP", "name", name, "addr", addr)
lg.Info("DNS: forward lookup confirmed original IP", "name", name, "addr", addr)
return true
}
continue
}
}
slog.Info("DNS: could not confirm original IP in forward lookups", "addr", addr)
lg.Info("DNS: could not confirm original IP in forward lookups", "addr", addr)
return false
}
// VerifyFCrDNS performs a forward-confirmed reverse DNS (FCrDNS) lookup for the given IP address,
// optionally matching against a provided pattern.
func (d *Dns) VerifyFCrDNS(addr string, pattern *string) bool {
lg := d.lg.With()
var patternVal string
if pattern != nil {
patternVal = *pattern
}
slog.Debug("DNS: performing FCrDNS lookup", "addr", addr, "pattern", patternVal)
lg.Debug("DNS: performing FCrDNS lookup", "addr", addr, "pattern", patternVal)
names, err := d.ReverseDNS(addr)
if err != nil {
@@ -117,24 +123,24 @@ func (d *Dns) VerifyFCrDNS(addr string, pattern *string) bool {
// If a pattern is provided, check for a match.
if pattern != nil {
anyNameMatched := false
re, err := regexp.Compile(*pattern)
if err != nil {
lg.Error("DNS: verifyFCrDNS invalid regex pattern", "err", err)
return false
}
var matchedNames []string
for _, name := range names {
matched, err := regexp.MatchString(*pattern, name)
if err != nil {
slog.Error("DNS: verifyFCrDNS invalid regex pattern", "err", err)
return false // Invalid pattern is a failure.
}
if matched {
anyNameMatched = true
break
if re.MatchString(name) {
matchedNames = append(matchedNames, name)
}
}
if !anyNameMatched {
slog.Debug("DNS: FCrDNS no PTR matches the pattern", "addr", addr, "pattern", *pattern)
if len(matchedNames) == 0 {
return false
}
slog.Debug("DNS: FCrDNS PTR matched pattern, proceeding with forward check", "addr", addr, "pattern", *pattern)
names = matchedNames
}
// If we're here, either there was no pattern, or the pattern matched.
+9 -9
View File
@@ -1,7 +1,6 @@
package dns
import (
"context"
"errors"
"net"
"reflect"
@@ -9,14 +8,15 @@ import (
"time"
"github.com/TecharoHQ/anubis/lib/store/memory"
"github.com/neilotoole/slogt/v2"
)
// newTestDNS is a helper function to create a new Dns object with an in-memory cache for testing.
func newTestDNS(forwardTTL int, reverseTTL int) *Dns {
ctx := context.Background()
memStore := memory.New(ctx)
func newTestDNS(t *testing.T, forwardTTL int, reverseTTL int) *Dns {
t.Helper()
memStore := memory.New(t.Context())
cache := NewDNSCache(forwardTTL, reverseTTL, memStore)
return New(ctx, cache)
return New(t.Context(), cache, slogt.New(t))
}
// mockLookupAddr is a mock implementation of the net.LookupAddr function.
@@ -75,7 +75,7 @@ func TestMain(m *testing.M) {
}
func TestDns_ArpaReverseIP(t *testing.T) {
d := newTestDNS(0, 0)
d := newTestDNS(t, 0, 0)
tests := []struct {
name string
ip string
@@ -102,7 +102,7 @@ func TestDns_ArpaReverseIP(t *testing.T) {
}
func TestDns_ReverseDNS(t *testing.T) {
d := newTestDNS(1, 1) // short TTL for testing cache
d := newTestDNS(t, 1, 1) // short TTL for testing cache
// First call - cache miss
t.Run("cache miss", func(t *testing.T) {
@@ -173,7 +173,7 @@ func TestDns_ReverseDNS(t *testing.T) {
}
func TestDns_LookupHost(t *testing.T) {
d := newTestDNS(1, 1)
d := newTestDNS(t, 1, 1)
t.Run("cache miss", func(t *testing.T) {
got, err := d.LookupHost("dns.google")
@@ -236,7 +236,7 @@ func TestDns_LookupHost(t *testing.T) {
}
func TestDns_VerifyFCrDNS(t *testing.T) {
d := newTestDNS(1, 1)
d := newTestDNS(t, 1, 1)
// Helper to convert string to *string
p := func(s string) *string {
+82
View File
@@ -0,0 +1,82 @@
package dns
import (
"context"
"net"
"testing"
"github.com/neilotoole/slogt/v2"
)
// TestGHSA_5gwm_367w_7fgj requires the same PTR hostname to match the
// policy pattern and forward-resolve to the original IP address.
func TestGHSA_5gwm_367w_7fgj(t *testing.T) {
const addr = "192.0.2.42"
pattern := `^.*\.yandex\.(ru|com|net)$`
tests := []struct {
name string
names []string
forward map[string][]string
want bool
}{
{
name: "matching PTR does not resolve",
names: []string{"fake.yandex.com.", "owned.example."},
forward: map[string][]string{"owned.example": {addr}},
},
{
name: "nonmatching PTR comes first",
names: []string{"owned.example.", "fake.yandex.com."},
forward: map[string][]string{"owned.example": {addr}},
},
{
name: "matching PTR resolves to another IP",
names: []string{"fake.yandex.com.", "owned.example."},
forward: map[string][]string{
"fake.yandex.com": {"192.0.2.99"},
"owned.example": {addr},
},
},
{
name: "forward confirmed hostname does not match",
names: []string{"owned.example."},
forward: map[string][]string{"owned.example": {addr}},
},
{
name: "matching hostname is forward confirmed",
names: []string{"real.yandex.com."},
forward: map[string][]string{"real.yandex.com": {addr}},
want: true,
},
{
name: "later matching hostname is forward confirmed",
names: []string{"fake.yandex.com.", "real.yandex.com."},
forward: map[string][]string{"real.yandex.com": {addr}},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
originalAddr, originalHost := DNSLookupAddr, DNSLookupHost
t.Cleanup(func() {
DNSLookupAddr, DNSLookupHost = originalAddr, originalHost
})
DNSLookupAddr = func(string) ([]string, error) {
return tt.names, nil
}
DNSLookupHost = func(host string) ([]string, error) {
if addrs, ok := tt.forward[host]; ok {
return addrs, nil
}
return nil, &net.DNSError{Name: host, IsNotFound: true}
}
d := New(context.Background(), nil, slogt.New(t))
if got := d.VerifyFCrDNS(addr, &pattern); got != tt.want {
t.Errorf("VerifyFCrDNS(%q, %q) with PTRs %v = %v, want %v", addr, pattern, tt.names, got, tt.want)
}
})
}
}