https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/fail2ban/server/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/fail2ban/server/__pycache__/datetemplate.cpython-310.pyc
o

��_<0�@s&dZdZdZddlZddlZddlmZddlmZm	Z	m
Z
dd	lmZee
�Ze�d
�Ze�d�dfZe�d
�Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�dd�fZe�d�Ze�d�Ze�d�Ze�dej�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gd d!�d!e�Z"dS)"z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�N)�abstractmethod�)�reGroupDictStrptime�timeRE�getTimePatternRE�)�	getLoggerz(?<!(?:\(\?))(?<!\\)\((?!\?)z-^((?:\(\?\w+\))?\^?(?:\(\?\w+\))?)(.*?)(\$?)$z\1(\2)\3z^\{UNB\}z
^\{\^LN-BEG\}z^\((?:\?:)?\^\|\\b\|\\W\)z\(\?=\\b\|\\W\|\$\)$z-^\(*(?:\(\?\w+\))?(?:\^|\(*\*\*|\((?:\?:)?\^)z!(?<!\\)(?:\$\)?|\\b|\\s|\*\*\)*)$z)^\(*(?:\(\?\w+\))?\(*\*\*|(?<!\\)\*\*\)*$cCs|���dd�S)Nz**�)�group�replace)�m�r�>/usr/lib/python3/dist-packages/fail2ban/server/datetemplate.py�<lambda>.srz(^(?:\(\?\w+\))?(?:\^|\((?:\?:)?\^(?!\|))z(?<![\\\|])(?:\$\)?)$z(?<!\%)\%[aAbBpc]z(?<!\\)\{L?EPOCH\}c@sreZdZdZdZdZdZdZdd�Zdd	�Z	ddd�Z
ee	e
d
d�Zdd�Z
dd�Zeddd��Zedd��ZdS)�DateTemplatez�A template which searches for and returns a date from a log line.

	This is an not functional abstract class which other templates should
	inherit from.

	Attributes
	----------
	name
	regex
	��rrcCs.d|_d|_d|_d|_d|_d|_d|_dS)Nr
g�?r)�name�weight�flags�hits�time�_regex�_cRegex��selfrrr�__init__Is
zDateTemplate.__init__cC�|jS�N)rrrrr�getRegexRszDateTemplate.getRegexTcCs:|��}|ot�|�}|ot�|�}t�|�s#td�td|�}d|_|rP|j|dkr2tj	ntj
O_|dkr@d|}nd|}|j�d�sPd|j|_|r^|jtj
O_|d7}|jtj
@sqt�|�rq|jtj
O_|jtj@s�t�|�r�|jtjO_td�td|�}||_t�dd	|�d
|_d
S)a�Sets regex to use for searching for date in log line.

		Parameters
		----------
		regex : str
			The regex the template will use for searching for a date.
		wordBegin : bool
			Defines whether the regex should be modified to search at beginning of a
			word, by adding special boundary r'(?=^|\b|\W)' to start of regex.
			Can be disabled with specifying of ** at front of regex.
			Default True.
		wordEnd : bool
			Defines whether the regex should be modified to search at end of a word,
			by adding special boundary r'(?=\b|\W|$)' to end of regex.
			Can be disabled with specifying of ** at end of regex.
			Default True.

		Raises
		------
		re.error
			If regular expression fails to compile
		rr�startz(?=^|\b|\W)z
^(?:\W{0,2})?z	{^LN-BEG}z(?=\b|\W|$)�z  constructed regex %sN)�strip�RE_NO_WRD_BOUND_BEG�search�RE_NO_WRD_BOUND_END�
RE_GROUPED�RE_GROUP�subrr�
WORD_BEGIN�
LINE_BEGINr�
startswith�WORD_END�RE_LINE_BOUND_BEG�LINE_END�RE_LINE_BOUND_END�RE_DEL_WRD_BOUNDSr�logSys�logr)r�regex�	wordBegin�wordEnd�
boundBegin�boundEndrrr�setRegexUs0


zDateTemplate.setRegexz!Regex used to search for date.
		)�docc
CsN|js%z
t�|j�|_WdSty$}zt�d|j|j�|�d}~wwdS)z Compile regex by first usage.
		z Compile %r failed, expression %rN)r�re�compiler4�	Exceptionr2�errorr)r�errr�
_compileRegex�s���zDateTemplate._compileRegexcGs8|js|��|jj|g|�R�}|r|jd7_|S)z1Check if regex for date matches on a log line.
		r)rr@r%r)r�line�args�	dateMatchrrr�	matchDate�szDateTemplate.matchDateNcCstd��)aQAbstract method, which should return the date for a log line

		This should return the date for a log line, typically taking the
		date from the part of the line which matched the templates regex.
		This requires abstraction, therefore just raises exception.

		Parameters
		----------
		line : str
			Log line, of which the date should be extracted from.
		default_tz: if no explicit time zone is present in the line
                            passing this will interpret it as in that time zone.

		Raises
		------
		NotImplementedError
			Abstract method, therefore always returns this.
		zgetDate() is abstract)�NotImplementedError�rrArC�
