MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / isDBMSVersionAtLeast

Function isDBMSVersionAtLeast

lib/core/common.py:3353–3420  ·  view source on GitHub ↗

Checks if the recognized DBMS version is at least the version specified >>> pushValue(kb.dbmsVersion) >>> kb.dbmsVersion = "2" >>> isDBMSVersionAtLeast("1.3.4.1.4") True >>> isDBMSVersionAtLeast(2.1) False >>> isDBMSVersionAtLeast(">2") False >>> isDBMSVersi

(minimum)

Source from the content-addressed store, hash-verified

3351 return retVal
3352
3353def isDBMSVersionAtLeast(minimum):
3354 """
3355 Checks if the recognized DBMS version is at least the version specified
3356
3357 >>> pushValue(kb.dbmsVersion)
3358 >>> kb.dbmsVersion = "2"
3359 >>> isDBMSVersionAtLeast("1.3.4.1.4")
3360 True
3361 >>> isDBMSVersionAtLeast(2.1)
3362 False
3363 >>> isDBMSVersionAtLeast(">2")
3364 False
3365 >>> isDBMSVersionAtLeast(">=2.0")
3366 True
3367 >>> kb.dbmsVersion = "<2"
3368 >>> isDBMSVersionAtLeast("2")
3369 False
3370 >>> isDBMSVersionAtLeast("1.5")
3371 True
3372 >>> kb.dbmsVersion = "MySQL 5.4.3-log4"
3373 >>> isDBMSVersionAtLeast("5")
3374 True
3375 >>> kb.dbmsVersion = popValue()
3376 """
3377
3378 retVal = None
3379
3380 if not any(isNoneValue(_) for _ in (Backend.getVersion(), minimum)) and Backend.getVersion() != UNKNOWN_DBMS_VERSION:
3381 version = Backend.getVersion().replace(" ", "").rstrip('.')
3382
3383 correction = 0.0
3384 if ">=" in version:
3385 pass
3386 elif '>' in version:
3387 correction = VERSION_COMPARISON_CORRECTION
3388 elif '<' in version:
3389 correction = -VERSION_COMPARISON_CORRECTION
3390
3391 version = extractRegexResult(r"(?P<result>[0-9][0-9.]*)", version)
3392
3393 if version:
3394 if '.' in version:
3395 parts = version.split('.', 1)
3396 parts[1] = filterStringValue(parts[1], '[0-9]')
3397 version = '.'.join(parts)
3398
3399 try:
3400 version = float(filterStringValue(version, '[0-9.]')) + correction
3401 except ValueError:
3402 return None
3403
3404 if isinstance(minimum, six.string_types):
3405 if '.' in minimum:
3406 parts = minimum.split('.', 1)
3407 parts[1] = filterStringValue(parts[1], '[0-9]')
3408 minimum = '.'.join(parts)
3409
3410 correction = 0.0

Callers 5

cleanupPayloadMethod · 0.90
nullAndCastFieldMethod · 0.90
getUsersMethod · 0.90
escapeMethod · 0.90
escapeMethod · 0.90

Calls 5

isNoneValueFunction · 0.85
extractRegexResultFunction · 0.85
filterStringValueFunction · 0.85
getVersionMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…