You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/admin/configuration/expressions.mdx
+114Lines changed: 114 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -233,6 +233,27 @@ This is best applied when doing explicit block rules, eg:
233
233
234
234
It seems counter-intuitive to allow known bad clients through sometimes, but this allows you to confuse attackers by making Anubis' behavior random. Adjust the thresholds and numbers as facts and circumstances demand.
235
235
236
+
### `regexSafe`
237
+
238
+
Available in `bot` expressions.
239
+
240
+
```ts
241
+
function regexSafe(input: string): string;
242
+
```
243
+
244
+
`regexSafe`takes a string and escapes it for safe use inside of a regular expression. This is useful when you are creating regular expressions from headers or variables such as `remoteAddress`.
@@ -266,6 +287,99 @@ This is useful if you want to write rules that allow requests that have no query
266
287
- size(segments(path)) < 2
267
288
```
268
289
290
+
### DNS Functions
291
+
292
+
Anubis can also perform DNS lookups as a part of its expression evaluation. This can be useful for doing things like checking for a valid [Forward-confirmed reverse DNS (FCrDNS)](https://en.wikipedia.org/wiki/Forward-confirmed_reverse_DNS) record.
293
+
294
+
#### `arpaReverseIP`
295
+
296
+
Available in `bot` expressions.
297
+
298
+
```ts
299
+
function arpaReverseIP(ip: string): string;
300
+
```
301
+
302
+
`arpaReverseIP`takes an IP address and returns its value in [ARPA notation](https://www.ietf.org/rfc/rfc2317.html). This can be useful when matching PTR record patterns.
Do not use this for validating the legitimacy of an IP address. It is possible for DNS records to be out of date or otherwise manipulated. Use [`verifyFCrDNS`](#verifyfcrdns) instead for a more reliable result.
344
+
345
+
:::
346
+
347
+
#### `verifyFCrDNS`
348
+
349
+
Available in `bot` expressions.
350
+
351
+
```ts
352
+
function verifyFCrDNS(ip: string): bool;
353
+
function verifyFCrDNS(ip: string, pattern: string): bool;
354
+
```
355
+
356
+
`verifyFCrDNS` checks if the reverse DNS of an IP address matches its forward DNS. This is a common technique to filter out spam and bot traffic. `verifyFCrDNS` comes in two forms:
357
+
358
+
- `verifyFCrDNS(remoteAddress)`will check that the reverse DNS of the remote address resolves back to the remote address.
359
+
- `verifyFCrDNS(remoteAddress, pattren)`will check that the reverse DNS of the remote address is matching with pattern and that name resolves back to the remote address.
360
+
361
+
This is best used in rules like this:
362
+
363
+
```yaml
364
+
- name: require-fcrdns-for-post
365
+
action: DENY
366
+
expression:
367
+
all:
368
+
- method == "POST"
369
+
- "!verifyFCrDNS(remoteAddress)"
370
+
```
371
+
372
+
Here is an another example that allows requests from telegram:
Expressions are very powerful. This is a benefit and a burden. If you are not careful with your expression targeting, you will be liable to get yourself into trouble. If you are at all in doubt, throw a `CHALLENGE` over a `DENY`. Legitimate users can easily work around a `CHALLENGE` result with a [proof of work challenge](../../design/why-proof-of-work.mdx). Bots are less likely to be able to do this.
0 commit comments