mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 05:04:11 +03:00
more refactoring
This commit is contained in:
parent
682872689a
commit
abc12bc361
|
@ -33,13 +33,13 @@ from lib.core.common import getUnicode
|
|||
from lib.core.common import paramToDict
|
||||
from lib.core.common import parseTargetUrl
|
||||
from lib.core.common import readInput
|
||||
from lib.core.common import smokeTest
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.exception import exceptionsTuple
|
||||
from lib.core.exception import sqlmapNotVulnerableException
|
||||
from lib.core.session import setInjection
|
||||
from lib.core.smoketest import smokeTest
|
||||
from lib.core.target import initTargetEnv
|
||||
from lib.core.target import setupTargetEnv
|
||||
from lib.utils.parenthesis import checkForParenthesis
|
||||
|
|
|
@ -1404,35 +1404,3 @@ def longestCommonPrefix(*sequences):
|
|||
|
||||
def commonFinderOnly(initial, sequence):
|
||||
return longestCommonPrefix(*filter(lambda x: x.startswith(initial), sequence))
|
||||
|
||||
def smokeTest():
|
||||
import doctest
|
||||
retVal = True
|
||||
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
|
||||
path = os.path.join(root, os.path.splitext(file)[0])
|
||||
path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
|
||||
path = path.replace(os.sep, '.').lstrip('.')
|
||||
try:
|
||||
__import__(path)
|
||||
module = sys.modules[path]
|
||||
except Exception, msg:
|
||||
retVal = False
|
||||
errMsg = "smoke test failed at importing module '%s' (%s):\n%s\n" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
|
||||
logger.error(errMsg)
|
||||
else:
|
||||
# Run doc tests
|
||||
# Reference: http://docs.python.org/library/doctest.html
|
||||
(failure_count, test_count) = doctest.testmod(module)
|
||||
if failure_count > 0:
|
||||
retVal = False
|
||||
|
||||
infoMsg = "smoke test "
|
||||
if retVal:
|
||||
infoMsg += "PASSED"
|
||||
logger.info(infoMsg)
|
||||
else:
|
||||
infoMsg += "FAILED"
|
||||
logger.error(infoMsg)
|
||||
return retVal
|
||||
|
|
|
@ -30,6 +30,9 @@ from lib.core.data import logger
|
|||
from lib.core.data import paths
|
||||
|
||||
def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
|
||||
"""
|
||||
This will run the program and present profiling data in a nice looking graph
|
||||
"""
|
||||
try:
|
||||
from extra.gprof2dot import gprof2dot
|
||||
from extra.xdot import xdot
|
||||
|
|
64
lib/core/smoketest.py
Normal file
64
lib/core/smoketest.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
$Id$
|
||||
|
||||
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
|
||||
|
||||
Copyright (c) 2010 Miroslav Stampar <miroslav.stampar@gmail.com>
|
||||
|
||||
sqlmap is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation version 2 of the License.
|
||||
|
||||
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
||||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import logger
|
||||
from lib.core.data import paths
|
||||
|
||||
def smokeTest():
|
||||
"""
|
||||
This will run the basic smoke testing of a program
|
||||
"""
|
||||
import doctest
|
||||
retVal = True
|
||||
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
|
||||
path = os.path.join(root, os.path.splitext(file)[0])
|
||||
path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
|
||||
path = path.replace(os.sep, '.').lstrip('.')
|
||||
try:
|
||||
__import__(path)
|
||||
module = sys.modules[path]
|
||||
except Exception, msg:
|
||||
retVal = False
|
||||
errMsg = "smoke test failed at importing module '%s' (%s):\n%s\n" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
|
||||
logger.error(errMsg)
|
||||
else:
|
||||
# Run doc tests
|
||||
# Reference: http://docs.python.org/library/doctest.html
|
||||
(failure_count, test_count) = doctest.testmod(module)
|
||||
if failure_count > 0:
|
||||
retVal = False
|
||||
|
||||
infoMsg = "smoke test "
|
||||
if retVal:
|
||||
infoMsg += "PASSED"
|
||||
logger.info(infoMsg)
|
||||
else:
|
||||
infoMsg += "FAILED"
|
||||
logger.error(infoMsg)
|
||||
return retVal
|
Loading…
Reference in New Issue
Block a user