Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 7b700cf

Browse files
puneetseahkok
authored andcommitted
Add tallow.patterns man page
Add a tallow.patterns man page which explains the json configuration files that contain regex patterns and banning thresholds. This functionality was added by 9174590.
1 parent 3ffb46e commit 7b700cf

3 files changed

Lines changed: 136 additions & 2 deletions

File tree

man/tallow.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ the `-DDEBUG=1` symbol passed to the compiler.
4848

4949
## SEE ALSO
5050

51-
systemd-journald(1), iptables(1), ipset(1), tallow.conf(5)
51+
systemd-journald(1), iptables(1), ipset(1), tallow.conf(5), tallow.patterns(5)
5252

5353
## BUGS
5454

man/tallow.conf.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Use the following commands if you're using firewalld(1):
8787

8888
## SEE ALSO
8989

90-
tallow(1)
90+
tallow(1), tallow.patterns(5)
9191

9292
## AUTHOR
9393

man/tallow.patterns.5.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
## tallow.patterns
2+
3+
Tallow pattern matching configuration files.
4+
5+
6+
## SYNOPSIS
7+
8+
tallow(1) uses regular expressions to match journal entries and extract an IP
9+
address from them. JSON files are used to configure the patterns and banning
10+
thresholds used by tallow(1).
11+
12+
`/etc/tallow/*.json`
13+
`/usr/share/tallow/*.json`
14+
15+
16+
## DESCRIPTION
17+
18+
tallow(1) uses regular expressions to match journal entries and extract an IP
19+
address from them. JSON files are used to configure the patterns and banning
20+
thresholds used by tallow(1). This adds the ability to extend the patterns
21+
tallow(1) will recognize. Many JSON files can exist for logical grouping. The
22+
tallow(1) daemon will read all JSON files in the configuration directories at
23+
startup.
24+
25+
tallow(1) operates with default pattern definitions
26+
in`/usr/share/tallow/*.json`. Users can add more patterns with their own JSON
27+
files under `/etc/tallow`. The default JSON files can be overridden by creating
28+
the same file under `/etc/tallow`.
29+
30+
31+
## FILE FORMAT
32+
33+
Pattern configuration files use the JavaScript Object Notation (JSON) format.
34+
35+
The JSON must be two levels deep and all properties are required. The root
36+
object is an array containing objects with a `filter` key and an `items` key.
37+
38+
* `filter` is a string that defines a field for filtering the journal file.
39+
This helps make sure patterns are only matched to a subset of journal
40+
entries. See systemd.journal-fields(7) for valid journal fields.
41+
42+
* `items` is an array of objects that contains three elements: `ban`, `score`,
43+
and `pattern`.
44+
45+
* `ban` is an integer that defines the number of seconds to ban originating
46+
IP for. If this value is > 0, the IP address get banned immediately when a
47+
journal entry matches `pattern`.
48+
49+
* `score` is a double that defines a value to add to the accumulated "score"
50+
of an originating IP address each time a journal entry matches
51+
the `pattern`. If the combined score is > 1.0, tallow bans the originating
52+
IP for the default time of 1 hour. The `ban` element value above is not
53+
used for bans made due to `score`.
54+
55+
* `pattern` is a string that defines a Perl Compatible Regular Expressions
56+
(PCRE) to match against the filtered journal entries. The PCRE should
57+
extract exactly one substring: the originating IP address for tallow(1).
58+
See systemd.journal-fields(7) for valid journal fields.
59+
60+
61+
62+
## EXAMPLES
63+
64+
1. The JSON below is a snippet from one of the default pattern configuration
65+
files for blocking certain failed `sshd` connections.
66+
67+
The first pattern will ban an IP address after it fails to login 6 times
68+
causing it to reach a total score > 1.0.
69+
70+
The second pattern will ban an IP address for 10 seconds every time a login is
71+
attempted with an invalid user. Additionally, it will ban the IP address for
72+
1 hour if it attempts to login with an invalid user 6 times causing it to
73+
reach a total score > 1.0.
74+
75+
See the `/usr/share/tallow/sshd.json` file for more `sshd` examples.
76+
77+
```
78+
[
79+
{
80+
"filter": "SYSLOG_IDENTIFIER=sshd",
81+
"items": [
82+
{
83+
"ban": 0,
84+
"score": 0.2,
85+
"pattern": "MESSAGE=Failed .* for .* from ([0-9a-z:.]+) port \\d+ ssh2"
86+
},
87+
{
88+
"ban": 10,
89+
"score": 0.2,
90+
"pattern": "MESSAGE=Invalid user .* from ([0-9a-z:.]+) port \\d+"
91+
}
92+
]
93+
}
94+
]
95+
```
96+
97+
98+
99+
2. The JSON below defines a pattern for blocking connections based on error logs
100+
from `nginx-mainline` if placed in a `/etc/tallow/nginx-mainline.json` file.
101+
102+
The pattern will ban an IP address for 15 seconds every time it attempts to
103+
access a script that does not exist. Additionally, it will ban the IP
104+
address for 1 hour if it attempts to access invalid scripts 4 times causing
105+
it to reach a total score > 1.0.
106+
107+
```
108+
[
109+
{
110+
"filter": "SYSLOG_IDENTIFIER=nginx-mainline",
111+
"items": [
112+
{
113+
"ban": 15,
114+
"score": 0.3,
115+
"pattern": ".Primary script unknown. while reading response header from upstream, client: ([0-9a-z:.]+),"
116+
}
117+
]
118+
}
119+
]
120+
```
121+
122+
## SEE ALSO
123+
124+
tallow(1), tallow.conf(5)
125+
126+
## BUGS
127+
128+
`tallow` is `NOT A SECURITY SOLUTION`, nor does it protect against random
129+
password logins. An attacker may still be able to logon to your systems if you
130+
allow password logins.
131+
132+
## AUTHOR
133+
134+
Auke Kok <auke-jan.h.kok@intel.com>

0 commit comments

Comments
 (0)