Commit graph

3279 commits

Author SHA1 Message Date
sebres
af4b13115b code and config review after rebase to current master 2015-11-02 14:04:57 +01:00
sebres
4dc7744927 asyncserver (asyncore) code fixed and test cases repaired (always delete temp files, wait for end of thread/server, etc)
definitely closes gh-161, also other usage of asyncore event loop (in test_smtp.py)
repair cache in ipToName (can returns None), precaching of invalid IPs (according to RFC 5737) to stop endless wait for resolving it in test cases.
2015-11-02 14:04:57 +01:00
sebres
9181ca338b SetupTest should run at version of python currently installed (resp. active one), skip if started with another version. 2015-11-02 14:04:56 +01:00
sebres
66e9e14f23 - filtering of test cases extended for method additionally to class (matches method only not whole class for regexp matched method name);
- new options for "fail2ban-testcases" introduced: "-g" or "--no-gamin" and "-m" or "--memory-db", both are true also if "-f" or "--fast" specified,
  for example: `fail2ban-testcases -ngm` will runs faster (because no network, no gamin, memory database)
  but will use the same default sleep intervals as in production (in comparison to -nf);
- seekToTime rewritten, accuracy increased by seekToTime, extended for all FileFilter (PyInotify, Gamin also), test cases extended etc.
- common performance optimized and code reviewed;
2015-11-02 14:04:56 +01:00
sebres
817852f083 test cases extended, code review (+ python 3.x compatibility);
database test cases extended - enable deleted (disabled) jail in addJail;
2015-11-02 14:04:55 +01:00
Yaroslav Halchenko
24a1e8e605 RF: use descriptive loop variable (oldticket) and matching associated variable suffixes (old) 2015-11-02 14:04:54 +01:00
Yaroslav Halchenko
454de867e7 RF: make Jail new style class, avoiding multiple inheritance with object 2015-11-02 14:04:54 +01:00
Yaroslav Halchenko
381e40e7a4 RF: is_alive -> isAlive to stay consistent in camelCasing 2015-11-02 14:04:52 +01:00
sebres
4157adf5fe - performance of fail2ban optimized
-- cache dnsToIp, ipToName to prevent long wait during retrieving of ip/name for wrong dns or lazy dns-system;
   -- instead of simple "sleep" used conditional wait "wait_for", that internal increases sleep interval up to sleeptime;
   -- ticket / banmanager / failmanager modules are performance optimized;
- performance of test cases optimized:
   -- added option "--fast" to decrease wait intervals, avoid passive waiting, and skip few very slow test cases;
- code review after partially cherry pick of branch 'ban-time-incr' (see gh-716)
   -- ticket module prepared to easy merge with newest version of 'ban-time-incr', now additionally holds banTime, banCount and json-data;
   -- executeCmd partially moved from action to new module utils, etc.
   -- python 2.6 compatibility;
