cleaning up a bit for a configuration mess

This commit is contained in:
Miroslav Stampar
2011-06-16 11:42:13 +00:00
parent f515c9c9e0
commit 6f681b45ad
4 changed files with 100 additions and 97 deletions

View File

@@ -91,7 +91,6 @@ from lib.core.settings import MIN_TIME_RESPONSES
from lib.core.settings import PAYLOAD_DELIMITER
from lib.core.settings import REFLECTED_NON_ALPHA_NUM_REGEX
from lib.core.settings import REFLECTED_VALUE_MARKER
from lib.core.settings import TIME_DEFAULT_DELAY
from lib.core.settings import TIME_STDEV_COEFF
from lib.core.settings import DYNAMICITY_MARK_LENGTH
from lib.core.settings import REFLECTIVE_MISS_THRESHOLD

View File

@@ -58,6 +58,7 @@ from lib.core.data import paths
from lib.core.data import queries
from lib.core.datatype import advancedDict
from lib.core.datatype import injectionDict
from lib.core.defaults import defaults
from lib.core.enums import DBMS
from lib.core.enums import HTTPHEADER
from lib.core.enums import HTTPMETHOD
@@ -99,7 +100,6 @@ from lib.core.settings import SYBASE_ALIASES
from lib.core.settings import BURP_SPLITTER
from lib.core.settings import LOCALHOST
from lib.core.settings import MAX_NUMBER_OF_THREADS
from lib.core.settings import TIME_DEFAULT_DELAY
from lib.core.settings import TIME_DELAY_CANDIDATES
from lib.core.settings import UNKNOWN_DBMS_VERSION
from lib.core.settings import WEBSCARAB_SPLITTER
@@ -1287,10 +1287,9 @@ def __cleanupOptions():
debugMsg = "turning off --null-connection switch used indirectly by switch -o"
logger.debug(debugMsg)
# to distinguish explicit usage of --time-sec
if conf.timeSec is None:
if conf.timeSec not in kb.explicitSettings:
if conf.tor:
conf.timeSec = 2 * TIME_DEFAULT_DELAY
conf.timeSec = 2 * conf.timeSec
kb.adjustTimeDelay = False
warnMsg = "increasing default value for "
@@ -1298,7 +1297,6 @@ def __cleanupOptions():
warnMsg += "--tor switch was provided"
logger.warn(warnMsg)
else:
conf.timeSec = TIME_DEFAULT_DELAY
kb.adjustTimeDelay = True
else:
kb.adjustTimeDelay = False
@@ -1374,6 +1372,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
kb.dynamicParameters = False
kb.endDetection = False
kb.httpErrorCodes = {}
kb.explicitSettings = set()
kb.errorIsNone = True
kb.formNames = []
kb.headersCount = 0
@@ -1593,7 +1592,7 @@ def __setVerbosity():
def __mergeOptions(inputOptions, overrideOptions):
"""
Merge command line options with configuration file options.
Merge command line options with configuration file and default options.
@param inputOptions: optparse object with command line options.
@type inputOptions: C{instance}
@@ -1608,7 +1607,15 @@ def __mergeOptions(inputOptions, overrideOptions):
inputOptionsItems = inputOptions.__dict__.items()
for key, value in inputOptionsItems:
if key not in conf or (not conf[key] and value) or overrideOptions:
if key not in conf or value not in (None, False) or overrideOptions:
conf[key] = value
for key, value in conf.items():
if value:
kb.explicitSettings.add(key)
for key, value in defaults.items():
if not conf[key]:
conf[key] = value
def __setTrafficOutputFP():

View File

@@ -78,9 +78,6 @@ UNION_STDEV_COEFF = 7
# length of queue for candidates for time delay adjustment
TIME_DELAY_CANDIDATES = 3
# default time delay in seconds
TIME_DEFAULT_DELAY = 5
# HTTP timeout in silent mode
HTTP_SILENT_TIMEOUT = 3