-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Wish: fail2ban-regex with --print-all-matched-and-action #2036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is it something like: fail2ban-regex --out-action 'my-action[prm1="val1",...]' $log $filter Or: fail2ban-regex --out-tags $log $filter Could you provide an example, just for better understanding, what do you mean with |
yes... your suggestion is quite insightful. For me, simple tags which is predefined in action.d could be okay. (specify tag or composite action on shell command line could be quite uncertain since it is bash-ish syntax. we need POSIX-like stuffs. e.g, " Correct me if I am wrong here! fail2ban-regex --out-action $log $filter $action_conf_file |
Although it would be relative easy to implement for some script-actions (but no way for pythonic actions).
The problem here - you'll then see the pre-substituted scripts only (with interpolated tags), but they are not executed in shell (because otherwise some complex scripts may cause ban or send mail, etc).
Exactly this syntax will be impossible, because it conflicts with 3rd optional argument, which is currently ignore-pattern (it could work as in my example above). |
I see... those run-time dependency (or Python-script dependency) tag cannot be decided/finalized by fail2ban-regex moment without truly code execution. In that case, we make requirement simpler, as your suggestion, we specify action (or tag) via shell command parameters, and/or dump tags mentioned in filter config file, which is supplied via shell command as well. Again, correct me if I am thinking wrong. |
Latest version (since d1b7e2b) partially implementing this RFE, so Examples: $ fail2ban-regex -r -o row './fail2ban/tests/files/testcase01.log' sshd
[u'failed.dns.ch', 1577789999.0, {'dns': u'failed.dns.ch', 'users': set([u'kevin']), 'ip6': None, 'user': u'kevin', 'ip4': None, 'mlfid': u' [sshd] '}],
...
['87.142.124.10', 1577789999.0, {'dns': None, 'users': set([u'kevin']), 'ip6': None, 'user': u'kevin', 'ip4': u'87.142.124.10', 'mlfid': u' [sshd] '}],
$ fail2ban-regex -r -o id './fail2ban/tests/files/testcase01.log' sshd | uniq -c
3 failed.dns.ch
3 193.168.0.128
4 87.142.124.10
$ fail2ban-regex -r -o user './fail2ban/tests/files/testcase01.log' sshd | uniq
kevin
This facilities will be released with 0.10.5 (and 0.11). |
#2909 (comment) illustrates some PoC extending |
This may be a dumb requirement (not yet know if there is alternative way to fulfill). But if fail2ban-regex can supply a function to output the possible action to take, that can be quite helpful to understand the final outcome of complicate Python string interpolation of fail2ban tags...
The text was updated successfully, but these errors were encountered: