Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abc12bc

Browse files
committed
more refactoring
1 parent 6828726 commit abc12bc

4 files changed

Lines changed: 68 additions & 33 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
from lib.core.common import paramToDict
3434
from lib.core.common import parseTargetUrl
3535
from lib.core.common import readInput
36-
from lib.core.common import smokeTest
3736
from lib.core.data import conf
3837
from lib.core.data import kb
3938
from lib.core.data import logger
4039
from lib.core.exception import exceptionsTuple
4140
from lib.core.exception import sqlmapNotVulnerableException
4241
from lib.core.session import setInjection
42+
from lib.core.smoketest import smokeTest
4343
from lib.core.target import initTargetEnv
4444
from lib.core.target import setupTargetEnv
4545
from lib.utils.parenthesis import checkForParenthesis

lib/core/common.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,35 +1404,3 @@ def longestCommonPrefix(*sequences):
14041404

14051405
def commonFinderOnly(initial, sequence):
14061406
return longestCommonPrefix(*filter(lambda x: x.startswith(initial), sequence))
1407-
1408-
def smokeTest():
1409-
import doctest
1410-
retVal = True
1411-
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
1412-
for file in files:
1413-
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
1414-
path = os.path.join(root, os.path.splitext(file)[0])
1415-
path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
1416-
path = path.replace(os.sep, '.').lstrip('.')
1417-
try:
1418-
__import__(path)
1419-
module = sys.modules[path]
1420-
except Exception, msg:
1421-
retVal = False
1422-
errMsg = "smoke test failed at importing module '%s' (%s):\n%s\n" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
1423-
logger.error(errMsg)
1424-
else:
1425-
# Run doc tests
1426-
# Reference: http://docs.python.org/library/doctest.html
1427-
(failure_count, test_count) = doctest.testmod(module)
1428-
if failure_count > 0:
1429-
retVal = False
1430-
1431-
infoMsg = "smoke test "
1432-
if retVal:
1433-
infoMsg += "PASSED"
1434-
logger.info(infoMsg)
1435-
else:
1436-
infoMsg += "FAILED"
1437-
logger.error(infoMsg)
1438-
return retVal

lib/core/profiling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
from lib.core.data import paths
3131

3232
def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
33+
"""
34+
This will run the program and present profiling data in a nice looking graph
35+
"""
3336
try:
3437
from extra.gprof2dot import gprof2dot
3538
from extra.xdot import xdot

lib/core/smoketest.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id$
5+
6+
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
7+
8+
Copyright (c) 2010 Miroslav Stampar <[email protected]>
9+
10+
sqlmap is free software; you can redistribute it and/or modify it under
11+
the terms of the GNU General Public License as published by the Free
12+
Software Foundation version 2 of the License.
13+
14+
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
15+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17+
details.
18+
19+
You should have received a copy of the GNU General Public License along
20+
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
21+
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
"""
23+
24+
import os
25+
import sys
26+
27+
from lib.core.data import conf
28+
from lib.core.data import logger
29+
from lib.core.data import paths
30+
31+
def smokeTest():
32+
"""
33+
This will run the basic smoke testing of a program
34+
"""
35+
import doctest
36+
retVal = True
37+
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
38+
for file in files:
39+
if os.path.splitext(file)[1].lower() == '.py' and file != '__init__.py':
40+
path = os.path.join(root, os.path.splitext(file)[0])
41+
path = path.replace(paths.SQLMAP_ROOT_PATH, '.')
42+
path = path.replace(os.sep, '.').lstrip('.')
43+
try:
44+
__import__(path)
45+
module = sys.modules[path]
46+
except Exception, msg:
47+
retVal = False
48+
errMsg = "smoke test failed at importing module '%s' (%s):\n%s\n" % (path, os.path.join(paths.SQLMAP_ROOT_PATH, file), msg)
49+
logger.error(errMsg)
50+
else:
51+
# Run doc tests
52+
# Reference: http://docs.python.org/library/doctest.html
53+
(failure_count, test_count) = doctest.testmod(module)
54+
if failure_count > 0:
55+
retVal = False
56+
57+
infoMsg = "smoke test "
58+
if retVal:
59+
infoMsg += "PASSED"
60+
logger.info(infoMsg)
61+
else:
62+
infoMsg += "FAILED"
63+
logger.error(infoMsg)
64+
return retVal

0 commit comments

Comments
 (0)