mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-05-01 12:31:57 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92baa1dcfb | |||
| a5bb6d2751 | |||
| 1e298f5d0e | |||
| a4770956a8 | |||
| 316905bf1d | |||
| 1a12171d74 |
@@ -22,11 +22,11 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/${{ github.repository }}
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
|
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
|
||||||
with:
|
with:
|
||||||
images: ${{ env.IMAGE }}
|
images: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/techarohq/anubis/docs
|
images: ghcr.io/techarohq/anubis/docs
|
||||||
tags: |
|
tags: |
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
|
||||||
with:
|
with:
|
||||||
images: ghcr.io/techarohq/anubis/docs
|
images: ghcr.io/techarohq/anubis/docs
|
||||||
tags: |
|
tags: |
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
||||||
with:
|
with:
|
||||||
node-version: latest
|
node-version: latest
|
||||||
|
|
||||||
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
|
||||||
with:
|
with:
|
||||||
go-version: stable
|
go-version: stable
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,10 @@
|
|||||||
all:
|
all:
|
||||||
- path.startsWith("/v2/")
|
- path.startsWith("/v2/")
|
||||||
- userAgent.contains("containerd/")
|
- userAgent.contains("containerd/")
|
||||||
|
|
||||||
|
- name: allow-renovate
|
||||||
|
action: ALLOW
|
||||||
|
expression:
|
||||||
|
all:
|
||||||
|
- path.startsWith("/v2/")
|
||||||
|
- userAgent.contains("Renovate/")
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM docker.io/library/node AS build
|
FROM docker.io/library/node:lts AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
<!-- This changes the project to: -->
|
<!-- This changes the project to: -->
|
||||||
|
|
||||||
|
- Expose WEIGHT rule matches as Prometheus metrics.
|
||||||
- Allow more OCI registry clients [based on feedback](https://github.com/TecharoHQ/anubis/pull/1253#issuecomment-3506744184).
|
- Allow more OCI registry clients [based on feedback](https://github.com/TecharoHQ/anubis/pull/1253#issuecomment-3506744184).
|
||||||
- Expose services directory in the embedded `(data)` filesystem.
|
- Expose services directory in the embedded `(data)` filesystem.
|
||||||
- Add Ukrainian locale ([#1044](https://github.com/TecharoHQ/anubis/pull/1044))
|
- Add Ukrainian locale ([#1044](https://github.com/TecharoHQ/anubis/pull/1044)).
|
||||||
|
- Allow Renovate as an OCI registry client.
|
||||||
|
- Properly handle 4in6 addresses so that IP matching works with those addresses.
|
||||||
|
|
||||||
## v1.23.1: Lyse Hext - Echo 1
|
## v1.23.1: Lyse Hext - Echo 1
|
||||||
|
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ func (s *Server) check(r *http.Request, lg *slog.Logger) (policy.CheckResult, *p
|
|||||||
return cr("bot/"+b.Name, b.Action, weight), &b, nil
|
return cr("bot/"+b.Name, b.Action, weight), &b, nil
|
||||||
case config.RuleWeigh:
|
case config.RuleWeigh:
|
||||||
lg.Debug("adjusting weight", "name", b.Name, "delta", b.Weight.Adjust)
|
lg.Debug("adjusting weight", "name", b.Name, "delta", b.Weight.Adjust)
|
||||||
|
policy.Applications.WithLabelValues("bot/"+b.Name, "WEIGH").Add(1)
|
||||||
weight += b.Weight.Adjust
|
weight += b.Weight.Adjust
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,148 +173,6 @@ func TestRenderIndexRedirect(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClearCookieHostParameterHonorsDynamicDomain(t *testing.T) {
|
|
||||||
// Test that Host parameter is only used when CookieDynamicDomain is enabled
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
options Options
|
|
||||||
host string
|
|
||||||
expectedDomain string
|
|
||||||
shouldHaveDomainField bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "dynamic domain disabled",
|
|
||||||
options: Options{CookieDynamicDomain: false},
|
|
||||||
host: "subdomain.example.com",
|
|
||||||
expectedDomain: "",
|
|
||||||
shouldHaveDomainField: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "dynamic domain enabled with valid host",
|
|
||||||
options: Options{CookieDynamicDomain: true},
|
|
||||||
host: "subdomain.example.com",
|
|
||||||
expectedDomain: "example.com",
|
|
||||||
shouldHaveDomainField: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "dynamic domain enabled with invalid host",
|
|
||||||
options: Options{CookieDynamicDomain: true},
|
|
||||||
host: "invalid-host",
|
|
||||||
expectedDomain: "",
|
|
||||||
shouldHaveDomainField: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
srv := spawnAnubis(t, tc.options)
|
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
|
|
||||||
// Test ClearCookie with Host parameter
|
|
||||||
srv.ClearCookie(rw, CookieOpts{Path: "/", Host: tc.host})
|
|
||||||
|
|
||||||
resp := rw.Result()
|
|
||||||
cookies := resp.Cookies()
|
|
||||||
|
|
||||||
if len(cookies) != 1 {
|
|
||||||
t.Errorf("wanted 1 cookie, got %d cookies", len(cookies))
|
|
||||||
}
|
|
||||||
|
|
||||||
ckie := cookies[0]
|
|
||||||
|
|
||||||
if ckie.Name != anubis.CookieName {
|
|
||||||
t.Errorf("wanted cookie named %q, got cookie named %q", anubis.CookieName, ckie.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ckie.MaxAge != -1 {
|
|
||||||
t.Errorf("wanted cookie max age of -1, got: %d", ckie.MaxAge)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify domain handling based on CookieDynamicDomain setting
|
|
||||||
if tc.shouldHaveDomainField {
|
|
||||||
if ckie.Domain != tc.expectedDomain {
|
|
||||||
t.Errorf("wanted cookie domain %q, got cookie domain %q", tc.expectedDomain, ckie.Domain)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ckie.Domain != tc.expectedDomain {
|
|
||||||
t.Errorf("wanted cookie domain %q, got cookie domain %q", tc.expectedDomain, ckie.Domain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetCookieHostParameterHonorsDynamicDomain(t *testing.T) {
|
|
||||||
// Test that SetCookie Host parameter is only used when CookieDynamicDomain is enabled
|
|
||||||
testCases := []struct {
|
|
||||||
name string
|
|
||||||
options Options
|
|
||||||
host string
|
|
||||||
expectedDomain string
|
|
||||||
shouldHaveDomainField bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "dynamic domain disabled",
|
|
||||||
options: Options{CookieDynamicDomain: false},
|
|
||||||
host: "subdomain.example.com",
|
|
||||||
expectedDomain: "",
|
|
||||||
shouldHaveDomainField: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "dynamic domain enabled with valid host",
|
|
||||||
options: Options{CookieDynamicDomain: true},
|
|
||||||
host: "subdomain.example.com",
|
|
||||||
expectedDomain: "example.com",
|
|
||||||
shouldHaveDomainField: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "dynamic domain enabled with invalid host",
|
|
||||||
options: Options{CookieDynamicDomain: true},
|
|
||||||
host: "invalid-host",
|
|
||||||
expectedDomain: "",
|
|
||||||
shouldHaveDomainField: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
srv := spawnAnubis(t, tc.options)
|
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
|
|
||||||
// Test SetCookie with Host parameter
|
|
||||||
srv.SetCookie(rw, CookieOpts{Path: "/", Host: tc.host, Value: "test-value"})
|
|
||||||
|
|
||||||
resp := rw.Result()
|
|
||||||
cookies := resp.Cookies()
|
|
||||||
|
|
||||||
if len(cookies) != 1 {
|
|
||||||
t.Errorf("wanted 1 cookie, got %d cookies", len(cookies))
|
|
||||||
}
|
|
||||||
|
|
||||||
ckie := cookies[0]
|
|
||||||
|
|
||||||
if ckie.Name != anubis.CookieName {
|
|
||||||
t.Errorf("wanted cookie named %q, got cookie named %q", anubis.CookieName, ckie.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ckie.Value != "test-value" {
|
|
||||||
t.Errorf("wanted cookie value %q, got cookie value %q", "test-value", ckie.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify domain handling based on CookieDynamicDomain setting
|
|
||||||
if tc.shouldHaveDomainField {
|
|
||||||
if ckie.Domain != tc.expectedDomain {
|
|
||||||
t.Errorf("wanted cookie domain %q, got cookie domain %q", tc.expectedDomain, ckie.Domain)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ckie.Domain != tc.expectedDomain {
|
|
||||||
t.Errorf("wanted cookie domain %q, got cookie domain %q", tc.expectedDomain, ckie.Domain)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRenderIndexUnauthorized(t *testing.T) {
|
func TestRenderIndexUnauthorized(t *testing.T) {
|
||||||
s := &Server{
|
s := &Server{
|
||||||
opts: Options{
|
opts: Options{
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ func (rac *RemoteAddrChecker) Check(r *http.Request) (bool, error) {
|
|||||||
return false, fmt.Errorf("%w: %s is not an IP address: %w", ErrMisconfiguration, host, err)
|
return false, fmt.Errorf("%w: %s is not an IP address: %w", ErrMisconfiguration, host, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert IPv4-mapped IPv6 addresses to IPv4
|
||||||
|
if addr.Is6() && addr.Is4In6() {
|
||||||
|
addr = addr.Unmap()
|
||||||
|
}
|
||||||
|
|
||||||
return rac.prefixTable.Contains(addr), nil
|
return rac.prefixTable.Contains(addr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,20 @@ func TestRemoteAddrChecker(t *testing.T) {
|
|||||||
ok: true,
|
ok: true,
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "match_ipv4_in_ipv6",
|
||||||
|
cidrs: []string{"0.0.0.0/0"},
|
||||||
|
ip: "::ffff:1.1.1.1",
|
||||||
|
ok: true,
|
||||||
|
err: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "match_ipv4_in_ipv6_hex",
|
||||||
|
cidrs: []string{"0.0.0.0/0"},
|
||||||
|
ip: "::ffff:101:101",
|
||||||
|
ok: true,
|
||||||
|
err: nil,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "match_ipv6",
|
name: "match_ipv6",
|
||||||
cidrs: []string{"::/0"},
|
cidrs: []string{"::/0"},
|
||||||
|
|||||||
Regular → Executable
Reference in New Issue
Block a user