default_tzrrr�getDate�szDateTemplate.getDatec
Cs$t�dt�dt�dt�d|����S)Nr
)�RE_EXEANC_BOUND_BEGr)�RE_EXSANC_BOUND_BEG�RE_EXLINE_BOUND_BEG�RE_EXLINE_NO_BOUNDS)�patternrrr�unboundPattern�s
��zDateTemplate.unboundPattern�TT�NN)�__name__�
__module__�__qualname__�__doc__r+r/r*r-rr r9�propertyr4r@rDrrH�staticmethodrNrrrrr8s$	
9�rc@s$eZdZdZddd�Zd	dd�ZdS)
�	DateEpochz�A date template which searches for Unix timestamps.

	This includes Unix timestamps which appear at start of a line, optionally
	within square braces (nsd), or on SELinux audit log lines.

	Attributes
	----------
	name
	regex
	FNcs�t�|�|s	dn||_||_d|_d�|r|sdn||_d�|r9dt��fdd�|�d	}d
|_|�|�dS|sHd�}|j|dd
�dSd�}|j|ddd�dS)N�Epochrz\d{10,11}\b(?:\.\d{3,6})?�	LongEpochz'\d{10,11}(?:\d{3}(?:\.\d{1,6}|\d{3})?)?�(csd�S)Nz(%s)r)�v��epochRErrr�sz$DateEpoch.__init__.<locals>.<lambda>�)rzf((?:^|(?P<square>(?<=^\[))|(?P<selinux>(?<=\baudit\()))%s)(?:(?(selinux)(?=:\d+\)))|(?(square)(?=\])))F�r5z*((?P<square>(?<=^\[))?%s)(?(square)(?=\]))r!T)r5r6)rrr�_longFrm�_grpIdx�RE_EPOCH_PATTERNr)r9)r�
lineBeginOnlyrM�longFrmr4rr\rr�s"
zDateEpoch.__init__cCsn|s|�|�}|r5|�|j�}|jr/t|�dkr/t|�dkr)d|vr)t|�d}nt|�d}t|�|fSdS)axMethod to return the date for a log line.

		Parameters
		----------
		line : str
			Log line, of which the date should be extracted from.
		default_tz: ignored, Unix timestamps are time zone independent

		Returns
		-------
		(float, str)
			Tuple containing a Unix timestamp, and the string of the date
			which was matched and in turned used to calculated the timestamp.
		�
��.i@Bi�N)rDrrar`�len�float)rrArCrGr[rrrrH�s
�zDateEpoch.getDate)FNFrP�rQrRrSrTrrHrrrrrW�s
rWcsheZdZdZe�\ZZe�e�Zd
�fdd�	Z	e
dd��Zejdd��Zd�fd	d
�	Z
ddd�Z�ZS)�DatePatternRegexz�Date template, with regex/pattern

	Parameters
	----------
	pattern : str
		Sets the date templates pattern.

	Attributes
	----------
	name
	regex
	pattern
	Ncs6tt|���d|_|dur|j|fi|��dSdSr)�superrkr�_patternr9)rrM�kwargs��	__class__rrrs
�zDatePatternRegex.__init__cCr)aVThe pattern used for regex with strptime "%" time fields.

		This should be a valid regular expression, of which matching string
		will be extracted from the log line. strptime style "%" fields will
		be replaced by appropriate regular expressions, or custom regex
		groups with names as per the strptime fields can also be used
		instead.
		)rmrrrrrMs
zDatePatternRegex.patterncCs|�|�dSr)r9)rrMrrrrM(sTc
s�||_t�|�rt�d|�}d}}|r!t�|�r!t�d|�}d}z'|j�d|�}||j|_|t}t	�|�r<d|}t
t|��|||�WdSt
y\}ztd||f��d}~ww)Nr
Fr!z%(\1)sz(?iu)zWFailed to set datepattern '%s' (may be an invalid format or unescaped percent char): %s)rmrLr%r)rK�
_patternRE�_patternNamerr�RE_ALPHA_PATTERNrlrkr9r=�	TypeError)rrMr5r6�fmtr4r?rorrr9,s$

��zDatePatternRegex.setRegexcCs*|s|�|�}|rt|��|d�|fSdS)a�Method to return the date for a log line.

		This uses a custom version of strptime, using the named groups
		from the instances `pattern` property.

		Parameters
		----------
		line : str
			Log line, of which the date should be extracted from.
		default_tz: optionally used to correct timezone

		Returns
		-------
		(float, str)
			Tuple containing a Unix timestamp, and the string of the date
			which was matched and in turned used to calculated the timestamp.
		)rGN)rDr�	groupdictrFrrrrHCs
��zDatePatternRegex.getDaterrOrP)rQrRrSrTrrqrrr;r<rrUrM�setterr9rH�
__classcell__rrrorrks



rkc@s$eZdZdZddd�Zd	dd�ZdS)
�
DateTai64nz`A date template which matches TAI64N formate timestamps.

	Attributes
	----------
	name
	regex
	FcCs"t�|�d|_|jd|d�dS)N�TAI64Nz
@[0-9a-f]{24}r_)rrrr9)rr5rrrres
zDateTai64n.__init__NcCs:|s|�|�}|r|�d�}|dd�}t|d�|fSdS)aqMethod to return the date for a log line.

		Parameters
		----------
		line : str
			Log line, of which the date should be extracted from.
		default_tz: ignored, since TAI is time zone independent

		Returns
		-------
		(float, str)
			Tuple containing a Unix timestamp, and the string of the date
			which was matched and in turned used to calculated the timestamp.
		rr�rfN)rDr�int)rrArCrG�value�seconds_since_epochrrrrHks

�zDateTai64n.getDate)FrPrjrrrrry\s
ry)#�
__author__�
__copyright__�__license__r;r�abcr�strptimerrr�helpersr	rQr2r<r'r(rLrKrJrIr$r&r1r.r0rs�
IGNORECASErb�objectrrWrkryrrrr�<module>s8






�


=X

https://t.me/RX1948 - 2025