config root man

Current Path : /compat/linux/proc/self/root/usr/share/fail2ban/testcases/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //compat/linux/proc/self/root/usr/share/fail2ban/testcases/filtertestcase.pyc

ESc@sdZdZddklZddkZddkZddkZddkZddk	Z	ddk
lZddkl
Z
ddklZlZlZddklZdd	klZdd
klZddklZlZdZd
ZddZddZdddddZdeifdYZ defdYZ!de!fdYZ"defdYZ#deifdYZ$defdYZ%dd k&l'Z'd!Z(d"eifd#YZ)d$eifd%YZ*d&eifd'YZ+dS((s9Copyright (c) 2004 Cyril Jaquier; 2012 Yaroslav HalchenkotGPLi(topenN(tJail(t
FilterPoll(tFiltert
FileFiltertDNSUtils(tFailManager(tFailManagerEmpty(t	DummyJail(t
mtimesleeptLogCaptureTestCasecGs+t|djo|d}nt|S(sOverload built in open so we could assure sufficiently large buffer

	Explicit .flush would be needed to assure that changes leave the buffer
	iiP(iP(tlentfopen(targs((s//usr/share/fail2ban/testcases/filtertestcase.pyR1sc
Cscy|iWnnXyti|WnnXtii|dotd|dndS(Ns.bak(tclosetostunlinktpathtexistst	_killfiletNone(tftname((s//usr/share/fail2ban/testcases/filtertestcase.pyR;scCs|i|d|d|i|d|p|dti|dti|d}}|i||t|djok|djo^tidjptii	do
d}nt
}|i||d||dndS(	sLittle helper to unify comparisons with the target entries

	and report helpful failure reports instead of millions of seconds ;)
	iiiis
tcygwincSst|iddS(s\rt(treprtreplace(tx((s//usr/share/fail2ban/testcases/filtertestcase.pyt<lambda>YsN(tassertEqualttimet	localtimeRRRtlineseptsystplatformt
startswithR(tutesttfoundtoutputtcountt
found_timetoutput_timetsrepr((s//usr/share/fail2ban/testcases/filtertestcase.pyt_assert_equal_entriesJs #
c
Cst|to|i}n|ii}|i}|i}|i}|i}||||f}	t	||	||dS(sXAdditional helper to wrap most common test case

	Test filter to contain target ticket
	N(
t
isinstanceR	t
getFailTickettfailManagerttoBant
getAttempttgetTimetgetIPt
getMatchesR,(
R%tfilter_R'R(ttickettattemptstdatetiptmatchesR&((s//usr/share/fail2ban/testcases/filtertestcase.pyt_assert_correct_last_attempt^sitaRc
Cstt|tot|d}nx t|D]}|i}q7Wd}g}xa|djp
||joF|i}	|dj	o|	|joPn|i|	|d7}q\Wt|tot||}n|idi	||i
tid|S(sWCopy lines from one file to another (which might be already open)

	Returns open fout
	triis
g?N(
R
R-tstrRtxrangetreadlineRtappendtwritetjointflushRtsleep(
tfintfouttntskiptmodet
terminal_linetit_tlinestl((s//usr/share/fail2ban/testcases/filtertestcase.pyt_copy_lines_between_filesqs*



tBasicFiltercBs#eZdZdZdZRS(cCstd|_dS(NR(Rtfilter(tself((s//usr/share/fail2ban/testcases/filtertestcase.pytsetUpscCso|i|iid|iit|i|iid|iit|i|iiddS(Ntwarntyestno(RRRt	getUseDnst	setUseDnstTruetFalse(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetSetUseDNSs
cCsddkl}tid
jo\ddkl}xYdddtdtd	fD]"}|i||||qRWnddkl}|i|dd
|i|dd|i|tdddS(Ni(t_binii(tbiniii
It0b1t0b0t0b1010(ii(t
server.filterR]R"tversion_infot__builtin__R^tlongR(RSR]R^RH((s//usr/share/fail2ban/testcases/filtertestcase.pyttestBins"$(t__name__t
__module__RTR\Rf(((s//usr/share/fail2ban/testcases/filtertestcase.pyRQs		tIgnoreIPcBsPeZdZdZdZdZdZdZdZdZ	RS(cCs/ti|t|_t|i|_dS(sCall before every test case.N(RRTR	tjailRRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRTs
cCsDd}x7|D]/}|ii||i|ii|q
WdS(Ns	127.0.0.1s192.168.0.1s255.255.255.255s99.99.99.99(s	127.0.0.1s192.168.0.1s255.255.255.255s99.99.99.99(RRtaddIgnoreIPt
assertTruetinIgnoreIPList(RStipListR9((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPOKs
cCsDd}x7|D]/}|ii||i|ii|q
WdS(NRs999.999.999.999tabcdefs
192.168.0.(Rs999.999.999.999Rps
192.168.0.(RRRktassertFalseRm(RSRnR9((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPNOKs
cCs|iid|i|iid|i|iid|i|iid|i|iid|i|iid|i|iiddS(Ns192.168.1.0/25s192.168.1.0s192.168.1.1s
192.168.1.127s
192.168.1.128s
192.168.1.255s
192.168.0.255(RRRkRlRmRq(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPCIDRscCs|iid|i|iid|i|iid|i|iid|i|iid|i|iid|i|iiddS(Ns192.168.1.0/255.255.255.128s192.168.1.0s192.168.1.1s
192.168.1.127s
192.168.1.128s
192.168.1.255s
192.168.0.255(RRRkRlRmRq(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPMaskscCsJ|iid|iid|iid|i|iddS(Ns192.168.1.0/25s<HOST>s%Thu Jul 11 01:21:43 2013 192.168.1.32sIgnore 192.168.1.32(RRRktaddFailRegextprocessLineAndAddRlt
_is_logged(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreInProcessLinescCsP|iid|iid|i|id|i|iddS(Ns192.168.1.0/25s192.168.1.32sIgnore 192.168.1.32s\Requested to manually ban an ignored IP 192.168.1.32. User knows best. Proceeding to ban it.(RRRktaddBannedIPRqRwRl(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreAddBannedIPscCsF|iid|i|iid|i|iiddS(Ns%testcases/files/ignorecommand.py <ip>s10.0.0.1s10.0.0.0(RRtsetIgnoreCommandRlRmRq(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreCommands(
RgRhRTRoRrRsRtRxRzR|(((s//usr/share/fail2ban/testcases/filtertestcase.pyRis									tIgnoreIPDNScBseZdZdZRS(cCs-|iid|i|iiddS(Nswww.epfl.chs
128.178.50.12(RRRkRlRm(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPDNSOKscCs_|iid|i|iid|i|iid|i|iiddS(Nswww.epfl.chs
127.177.50.10s
128.178.50.11s
128.178.50.13(RRRkRqRm(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIgnoreIPDNSNOKs(RgRhR~R(((s//usr/share/fail2ban/testcases/filtertestcase.pyR}s	tLogFilecBs)eZdZdZdZdZRS(stestcases/missingLogFilecCsti|dS(N(RRT(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRTscCsti|dS(N(RttearDown(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRscCs/td|_|it|iitidS(N(RRRRtassertRaisestIOErrort
addLogPathRtMISSING(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestMissingLogFiless(RgRhRRTRR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRs		tLogFileFilterPollcBs)eZdZdZdZdZRS(stestcases/files/testcase01.logcCs&td|_|iitidS(sCall before every test case.N(RRRRRRtFILENAME(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRTscCsdS(sCall after every test case.N((RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRscCs<|i|iiti|i|iitidS(N(RlRRt
isModifiedRRRq(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestIsModifieds(RgRhRRTRR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRs		tLogFileMonitorcBszeZdZdZdZdZddZdZdZdZ	d	Z
d
ZdZdZ
d
ZRS(s#Few more tests for FilterPoll API
	icCsti|d|_|_tiddti\}|_tid7_t|id|_	t
d|_|ii|i|ii
t|iiddS(sCall before every test case.tNAtfail2bansmonitorfailures-%d-iR<s(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>N(RRTRRRttempfiletmkstempRt
_setup_idxRtfileRRRt	setActiveRZRu(RSRM((s//usr/share/fail2ban/testcases/filtertestcase.pyRTs
"cCs$ti|t|i|idS(N(RRRRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyR*s
g@cCsZti}xGti||jo/|ii|iotSntidqWtS(s?Wait up to `delay` sec to assure that it was modified or not
		g?(RRRRRRZRER[(RStdelayttime0((s//usr/share/fail2ban/testcases/filtertestcase.pyR/scCs|idS(Ng?(R(RS((s//usr/share/fail2ban/testcases/filtertestcase.pytnotModified9scCsGti|id|ii|i|i|id|idS(NisUnable to open %s(RtchmodRRRtgetFailuresRlRw(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyt
testNoLogFile=scCsP|iid|i|id|iid|i|iddS(Nis6Cannot remove regular expression. Index 0 is not valid(RRtdelFailRegexRqRwRl(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestRemovingFailRegexBscCs*|iid|i|iddS(Nis6Cannot remove regular expression. Index 0 is not valid(RRtdelIgnoreRegexRlRw(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestRemovingIgnoreRegexHscCs}|i|i|i|i|i|itxbtdD]T}|iid||ii|i|i|i|itqMWti	|i
|i
d|i|it|i
d}|i|i|i|it|id||i|i|i|i|it||i
t|i
|i
ddS(Nisline%d
s.oldR<(
RlRRR
trangeRRBRDRtrenameRRR(RSRLR((s//usr/share/fail2ban/testcases/filtertestcase.pyttestNewChangeViaIsModifiedLs0


cCs|ii|i|it|iiitti	|i
dd|ii|i|it|iiitti	|i
dd|ii|it||itidS(NRHiRI(
RRRRRRR/R0RPtGetFailurestFILENAME_01RR;tFAILURES_01(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyt"testNewChangeViaGetFailures_simplejscCs|iitti|i|ii|it||iti	tti|idddd|_|ii|it||iti	dS(NRIiRJtw(
RRRPRRRRRRR;R(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyt#testNewChangeViaGetFailures_rewriteys
cCstti|idddd|_|ii|i|it|ii	i
|i|ii	idt
i|i|idtti|idd|ii|it||iti|i|ii	iddS(	NRHiRJRis.bakRIi(RPRRRRRRRRRR/R0RtgetFailTotalRRR;R(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyt testNewChangeViaGetFailures_moves(RgRht__doc__RRTRRRRRRRRRR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRs		
							(tLockcs[tiddifdtiffdYdif_S(s8Generator of TestCase's for different filters/backends
	Rsmonitorfailures_%stMonitorFailurescseZdZfdZdZddZdZddZddZ	d	Z
d
ZdZe
dZd
ZdZdZdZRS(icsd|_|_d|if|_id7_t|id|_t|_|i|_|ii|i|iit	|ii
d|ii|idS(sCall before every test case.Rs%s-%diR<s(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>N(
RRRR(RRR	RjRRRZRutstartt
_sleep_4_poll(RS(Rttestclass_nametFilter_(s//usr/share/fail2ban/testcases/filtertestcase.pyRTs
cSs1|ii|iit|i|idS(N(RRtstopRCRRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRs

g@cSsTti}xAti||jo)t|iotSntidqWtS(s@Wait up to `delay` sec to assure that it was modified or not
			g?(RRRjRZRER[(RSRR((s//usr/share/fail2ban/testcases/filtertestcase.pytisFilledscSs"t|itotndS(N(R-RRRR
(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRsg?cSs|i|S(N(R(RSR((s//usr/share/fail2ban/testcases/filtertestcase.pytisEmptyscSs3|i|idt||i|d|dS(NiR((RlRR;Rj(RStfailuresR(((s//usr/share/fail2ban/testcases/filtertestcase.pytassert_correct_last_attemptscSs|it|iiitti|idd|it|iii|i	t
|itti|idd|i|i
d|it
|id|it|iii|iti|it
|idtti|idd|itidS(NRHiRIiiiid(RRRRR/R0RPRRRRqRRjRlRRRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_grow_filescSsh|iitti|i|ititti|idddd|_|itidS(NRIiRJR(RRRPRRRRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_rewrite_files
c	Ss|tti|idddd|_|i|idtt|i	t
dddig}|ii
D]}|t|qj~|it|i	ii|i|i	iidti|i|id	tti|id
d|iti|i|i	iidtd|id	tti|idd|iti|i|i	iid
dS(NRHiRJRiis&Queue must be empty but it is not: %s.s, s.bakRIiidi(RPRRRRRlRtintR-RRRRCRjtqueueR>RRR/R0RRRRRRRR(RSt_[1]R((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_move_files,8cSs4tti|iddi|iti|i|ii	i
d|o$t|i|it
idntti|iddddditi|id|i|iti|i|ii	i
dtti|iddi|iti|i|ii	i
ddS(	NRHidig?s.newRIii	(RPRRRRRRRRRR/RRRRRERR(RStinterim_kill((s//usr/share/fail2ban/testcases/filtertestcase.pyt_test_move_into_file$s 

cSs|idtdS(NR(RR[(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_move_into_file>scSs|idtdS(NR(RRZ(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyt!test_move_into_file_after_removedAscSstti|idd|itit|iddidtti|idd|iti|i|i	i
idtd|iddS(NRHids.bak2RRi(RPRRRRRRRBRRRR/RRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_new_bogus_fileGscSstti|idd|iti|ii|itti|idd|i	|i
d|ii|i|itiddtti|idd|itidS(NRHidiR(i(RPRRRRRRRt
delLogPathRRlRR(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttest_delLogPathTsN(RgRhR(RTRRRRRRRRRR[RRRRR((RRR(s//usr/share/fail2ban/testcases/filtertestcase.pyRs	
							
sMonitorFailures<%s>(%s)(RtmktempRgtunittesttTestCase(R((RRRs//usr/share/fail2ban/testcases/filtertestcase.pytget_monitor_failures_testcases%RcBseZdZdZdZdZdZddddgdfZd	Zd
Z	dZ
dddZd
Z
dZdZdZdZdZdZRS(stestcases/files/testcase01.logstestcases/files/testcase02.logstestcases/files/testcase03.logstestcases/files/testcase04.logs#testcases/files/testcase-usedns.logs
193.168.0.128igſAsWAug 14 11:59:59 [sshd] error: PAM: Authentication failure for kevin from 193.168.0.128
cCs#td|_|iitdS(sCall before every test case.N(RRRRRRZ(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRTscCsdS(sCall after every test case.N((RS((s//usr/share/fail2ban/testcases/filtertestcase.pyRscCs|iitidt|i|iidid|iidi|i|iidi	d|ii
ti|i|iigdS(NttailiiuR(RRRRRRZRt
getLogPathtgetPosRR@R(RS((s//usr/share/fail2ban/testcases/filtertestcase.pyttestTails##cCsg|pti}|pti}|ii||iid|ii|t||i|dS(Ns(?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>$(RRRRRRRuRR;(RStfilenameR((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailures01sc
Cstidddd}ttit|d}}x.|iD] }|id|idqDW|i|i|i	d|d	ti
d
 g}ti
dD]}||iddq~ft||dS(
Ntprefixttmp_fail2bantsuffixtcrlfRs%s
s
RRiis
(RRRRRt	readlinesRBtrstripRRRR(RStfnameRFRGRORR((s//usr/share/fail2ban/testcases/filtertestcase.pyttestCRLFFailures01s



3cCs~dddg}d
D]}|d|q~f}|iiti|iid	|iitit||i|dS(Ns141.3.81.106igxſAi5i6i9i:siAug 14 11:%d:59 i60p295 sshd[12365]: Failed publickey for roehl from ::ffff:141.3.81.106 port 51332 ssh2
sFailed .* from <HOST>(i5i6i9i:(RRRRtFILENAME_02RuRR;(RSRtmR'((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailures02s	!cCsSd}|iiti|iid|iitit||i|dS(Ns203.162.223.135igzſAs%error,relay=<HOST>,.*550 User unknown(s203.162.223.135igzſA(RRRRtFILENAME_03RuRR;(RSR'((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailures03s
cCsddg}|iiti|iid|iitiy4x-t|D]\}}t||i|qRWWntj
onXdS(	Ns
212.41.96.186igſAs
212.41.96.185gſAsInvalid user .* <HOST>(s
212.41.96.186igſA(s
212.41.96.185igſA(	RRRRtFILENAME_04RuRt	enumerateR;R(RSR'RLtout((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailures04s	
cCsdddddgf}ddddgf}xd|fd|fd	|ffD]x\}}tdd
|}|it|iid|iti|i	d|i
tit|||qOWdS(Ns93.184.216.119igxſAsaAug 14 11:54:59 i60p295 sshd[12365]: Failed publickey for roehl from example.com port 51332 ssh2
skAug 14 11:58:59 i60p295 sshd[12365]: Failed publickey for roehl from ::ffff:93.184.216.119 port 51332 ssh2
iRVRWRUtuseDnssFailed .* from <HOST>(RRRRZR/tsetMaxRetryRRtFILENAME_USEDNSRuRR;(RSt
output_yest	output_noRR'R5((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailuresUseDNSs 			


cCscd}|iiti|iid|iid|iitit||i|dS(Ns141.3.81.106ig@yſAsFailed .* from <HOST>sAccepted .* from <HOST>(s141.3.81.106ig@yſA(RRRRRRuRR;(RSR'((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailuresMultiRegexscCsyd}|iiti|iid|iid|iid|iiti|it|ii	i
dS(Ns141.3.81.106ig@yſAsFailed .* from <HOST>sAccepted .* from <HOST>s	for roehl(s141.3.81.106ig@yſA(RRRRRRutaddIgnoreRegexRRRR/R0(RSR'((s//usr/share/fail2ban/testcases/filtertestcase.pyttestGetFailuresIgnoreRegexsN(RgRhRRRRRRRTRRRRRRRRRRR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRts$							
					t
DNSUtilsTestscBseZdZdZRS(cCsptidd}|i|gtidd}|i|dgtidd}|i|dgdS(Nswww.example.comRWRUs93.184.216.119RV(RttextToIpR(RStres((s//usr/share/fail2ban/testcases/filtertestcase.pyt
testUseDnsscCsjdddg}xT|D]L}ti|d}|djo|i|dgq|i|gqWdS(Nswww.example.coms!doh1.2.3.4.buga.xxxxx.yyy.invalids1.2.3.4.buga.xxxxx.yyy.invalidRVs93.184.216.119(RRR(RSt	hostnamestsR((s//usr/share/fail2ban/testcases/filtertestcase.pyttestTextToIps	
(RgRhRR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRs	t	JailTestscBseZdZRS(cCstddd}dS(Nttesttbackendtpolling(R(RSRj((s//usr/share/fail2ban/testcases/filtertestcase.pyttestSetBackend_gh83s(RgRhR(((s//usr/share/fail2ban/testcases/filtertestcase.pyRs(,t
__copyright__t__license__RdRR
RRR"RRtserver.jailRtserver.filterpollRRbRRRtserver.failmanagerRRt	dummyjailR	tutilsR
RRRR,R;RPRRQRiR}RRRt	threadingRRRRR(((s//usr/share/fail2ban/testcases/filtertestcase.pys<module>s<	
	#8
	

Man Man