HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/fail2ban/tests/__pycache__/clientbeautifiertestcase.cpython-38.pyc
U

ܜ^/$�@s^dZdZdZddlZddlmZddlmZddlmZdd	l	m
Z
mZGd
d�dej�Z
dS)zAlexander Koeppez>Copyright (c) 2016 Cyril Jaquier, 2011-2013 Yaroslav HalchenkoZGPL�N�)�
Beautifier)�version)�IPAddr)�UnknownJailException�DuplicateJailExceptioncs�eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z�ZS)5�BeautifierTestcstt|���t�|_dS)z Call before every test case N)�superr�setUpr�b��self��	__class__��I/usr/lib/python3/dist-packages/fail2ban/tests/clientbeautifiertestcase.pyr
!szBeautifierTest.setUpcstt|���dS)z Call after every test case N)r	r�tearDownrrrrr&szBeautifierTest.tearDowncCs(dg}|j�|�|�|j��|�dS)N�test)r�setInputCmd�assertEqualZgetInputCmd)r
�cmdrrr�testGetInputCmd*szBeautifierTest.testGetInputCmdcCs&|j�dg�|�|j�d�d�dS)NZpingZpongzServer replied: pong�rrr�beautifyrrrr�testPing/szBeautifierTest.testPingcCs&|j�dg�|�|j�t�t�dS)Nr)rrrrrrrrr�testVersion3szBeautifierTest.testVersioncCs&|j�dg�|�|j�d�d�dS)N�add�sshzAdded jail sshrrrrr�testAddJail7szBeautifierTest.testAddJailcCs&|j�dg�|�|j�d�d�dS)N�startzJail startedrrrrr�
testStartJail;szBeautifierTest.testStartJailcCs(|j�ddg�|�|j�d�d�dS)N�stoprzJail stoppedrrrrr�testStopJail?szBeautifierTest.testStopJailcCs&|j�dg�|�|j�d�d�dS)Nr!zShutdown successfulrrrrr�testShutdownCszBeautifierTest.testShutdownc	Cs�|j�dg�ddddgff}d}|�|j�|�|�|j�ddg�ddd	d
gfddd
dtd�td�td�gfgff}d}|d7}|d7}|d7}|d7}|d7}|d7}|d7}|d7}|�|j�|�|�dS)NZstatus)zNumber of jailsrz	Jail listrZexim4z4Status
|- Number of jails:	0
`- Jail list:	ssh exim4ZFilter)zCurrently failedr)zTotal failedr)z	File list�/var/log/auth.logZActions)zCurrently banned�)zTotal bannedr%zBanned IP listz192.168.0.1z::ffff:10.2.2.1z2001:db8::1zStatus for the jail: ssh
z
|- Filter
z|  |- Currently failed:	0
z|  |- Total failed:	0
z#|  `- File list:	/var/log/auth.log
z`- Actions
z   |- Currently banned:	3
z   |- Total banned:	3
z6   `- Banned IP list:	192.168.0.1 10.2.2.1 2001:db8::1�rrrrr�r
�response�outputrrr�
testStatusGs<����zBeautifierTest.testStatuscCs&|j�dg�|�|j�d�d�dS)NZ	flushlogszrolled overzlogs: rolled overrrrrr�
testFlushLogslszBeautifierTest.testFlushLogscCs,|j�ddg�d}|�|j�d�|�dS)N�getZsyslogsocketz!Current syslog socket is:
`- auto�autor�r
r)rrr�testSyslogSocketpszBeautifierTest.testSyslogSocketcCs,|j�ddg�d}|�|j�d�|�dS)Nr,Z	logtargetz3Current logging target is:
`- /var/log/fail2ban.logz/var/log/fail2ban.logrr.rrr�
testLogTargetuszBeautifierTest.testLogTargetcCs,|j�ddg�d}|�|j�d�|�dS)Nr,ZloglevelzCurrent logging level is 'INFO'�INFOrr.rrr�testLogLevelzszBeautifierTest.testLogLevelcCsH|j�ddg�d}d|}|�|j�|�|�|�|j�d�d�dS)Nr,Zdbfilez"/var/lib/fail2ban/fail2ban.sqlite3zCurrent database file is:
`- �Database currently disabledrr'rrr�
testDbFiles
zBeautifierTest.testDbFilecCs@|j�ddg�d}|�|j�d�|�|�|j�d�d�dS)Nr,Z
dbpurgeagez.Current database purge age is:
`- 86400secondsi�Qr3rr.rrr�testDbPurgeAge�szBeautifierTest.testDbPurgeAgecCs�|j�dddg�g}d}|�|j�|�|�dg}d}|�|j�|�|�|j�dddd	g�d	dg}d
}|d7}|�|j�|�|�|j�dddd	g�dg}|�|j�|�|�dS)
Nr,�sshdZlogpathzNo file is currently monitoredr$z3Current monitored log file(s):
`- /var/log/auth.log�setZ
addlogpathz/var/log/messageszCurrent monitored log file(s):
z)|- /var/log/messages
`- /var/log/auth.logZ
dellogpathr)r
r(r)Z	outputaddrrr�testLogPath�szBeautifierTest.testLogPathcCs.|j�dddg�d}|�|j�d�|�dS)Nr,r6Zlogencodingz%Current log encoding is set to:
UTF-8zUTF-8rr.rrr�testLogEncoding�szBeautifierTest.testLogEncodingcCs�|j�dddg�|�|j�g�d�|j�dddg�ddgg}d	}|d
7}|�|j�|�|�|�ddg�|d7}|�|j�|�|�|j�ddd
g�|�|d�|�|j�|�|�d�d�dS)Nr,r6ZjournalmatchzNo journal match filter setr7ZaddjournalmatchZ
_SYSTEMD_UNITzsshd.servicezCurrent match filter:
z_SYSTEMD_UNIT sshd.serviceZ_COMMz
 + _COMM sshdZdeljournalmatch�z + r)rrrr�append�remove�splitr'rrr�testJournalMatch�s
