getting rid of obsolete getCompiledRegex (in newer versions of Python regexes are already cached)

This commit is contained in:
Miroslav Stampar
2012-04-03 14:34:15 +00:00
parent 556b349be3
commit b0787f193c
8 changed files with 31 additions and 55 deletions

View File

@@ -9,7 +9,6 @@ See the file 'doc/COPYING' for copying permission
import re
from lib.core.common import getCompiledRegex
from lib.core.common import readXmlFile
from lib.core.convert import urldecode
from lib.core.data import paths
@@ -51,9 +50,7 @@ def checkPayload(payload):
if payload:
for rule, desc in rules:
regObj = getCompiledRegex(rule)
if regObj.search(payload):
if re.search(rule, payload):
detected = True
logger.warn("highly probable IDS/IPS detection: '%s: %s'" % (desc, payload))

View File

@@ -23,6 +23,7 @@ except (ImportError, OSError):
else:
_multiprocessing = multiprocessing
import re
import time
from hashlib import md5
@@ -35,7 +36,6 @@ from lib.core.common import Backend
from lib.core.common import checkFile
from lib.core.common import clearConsoleLine
from lib.core.common import dataToStdout
from lib.core.common import getCompiledRegex
from lib.core.common import getFileItems
from lib.core.common import getPublicTypeMembers
from lib.core.common import hashDBRetrieve
@@ -404,7 +404,7 @@ def hashRecognition(value):
elif regex == HASH.CRYPT_GENERIC:
if any((value.lower() == value, value.upper() == value)):
continue
elif getCompiledRegex(regex).match(value):
elif re.match(regex, value):
retVal = regex
break
@@ -574,7 +574,7 @@ def dictionaryAttack(attack_dict):
hash_ = hash_.split()[0]
if getCompiledRegex(hash_regex).match(hash_):
if re.match(hash_regex, hash_):
item = None
if hash_regex not in (HASH.CRYPT_GENERIC, HASH.WORDPRESS):

View File

@@ -14,7 +14,6 @@ from lib.core.common import calculateDeltaSeconds
from lib.core.common import dataToSessionFile
from lib.core.common import dataToStdout
from lib.core.common import Backend
from lib.core.common import getCompiledRegex
from lib.core.common import safeStringFormat
from lib.core.common import randomStr
from lib.core.common import replaceNewlineTabs
@@ -133,7 +132,7 @@ def resume(expression, payload):
return None
substringQuery = queries[Backend.getIdentifiedDbms()].substring.query
select = getCompiledRegex("\ASELECT ", re.I).search(expression)
select = re.search("\ASELECT ", expression, re.I)
_, length, regExpr = queryOutputLength(expression, payload)