210 Commits

Author SHA1 Message Date
Xe Iaso
b6c361c294
fix(default-config): isBrowser -> isBrowserLike
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 18:07:36 -04:00
Xe Iaso
e9e602976f
docs(admin/configuration): add expressions docs outline
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 18:03:10 -04:00
Xe Iaso
33bb5803a8
docs(admin/environments): update apache/nginx docs
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 17:56:28 -04:00
Xe Iaso
ada7b3a179
docs(admin): add guide for making Anubis far less aggressive by default
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 17:56:06 -04:00
Xe Iaso
dfa7025afe
test: add apache, caddy, and nginx smoke test environments
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 17:52:23 -04:00
Xe Iaso
884af5fd4c
fix(data/common): use new isBrowserLike function for less aggressive challenge rule
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 17:51:58 -04:00
Xe Iaso
3fb8fa2009
feat(policy/expressions): add userAgent.isBrowserLike method
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 16:15:05 -04:00
Xe Iaso
b43df36f7d
feat(policy): add system load average as checker input
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 15:44:12 -04:00
Xe Iaso
fd058964fa
feat(data/apps): add API route allow rule for non-HEAD/GET
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 13:06:24 -04:00
Xe Iaso
fb20b36b18
feat(data/bots): add two example IRC bots
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 00:46:59 -04:00
Xe Iaso
84cba05167
fix(data): enable legacy rule for now, admins will have to opt-in
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 00:41:05 -04:00
Xe Iaso
9f988578a4
feat(data): add challenge-browser-like.yaml
This is a huge change to Anubis and will make it a lot more invisible at
the cost of requiring additional server configuration to make it happen.

If you add this bit of nginx config to your location block:

```nginx
proxy_set_header X-Http-Version $server_protocol;
```

And then adjust the bottom bot rule to this:

```yaml
- import: (data)/common/challenge-browser-like.yaml
```

Anubis will be way less aggressive than it was before. This will let
through any traffic that comes from a browser that actually is a browser
via some more advanced heuristics.

I think that this rule alone is the key feature of v1.18.0.

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-28 00:20:27 -04:00
Xe Iaso
ea4e5751ab
test(lib): ensure that Cf-Worker via expression works
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:50:24 -04:00
Xe Iaso
4e1db3842e
fix(policy/expressions): do not Contains missing keys
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:49:44 -04:00
Xe Iaso
029c79ba28
fix(lib/test): fix failing test and invalid cloudflare workers rule
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:50 -04:00
Xe Iaso
9f8ede7fe3
data/clients: fix curl-impersonate definition
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:50 -04:00
Xe Iaso
80bd7c563b
chore(data): reformat some things for expressions
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:49 -04:00
Xe Iaso
92a3e5ba81
fix: rename and/or to all/any
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:49 -04:00
Xe Iaso
65cbc6922c
data: add some examples of expression-based rules
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:49 -04:00
Xe Iaso
eae3a7b5e4
feat(lib/policy): add support for CEL checkers
This adds the ability for administrators to use Common Expression
Language[0] (CEL) for more advanced check logic than Anubis previously
offered.

These can be as simple as:

```yaml
- name: allow-api-routes
  action: ALLOW
  expression:
    and:
    - '!(method == "HEAD" || method == "GET")'
    - path.startsWith("/api/")
```

or get as complicated as:

```yaml
- name: allow-git-clients
  action: ALLOW
  expression:
    and:
    - userAgent.startsWith("git/") || userAgent.contains("libgit") || userAgent.startsWith("go-git") || userAgent.startsWith("JGit/") || userAgent.startsWith("JGit-")
    - >
      "Git-Protocol" in headers && headers["Git-Protocol"] == "version=2"
```

Internally these are compiled and evaluated with cel-go[1]. This also
leaves room for extensibility should that be desired in the future. This
will intersect with #338 and eventually intersect with TLS fingerprints
as in #337.