zBeautifierTest.testJournalMatchcCsf|j�dddg�d}d}|�|j�d�|d�|�|j�|�|d�|�|j�d�|d	�dS)
Nr,r6ZdatepatternzCurrent date pattern set to: )N�Default DetectorszNot set/requiredr?)rrztest (test)r�r
r)r(rrr�testDatePattern�s���zBeautifierTest.testDatePatterncCs�|j�dddg�d}|�|j�g�|�|j�dddg�tdd�td	�td
d�td�g}d
}|d7}|d7}|d7}|d7}|�|j�|�|�dS)Nr,r6Zignoreipz No IP address/network is ignoredr7Zaddignoreipz	127.0.0.0�z::1z
2001:db8::� z::ffff:10.0.2.1z)These IP addresses/networks are ignored:
z|- 127.0.0.0/8
z|- ::1
z|- 2001:db8::/32
z`- 10.0.2.1r&r@rrr�testIgnoreIP�s�zBeautifierTest.testIgnoreIPcCsR|j�dddg�d}|�|j�g�|�d}|d7}|�|j�ddg�|�dS)	Nr,r6Z	failregexz No regular expression is definedz.The following regular expression are defined:
z|- [0]: ^$
`- [1]: .*z^$z.*rr.rrr�
testFailRegex�szBeautifierTest.testFailRegexcCsP|j�dddg�d}|�|j�g�|�d}|d7}|�|j�dg�|�dS)Nr,r6ZactionszNo actions for jail sshdz)The jail sshd has the following actions:
ziptables-multiportrr.rrr�testActions�szBeautifierTest.testActionscCsT|j�ddddg�d}|�|j�g�|�d}|d7}d}|�|j�|�|�dS)	Nr,r6Zactionproperties�iptablesz+No properties for jail sshd action iptablesz;The jail sshd action iptables has the following properties:z
actionban, actionunban)Z	actionbanZactionunbanrr@rrr�testActionProperties�sz#BeautifierTest.testActionPropertiescCsT|j�ddddg�d}|�|j�g�|�d}|d7}|�|j�dd	g�|�dS)
Nr,r6Z
actionmethodsrGz(No methods for jail sshd action iptablesz9The jail sshd action iptables has the following methods:
z
ban, unbanZbanZunbanrr.rrr�testActionMethods�sz BeautifierTest.testActionMethodscCs^td�}d}|�|j�|�|�td�}d}|�|j�|�|�d}|�|j�t��|�dS)Nr6z(Sorry but the jail 'sshd' does not existzThe jail 'sshd' already existsz Sorry but the command is invalid)rrrZ
beautifyErrorr�
IndexErrorr'rrr�testBeautifyError�sz BeautifierTest.testBeautifyError)�__name__�
__module__�__qualname__r
rrrrrr r"r#r*r+r/r0r2r4r5r8r9r>rArDrErFrHrIrK�
__classcell__rrrrrs4%		

r)�
__author__Z
__copyright__Z__license__ZunittestZclient.beautifierrrZserver.ipdnsr�
exceptionsrrZTestCaserrrrr�<module>s