Skip to content

Commit

Permalink
Patching some resource-related warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Apr 12, 2024
1 parent 1e9e33d commit 2f01cbf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
6 changes: 3 additions & 3 deletions data/txt/sha256sums.txt
Expand Up @@ -165,7 +165,7 @@ f9c96cd3fe99578bed9d49a8bdf8d76836d320a7c48c56eb0469f48b36775c35 lib/controller
99d0e94dd5fe60137abf48bfa051129fb251f5c40f0f7a270c89fbcb07323730 lib/controller/__init__.py
826c33f1105be4c0985e1bbe1d75bdb009c17815ad6552fc8d9bf39090d3c40f lib/core/agent.py
b2d69c99632da5c2acd0c0934e70d55862f1380a3f602cbe7456d617fb9c1fc9 lib/core/bigarray.py
ba3f0002aa93f8f21f06dbea343573c590b9e6ec160fc6668c15e68a970cfb12 lib/core/common.py
a4863238aba3a2d203c26127a4a7a6df873bd0c6f1cd798d4a7abcdc71a07cb6 lib/core/common.py
5c26b0f308266bc3a9679ef837439e38d1dc7a69eac6bd3422280f49aaf114d2 lib/core/compat.py
b60c96780cad4a257f91a0611b08cfcc52f242908c5d5ab2bf9034ef07869602 lib/core/convert.py
5e381515873e71c395c77df00bf1dd8c4592afc6210a2f75cbc20daf384e539f lib/core/data.py
Expand All @@ -187,11 +187,11 @@ bf77f9fc4296f239687297aee1fd6113b34f855965a6f690b52e26bd348cb353 lib/core/profi
4eff81c639a72b261c8ba1c876a01246e718e6626e8e77ae9cc6298b20a39355 lib/core/replication.py
bbd1dcda835934728efc6d68686e9b0da72b09b3ee38f3c0ab78e8c18b0ba726 lib/core/revision.py
eed6b0a21b3e69c5583133346b0639dc89937bd588887968ee85f8389d7c3c96 lib/core/session.py
df96b0f2f935c583492c6331c6f222427976606af9a03ee5f05755a697ea7cec lib/core/settings.py
4cc89d1791e21b3bb4739039cb7eb57659370ab7008902eb80871c85a52c263f lib/core/settings.py
2bec97d8a950f7b884e31dfe9410467f00d24f21b35672b95f8d68ed59685fd4 lib/core/shell.py
e90a359b37a55c446c60e70ccd533f87276714d0b09e34f69b0740fd729ddbf8 lib/core/subprocessng.py
54f7c70b4c7a9931f7ff3c1c12030180bde38e35a306d5e343ad6052919974cd lib/core/target.py
5941a7a641ea58b1d9e59ab3c9f4e9e40566ba08842e1cadb51ea8df9faf763f lib/core/testing.py
970b1c3e59481f11dd185bdde52f697f7d8dfc3152d24e3d336ec3fab59a857c lib/core/testing.py
8cb7424aa9d42d028a6780250effe4e719d9bb35558057f8ebe9e32408a6b80f lib/core/threads.py
ff39235aee7e33498c66132d17e6e86e7b8a29754e3fdecd880ca8356b17f791 lib/core/unescaper.py
2984e4973868f586aa932f00da684bf31718c0331817c9f8721acd71fd661f89 lib/core/update.py
Expand Down
34 changes: 20 additions & 14 deletions lib/core/common.py
Expand Up @@ -1333,7 +1333,10 @@ def isZipFile(filename):

checkFile(filename)

return openFile(filename, "rb", encoding=None).read(len(ZIP_HEADER)) == ZIP_HEADER
with openFile(filename, "rb", encoding=None) as f:
header = f.read(len(ZIP_HEADER))

return header == ZIP_HEADER

def isDigit(value):
"""
Expand Down Expand Up @@ -2533,21 +2536,22 @@ def initCommonOutputs():
kb.commonOutputs = {}
key = None

for line in openFile(paths.COMMON_OUTPUTS, 'r'):
if line.find('#') != -1:
line = line[:line.find('#')]
with openFile(paths.COMMON_OUTPUTS, 'r') as f:
for line in f:
if line.find('#') != -1:
line = line[:line.find('#')]

line = line.strip()
line = line.strip()

if len(line) > 1:
if line.startswith('[') and line.endswith(']'):
key = line[1:-1]
elif key:
if key not in kb.commonOutputs:
kb.commonOutputs[key] = set()
if len(line) > 1:
if line.startswith('[') and line.endswith(']'):
key = line[1:-1]
elif key:
if key not in kb.commonOutputs:
kb.commonOutputs[key] = set()

if line not in kb.commonOutputs[key]:
kb.commonOutputs[key].add(line)
if line not in kb.commonOutputs[key]:
kb.commonOutputs[key].add(line)

def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
"""
Expand Down Expand Up @@ -5594,7 +5598,9 @@ def checkSums():
expected, filename = match.groups()
filepath = os.path.join(paths.SQLMAP_ROOT_PATH, filename).replace('/', os.path.sep)
checkFile(filepath)
if not hashlib.sha256(open(filepath, "rb").read()).hexdigest() == expected:
with open(filepath, "rb") as f:
content = f.read()
if not hashlib.sha256(content).hexdigest() == expected:
retVal &= False
break

Expand Down
2 changes: 1 addition & 1 deletion lib/core/settings.py
Expand Up @@ -20,7 +20,7 @@
from thirdparty.six import unichr as _unichr

# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.8.4.3"
VERSION = "1.8.4.5"
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
8 changes: 6 additions & 2 deletions lib/core/testing.py
Expand Up @@ -162,7 +162,9 @@ def _thread():
direct = "sqlite3://%s" % database
tmpdir = tempfile.mkdtemp()

content = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.conf"))).read().replace("url =", "url = %s" % url)
with open(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.conf"))) as f:
content = f.read().replace("url =", "url = %s" % url)

with open(config, "w+") as f:
f.write(content)
f.flush()
Expand Down Expand Up @@ -214,7 +216,9 @@ def smokeTest():

unisonRandom()

content = open(paths.ERRORS_XML, "r").read()
with open(paths.ERRORS_XML, "r") as f:
content = f.read()

for regex in re.findall(r'<error regexp="(.+?)"/>', content):
try:
re.compile(regex)
Expand Down

0 comments on commit 2f01cbf

Please sign in to comment.