Skip to content

Commit

Permalink
PyPy patch for testing module
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Sep 29, 2021
1 parent 08eeb0f commit aeaa776
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from thirdparty.six import unichr as _unichr

# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.5.9.27"
VERSION = "1.5.9.28"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
Expand Down
2 changes: 1 addition & 1 deletion lib/core/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _setHashDB():
if os.path.exists(conf.hashDBFile):
if conf.flushSession:
if conf.hashDB:
conf.hashDB.close()
conf.hashDB.closeAll()

try:
os.remove(conf.hashDBFile)
Expand Down
2 changes: 1 addition & 1 deletion lib/core/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _thread():
for tag, value in (("<url>", url), ("<base>", base), ("<direct>", direct), ("<tmpdir>", tmpdir), ("<request>", request), ("<log>", log), ("<multiple>", multiple), ("<config>", config), ("<base64>", url.replace("id=1", "id=MZ=%3d"))):
options = options.replace(tag, value)

cmd = "%s \"%s\" %s --batch --non-interactive --debug" % (sys.executable, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py")), options)
cmd = "%s \"%s\" %s --batch --non-interactive --debug" % (sys.executable if ' ' not in sys.executable else '"%s"' % sys.executable, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py")), options)

if "<tmpfile>" in cmd:
handle, tmp = tempfile.mkstemp()
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/hashdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ def __init__(self, filepath):
self.filepath = filepath
self._write_cache = {}
self._cache_lock = threading.Lock()
self._connections = []

def _get_cursor(self):
threadData = getCurrentThreadData()

if threadData.hashDBCursor is None:
try:
connection = sqlite3.connect(self.filepath, timeout=3, isolation_level=None)
self._connections.append(connection)
threadData.hashDBCursor = connection.cursor()
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)")
connection.commit()
Expand All @@ -66,6 +68,14 @@ def close(self):
except:
pass

def closeAll(self):
for connection in self._connections:
try:
connection.commit()
connection.close()
except:
pass

@staticmethod
def hashKey(key):
key = getBytes(key if isinstance(key, six.text_type) else repr(key), errors="xmlcharrefreplace")
Expand Down

0 comments on commit aeaa776

Please sign in to comment.