mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-03 11:45:46 +03:00
Adding support for boldifying important logging messages
This commit is contained in:
parent
b2fe1c30f8
commit
569c9214bf
|
@ -133,7 +133,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
|||
if bold:
|
||||
params.append('1')
|
||||
|
||||
if params:
|
||||
if params and message:
|
||||
if message.lstrip() != message:
|
||||
prefix = re.search(r"\s+", message).group(0)
|
||||
message = message[len(prefix):]
|
||||
|
|
|
@ -80,6 +80,7 @@ from lib.core.exception import sqlmapSyntaxException
|
|||
from lib.core.log import FORMATTER
|
||||
from lib.core.log import LOGGER_HANDLER
|
||||
from lib.core.optiondict import optDict
|
||||
from lib.core.settings import BOLD_PATTERNS
|
||||
from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR
|
||||
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
|
||||
from lib.core.settings import DEFAULT_GET_POST_DELIMITER
|
||||
|
@ -695,11 +696,19 @@ def singleTimeLogMessage(message, level=logging.INFO, flag=None):
|
|||
kb.singleLogFlags.add(flag)
|
||||
logger.log(level, message)
|
||||
|
||||
def boldifyMessage(message):
|
||||
retVal = message
|
||||
|
||||
if any(_ in message for _ in BOLD_PATTERNS):
|
||||
retVal = setColor(message, True)
|
||||
|
||||
return retVal
|
||||
|
||||
def setColor(message, bold=False):
|
||||
retVal = message
|
||||
level = extractRegexResult(r"\[(?P<result>[A-Z ]+)\]", message) or kb.get("stickyLevel")
|
||||
|
||||
if hasattr(LOGGER_HANDLER, "level_map"): # colorizing handler
|
||||
if message and hasattr(LOGGER_HANDLER, "level_map"): # colorizing handler
|
||||
if bold:
|
||||
retVal = colored(message, color=None, on_color=None, attrs=("bold",))
|
||||
elif level:
|
||||
|
|
|
@ -26,6 +26,7 @@ from extra.oset.pyoset import oset
|
|||
from extra.socks import socks
|
||||
from lib.controller.checks import checkConnection
|
||||
from lib.core.common import Backend
|
||||
from lib.core.common import boldifyMessage
|
||||
from lib.core.common import dataToStdout
|
||||
from lib.core.common import getPublicTypeMembers
|
||||
from lib.core.common import extractRegexResult
|
||||
|
@ -410,7 +411,7 @@ def __adjustLoggingFormatter():
|
|||
return
|
||||
|
||||
def format(record):
|
||||
_ = FORMATTER._format(record)
|
||||
_ = boldifyMessage(FORMATTER._format(record))
|
||||
if kb.prependFlag:
|
||||
_ = "\n%s" % _
|
||||
kb.prependFlag = False
|
||||
|
|
|
@ -509,3 +509,6 @@ VALID_TIME_CHARS_RUN_THRESHOLD = 100
|
|||
|
||||
# Check for empty columns only if table is sufficiently large
|
||||
CHECK_ZERO_COLUMNS_THRESHOLD = 10
|
||||
|
||||
# Boldify all logger messages containing these "patterns"
|
||||
BOLD_PATTERNS = ("' injectable", "might be injectable", "' is vulnerable", "is not injectable")
|
||||
|
|
Loading…
Reference in New Issue
Block a user