[0]: https://cel.dev/
[1]: https://github.com/google/cel-go

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 22:25:49 -04:00
dependabot[bot]
6daf08216e
build(deps-dev): bump esbuild from 0.25.2 to 0.25.3 in the npm group (#388)
Bumps the npm group with 1 update: [esbuild](https://github.com/evanw/esbuild).


Updates `esbuild` from 0.25.2 to 0.25.3
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.25.2...v0.25.3)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-version: 0.25.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-27 22:01:37 -04:00
dependabot[bot]
bd0e46dac3
build(deps): bump the github-actions group with 4 updates (#387)
Bumps the github-actions group with 4 updates: [docker/build-push-action](https://github.com/docker/build-push-action), [actions-hub/kubectl](https://github.com/actions-hub/kubectl), [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `docker/build-push-action` from 6.15.0 to 6.16.0
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](471d1dc4e0...14487ce63c)

Updates `actions-hub/kubectl` from 1.32.3 to 1.33.0
- [Release notes](https://github.com/actions-hub/kubectl/releases)
- [Commits](9270913c29...e81783053d)

Updates `astral-sh/setup-uv` from 5.4.2 to 6.0.0
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](d4b2f3b6ec...c7f87aa956)

Updates `github/codeql-action` from 3.28.15 to 3.28.16
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](45775bd823...28deaeda66)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: actions-hub/kubectl
  dependency-version: 1.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: astral-sh/setup-uv
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-version: 3.28.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-28 01:40:38 +00:00
Dryusdan
76514f9f32
Bump AI-robots.txt rules to version 1.29 (#383) 2025-04-27 20:52:08 -04:00
Xe Iaso
b0f0913ea2
v1.17.0: Asahi sas Brutus
Signed-off-by: Xe Iaso <me@xeiaso.net>
v1.17.0
2025-04-27 15:16:25 -04:00
Xe Iaso
5423ab013a
ci(packages): final pre-release yeet bump (#384)
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 16:54:03 +00:00
Jason Cameron
301c7a42bd
refactor(lib): Split up anubis.go into some smaller files. (#379)
* refactor(logging): centralize logger creation in GetLogger function

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* refactor(logging): rename GetLogger to GetRequestLogger for clarity

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* refactor: streamline error handling and response methods

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* refactor(lib): Split anubis.go up into some smaller specialized methods

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* refactor(http): simplify error response handling by using respondWithStatus

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* chore(lib): run goimports

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Jason Cameron <git@jasoncameron.dev>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-04-27 13:36:39 +00:00
Kistaro Windrider
755c18a9a7
README: Fix broken link to policy definition docs. (#380) 2025-04-27 13:33:41 +00:00
Xe Iaso
0fa9906e3a
test(config): add Xesite's old policy file to known good test cases (#382)
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-27 13:32:50 +00:00
p0008874
b08580ca33
docs(known-instances): add Codeberg. (#381)
Signed-off-by: p0008874 <75534590+p0008874@users.noreply.github.com>
2025-04-27 12:17:27 +00:00
Xe Iaso
d8f923974e
chore: blank commit to unbreak git
Signed-off-by: Xe Iaso <me@xeiaso.net>
v1.17.0-beta4
2025-04-26 13:52:13 -04:00
Xe Iaso
ef52550e70
fix(config): remove trailing newlines in regexes (#373)
Closes #372

Fun YAML fact of the day:

What is the difference between how these two expressions are parsed?

```yaml
foo: >
  bar
```

```yaml
foo: >-
  bar
```

They are invisible in yaml, but when you evaluate them to JSON the
difference is obvious:

```json
{
  "foo": "bar\n"
}
```

```json
{
  "foo": "bar"
}
```

User-Agent strings, URL path values, and HTTP headers _do_ end in
newlines in HTTP/1.1 wire form, but that newline is usually stripped
before the server actually handles it. Also HTTP/2 is a thing and does
not terminate header values with newlines.

This change makes Anubis more aggressively detect mistaken uses of the
yaml `>` operator and nudges the user into using the yaml `>-` operator
which does not append the trailing newline.

I had honestly forgotten about this YAML behavior because it wasn't
relevant for so long. Oops! Glad I released a beta.

Whenever you get into this state, Anubis will throw a config parsing
error and then give you a message hinting at the folly of your ways.

```
config.Bot: regular expression ends with newline (try >- instead of > in yaml)
```

Big thanks to https://yaml-multiline.info, this helped me realize my
folly instantly.

@aiverson, this is official permission to say "told you so".

Signed-off-by: Xe Iaso <me@xeiaso.net>
1.17.0-beta2 v1.17.0-beta3
2025-04-26 14:01:15 +00:00
Xe Iaso
c669b47b57
fix(lib): make Anubis less paranoid (#365)
Previously Anubis would aggressively make sure that the client cookie
matched exactly what it should. This has turned out to be too paranoid
in practice and has caused problems with Happy Eyeballs et. al.

This is a potential fix to #303 and #289.
v1.17.0-beta1
2025-04-25 15:02:55 -04:00
Jason Cameron
24f8ba729b
feat: add support for a base prefix (#294)
* fix: rename variable for preventing collision in ED25519 private key handling

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* fix: remove unused import and debug print in xess.go

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* feat: introduce base path configuration for Anubis endpoints

Closes: #231
Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* hack(internal/test): skip these tests for now

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(yeet): unbreak package builds

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Jason Cameron <git@jasoncameron.dev>
Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-04-25 14:39:38 -04:00
Sandro
6858f66a62
Add check endpoint which can be used with nginx' auth_request function (#266)
* Add check endpoint which can be used with nginx' auth_request function

* feat(cmd): allow configuring redirect domains

* test: add test environment for the nginx_auth PR

This is a full local setup of the nginx_auth PR including HTTPS so that
it's easier to validate in isolation.

This requires an install of k3s (https://k3s.io) with traefik set to
listen on localhost. This will be amended in the future but for now this
works enough to ship it.

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(cmd|lib): allow empty redirect domains variable

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(test): add space to target variable in anubis container

Signed-off-by: Xe Iaso <me@xeiaso.net>

* docs(admin): rewrite subrequest auth docs, make generic

* docs(install): document REDIRECT_DOMAINS flag

Signed-off-by: Xe Iaso <me@xeiaso.net>

* feat(lib): clamp redirects to the same HTTP host

Only if REDIRECT_DOMAINS is not set.

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-04-25 17:38:02 +00:00
Xe Iaso
a5d796c679
docs(install): note that Anubis needs certain paths proxied (#363)
Closes #310

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-25 17:32:29 +00:00
Maher
4d3353fdc5
fix(docs): fix typos in Traefik integration docs (#361)
- Fix wording and typos in the`traefix.mdx` file
- Add rendering fix for the NOTE due to syntax
2025-04-25 08:47:48 -04:00
Aurelia
a420db8b8a
feat: more elaborate XFF compute (#350)
* feat: more elaborate XFF compute

#328 followup

now featuring configuration and
defaults that shouldn't break most
setups.

fixes #344

* refactor: obvious condition eval order optimization

* feat: add StripLLU implementation

* chore: I'm sorry it's 7 AM

* test: add test environment for unix socket serving

Signed-off-by: Xe Iaso <me@xeiaso.net>

* test(unix-socket-xff): comment out the shell script more

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(internal): fix logic bug in XFF computation, add tests

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(internal): prevent panic in local testing

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(internal): shuffle around return values to flow better

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-04-25 11:59:55 +00:00
Xe Iaso
5a4f68d384
docs(README): sponsor: Distrust
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-25 07:53:54 -04:00
Xe Iaso
bac942d2e8
sponsor: Distrust
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-25 00:25:03 -04:00
Xe Iaso
9fab74eb8a
docs(README): enable dark mode for the star history view (#360)
Closes #340

Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-25 03:26:35 +00:00
Diego E
e6a1c5309f
docs: Fix nginx.mdx indentation (#359)
It would seem the file was originally edited for 2-space indentation but accidentally used tabs instead of actual spaces.

Signed-off-by: Diego E <diegoe@gnome.org>
2025-04-25 00:26:59 +00:00
Tristan Ross
5c29a66fcc
docs(known-instances): add NixOS Hydra (#358) 2025-04-24 23:35:29 +00:00
Remy Zandwijk
b4f9269ae4
Fix Traegik but funny typos. (#356) 2025-04-24 18:54:53 +00:00
Igor Brai
54cd99c750
Fix: mojeekbot regex (#351)
* update mojeekbot UA regex

* add fix into changelog

* hack: empty commit to unbreak CI

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2025-04-24 14:24:41 +00:00
luzpaz
30b0ba8055
README: represent repology badge in 3 column format (#349)
Signed-off-by: luzpaz <luzpaz@users.noreply.github.com>
2025-04-24 02:17:26 +00:00
compilade
ce425a2c21
fix(lib): use correct URL for path checker in PassChallenge (#347)
Otherwise, `r.URL.Path` was always `/.within.website/x/cmd/anubis/api/pass-challenge`
and this didn't match the path checker rules correctly,
which caused a failure when the difficulty of these rules was non-default.
2025-04-24 02:13:11 +00:00
Luciano Hillcoat - lucdev.net
2320ef4014
feat(docs): add documentation for default allow behavior (#346) 2025-04-24 01:13:21 +00:00
Xe Iaso
cfbe16f2d0
feat(xess): move CSS color definitions to CSS variables (#339)
Signed-off-by: Xe Iaso <me@xeiaso.net>
2025-04-23 12:07:53 +00:00
dependabot[bot]
1b206175f8
build(deps): bump estree-util-value-to-estree in /docs (#336)
Bumps [estree-util-value-to-estree](https://github.com/remcohaszing/estree-util-value-to-estree) from 3.3.2 to 3.3.3.
- [Release notes](https://github.com/remcohaszing/estree-util-value-to-estree/releases)
- [Commits](https://github.com/remcohaszing/estree-util-value-to-estree/compare/v3.3.2...v3.3.3)

---
updated-dependencies:
- dependency-name: estree-util-value-to-estree
  dependency-version: 3.3.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-23 07:09:01 -04:00
dependabot[bot]
3135abd0ec
build(deps): bump http-proxy-middleware from 2.0.7 to 2.0.9 in /docs (#335)
Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.7 to 2.0.9.
- [Release notes](https://github.com/chimurai/http-proxy-middleware/releases)
- [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.9/CHANGELOG.md)
- [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.7...v2.0.9)

---
updated-dependencies:
- dependency-name: http-proxy-middleware
  dependency-version: 2.0.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-23 07:08:53 -04:00