reaction/app/reaction.yml

59 lines
2.5 KiB
YAML
Raw Normal View History

---
# definitions are just a place to put chunks of conf you want to reuse in another place
# they're not readed by reaction
definitions:
- &iptablesban [ "iptables" "-w" "-A" "reaction" "1" "-s" "<ip>" "-j" "DROP" ]
- &iptablesunban [ "iptables" "-w" "-D" "reaction" "1" "-s" "<ip>" "-j" "DROP" ]
# patterns are substitued in regexes.
# when a filter performs an action, it replaces the found pattern
patterns:
ip:
# reaction regex syntax is defined here: https://github.com/google/re2/wiki/Syntax
regex: '(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:[0-9a-fA-F:]{2,90})'
ignore:
- 127.0.0.1
- ::1
2023-09-03 13:26:27 +02:00
# streams are commands
# they're run and their ouptut is captured
# *example:* `tail -f /var/log/nginx/access.log`
# their output will be used by one or more filters
streams:
# streams have a user-defined name
ssh:
# note that if the command is not in environment's `PATH`
# its full path must be given.
cmd: [ "journalctl" "-fu" "sshd.service" ]
2023-09-03 13:26:27 +02:00
# filters run actions when they match regexes on a stream
filters:
# filters have a user-defined name
failedlogin:
2023-09-03 13:26:27 +02:00
# reaction's regex syntax is defined here: https://github.com/google/re2/wiki/Syntax
regex:
2023-09-03 13:26:27 +02:00
# <ip> is predefined in the patterns section
# ip's regex is inserted in the following regex
- authentication failure;.*rhost=<ip>
# if retry and retry-period are defined,
# the actions will only take place if a same pattern is
# found `retry` times in a `retry-period` interval
retry: 3
# format is defined here: https://pkg.go.dev/time#ParseDuration
retry-period: 6h
2023-09-03 13:26:27 +02:00
# actions are run by the filter when regexes are matched
actions:
# actions have a user-defined name
ban:
# YAML substitutes *reference by the value at &reference
cmd: *iptablesban
unban:
cmd: *iptablesunban
2023-09-03 13:26:27 +02:00
# if after is defined, the action will not take place immediately, but after a specified duration
# same format as retry-period
after: 48h
# let's say reaction is quitting. does it run all those pending commands which had an `after` duration set?
# if you want reaction to run those pending commands before exiting, you can set this:
2023-09-03 13:26:27 +02:00
onexit: true
# (defaults to false)
# here it is not useful because we will flush the chain containing the bans anyway (see ./reaction.service)