Import Anubis v1.28.2

Replace the tree with upstream TecharoHQ/anubis v1.28.2 (a1384fbf42e3).
Masyunis customizations are re-applied in the following commits.
This commit is contained in:
sol_bot Bot committed 2026-11-28 14:52:26 +03:00
1 parent eb3e46d8d0
commit e07de898cd
573 files changed
+35846 -6807

No files matched your search

+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)
}
})
}
}