- testExecuteTimeoutWithNastyChildren: test case repaired - wait for pid file inside bash, kill tree in any case (gh-1155);
- testSocket: test case repaired - wait for server thread starts a socket (listener)
2015-11-02 14:04:52 +01:00
sebres
d7c4df5acd code review, test case extended; 2015-11-02 14:04:51 +01:00
sebres
66c66bdf4c code review and few new test cases 2015-11-02 14:04:50 +01:00
sebres
34d7973c81 increase code coverage 2015-11-02 14:04:50 +01:00
sebres
af8d6325e6 normalizing time config entries: use time abbreviation (str2seconds) for all time options such 'dbpurgeage', 'bantime', 'findtime', ex.: default '1d' instead '86400';
code review and test case extended;
2015-11-02 14:04:49 +01:00
sebres
515032b6e6 The tricky bug fixed - last position of log file will be never retrieved (#795):
addJail (executed before addLog) early uses a "INSERT OR REPLACE" statement to update "enabled" to 1 (and add jail the first time used at once), but this syntax in sqlite always deletes an entry (cause of constraint) and inserts it again, so because of CASCADE all log entries with this jail will be also deleted from logs table.
2015-11-02 14:02:13 +01:00
sebres
60db8b68a6 filter, datedetector, datetemplate: performance optimizing of combination datedetector.matchTime/getTime2, because early getTime search a template and call template.matchTime again (so the date parsing was really executed twice, now just once);
debug logging optimized;
added info line log "Start Fail2ban ..." after changed logging target;
2015-11-02 14:02:13 +01:00
sebres
c24953c84d prevent completely read of big files first time (after start of service), initial seek to start time using half-interval search algorithm (see issue #795):
now polling backend only (currently not implemented for gamin and pyinotify backends);
python3/pypy compatibility fix + removing obsolete code
2015-11-02 14:02:12 +01:00
sebres
801e88cdd6 test cases extended;
code review
2015-11-02 14:02:11 +01:00
sebres
03dfff04a5 static method forgotten; 2015-11-02 14:02:11 +01:00
sebres
ee94daa121 introduced string to seconds (str2seconds) for configuration entries with time;
todo: expands it for all time config entries;
2015-11-02 14:02:10 +01:00
sebres
5767191988 fixed misleading documentation of banaction 2015-11-01 17:08:00 +01:00
sebres
fcf03790f4 fixed misleading documentation of banaction 2015-11-01 17:05:02 +01:00
Serg G. Brester
eef7771b4e Merge pull request #1238 from sebres/fix/gh-1216
Fixed directly defined banaction for allports jails like pam-generic, recidive, etc
2015-10-31 13:17:04 +01:00
sebres
e825e977cc Nginx log paths extended (prefixed with "*" wildcard)
closes gh-1237
2015-10-30 17:51:30 +01:00
sebres
f359ed8c36 Fixed directly defined banaction for allports jails like pam-generic, recidive, etc with new default variable banaction_allports (+ man entries for both variables added);
closes gh-1216
2015-10-30 15:36:18 +01:00
sebres
53b39162a1 Shortly, much faster and stable version of regexp (possible because expression is start-anchored and does not contains closely to catch-all sub expressions) 2015-10-29 23:55:23 +01:00
sebres
6884593ab8 New filter nginx-limit-req ban hosts, that were failed through nginx by limit request processing rate (ngx_http_limit_req_module) 2015-10-29 23:15:20 +01:00
sebres
eb87638ead ChangeLog entry for OpenHAB home automation filter (gh-1223) 2015-10-26 15:56:01 +01:00
1technophile
2861a957a9 filter for openhab domotic software authentication failure with the rest api and web interface + test cases;
closes gh-1223
2015-10-26 15:48:23 +01:00
Serg G. Brester
26517b0464 Merge pull request #1226 from pablorf-dev/master
Minor fix and enhancement (fake google domains)
2015-10-22 14:23:47 +02:00
Pablo Rodriguez Fernandez
2c576c64f8 Change domain filter regex
Change domain filter regex since there are other Google crawlers.
See "Google crawlers"
<https://support.google.com/webmasters/answer/1061943?hl=en>
2015-10-20 10:46:00 +02:00
Pablo Rodriguez Fernandez
74fcb219ab Enhanced Google domain detection in apache-fakegooglebot
Previously, an attacker could fake a domain like
crawl-1-1-1-1.googlebot.com.fake.net and get resolved. This change
avoids to resolve fake Google domains.
2015-10-20 10:45:53 +02:00
Pablo
7e6964dd9d Fix section jail.conf.5 manpage
The section of jail.conf manpage is wrong, should be 5, not 10
2015-10-15 10:40:56 +02:00
Serg G. Brester
3a5d4fdd26 Merge pull request #1221 from pablorf-dev/master
Add check in apache-fakegooglebot to protect against PTR fake record (gh-1221)
2015-10-14 11:33:06 +02:00
Pablo Rodriguez Fernandez
a28e6b442e Add check in apache-fakegooglebot to protect against PTR fake record
An attacker may return a PTR record which fakes a Googlebot's domain
name. This modification resolves the PTR records to verify it.

See "Verifying Googlebot":
<https://support.google.com/webmasters/answer/80553?vid=1-635800030504666679-1963774919>
2015-10-13 17:11:49 +02:00
Yaroslav Halchenko
16443f7b05 Merge pull request #1219 from agentmoller001/patch-1
Updated route.conf to clear warnings (Closes #1026)
2015-10-09 21:26:53 -04:00
agentmoller001
617302fcc2 Updated route.conf to clear warnings
Does not throw warnings when starting/restarting by adding three lines of code.
2015-10-09 18:16:36 -07:00
Yaroslav Halchenko
6fb5e3a494 removed outdated and "problematic" .pydevproject 2015-10-09 14:10:02 -04:00
Serg G. Brester
42598fbf26 Merge pull request #1215 from paulmenzel/strip-trailing-whitespace-from-files-under-files
files: Strip trailing whitespace from files
2015-10-08 18:39:40 +02:00
Paul Menzel
078e2048f2 files: Strip trailing whitespace from files
Run the command `StripWhitespace` from the [Vim Better Whitespace
Plugin](https://github.com/ntpeters/vim-better-whitespace).
2015-10-08 16:18:08 +02:00
sebres
2696ede251 mysqld-auth: Updated "Access denied ..." regex for MySQL 5.6 and later
closes gh-1211
2015-10-07 14:34:13 +02:00
sebres
61ac481703 IpToName test case fixed ('66.249.66.1' resp. 'crawl-66-249-66-1.googlebot.com' seems to be unresolvable) 2015-10-07 13:36:21 +02:00
Serg G. Brester
68db52474d Merge pull request #1206 from kevinoid/ssh-match-auth-fail
ssh.conf: Fix disconnect "Auth fail" matching
2015-10-05 10:15:53 +02:00
Kevin Locke
2a5c93cfb5 Update ChangeLog and THANKS for "Auth fail" changes
Document the changes from 36919d9f in the ChangeLog and add myself to
the THANKS file (at @sebres suggestion).

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-10-05 00:31:13 -07:00
Kevin Locke
42b0e9258d Test cases for ssh.conf disconnect "Auth fail"
Add test coverage for the new disconnect "Auth fail" matching added in
36919d9f.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-10-02 15:56:26 -07:00
Kevin Locke
36919d9f97 ssh.conf: Fix disconnect "Auth fail" matching
The regex for matching against "Auth fail" disconnect log message does
not match against current versions of ssh.  OpenSSH 5.9 introduced
privilege separation of the pre-auth process, which included
[logging through monitor.c](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/monitor.c.diff?r1=1.113&r2=1.114)
which adds " [preauth]" to the end of each message and causes the log
level to be prepended to each message.

It also fails to match against clients which send a disconnect message
with a description that is either empty or includes a space, since this
is the content in the log message after the disconnect code, per
[packet.c:1785](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/packet.c?annotate=1.215),
which was matched by \S+.  Although I have not observed this yet, I
couldn't find anything which would preclude it in [RFC
4253](https://tools.ietf.org/html/rfc4253#section-11.1) and since the
message is attacker-controlled it provides a way to avoid getting
banned.

This commit fixes both issues.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2015-10-02 15:46:29 -07:00
Yaroslav Halchenko
8311bad4ea Merge pull request #1204 from szepeviktor/patch-8
Added CloudFlare API error codes URL
2015-09-30 07:54:30 -07:00
Viktor Szépe
0d8968daa9 Added CloudFlare API error codes URL 2015-09-30 16:07:45 +02:00
Yaroslav Halchenko
7f3b31aa37 Merge pull request #1198 from yarikoptic/enh-split-comma
ENH: allow to split ignoreip by space and/or comma (Closes #1197)
2015-09-27 11:09:55 -04:00
Yaroslav Halchenko
ff06176e9e Merge remote-tracking branch 'origin/master' into enh-split-comma
* origin/master:
  DOC: changelog for the timeout change
  Set Timeout at urlopen to 3 seconds
  README :: init/service example mentions debian based systems as the example
  README :: fitted paragraph style
  BF: disable testing on python 3.2 until coverage gets a fix
  README :: Some style/grammar tweaks, and init/service script mention. Re: #1193
  Set Timeout at urlopen to 3 seconds
2015-09-27 00:52:14 -04:00
Yaroslav Halchenko
4c48e994eb Merge pull request #1201 from yoosefi/master
README :: Some style/grammar tweaks, and init/service script mention.…
2015-09-27 00:51:16 -04:00