Skip to content

Commit a368b50

Browse files
committed
explain nosec
1 parent b5e24ed commit a368b50

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mergin/test/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ def _get_table_row_count(db_file, table):
13891389
try:
13901390
con_verify = sqlite3.connect(db_file)
13911391
cursor_verify = con_verify.cursor()
1392-
cursor_verify.execute("select count(*) from {};".format(table)) # nosec B608
1392+
cursor_verify.execute("select count(*) from {};".format(table)) # nosec B608 - internal test helper, not using user input
13931393
return cursor_verify.fetchone()[0]
13941394
finally:
13951395
cursor_verify.close()
@@ -3085,7 +3085,7 @@ def test_uploaded_chunks_cache(mc):
30853085

30863086
with open(file, "rb") as file_handle:
30873087
data = file_handle.read()
3088-
checksum = hashlib.sha1() # nosec B324 # usedforsecurity=False flag is compatible with python 3.9+
3088+
checksum = hashlib.sha1() # nosec B324 - usedforsecurity=False flag is compatible with python 3.9+
30893089
checksum.update(data)
30903090
checksum_str = checksum.hexdigest()
30913091
resp = mc.post(f"/v2/projects/{mp.project_id()}/chunks", data, {"Content-Type": "application/octet-stream"})

mergin/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def generate_checksum(file, chunk_size=4096):
2020
:param chunk_size: size of chunk
2121
:return: sha1 checksum
2222
"""
23-
checksum = hashlib.sha1() # nosec B324 # usedforsecurity=False flag is compatible with python 3.9+
23+
checksum = hashlib.sha1() # nosec B324 - usedforsecurity=False flag is compatible with python 3.9+
2424
with open(file, "rb") as f:
2525
while True:
2626
chunk = f.read(chunk_size)
@@ -306,7 +306,7 @@ def get_data_checksum(data: ByteString) -> str:
306306
:param data: data to calculate checksum
307307
:return: sha1 checksum
308308
"""
309-
checksum = hashlib.sha1() # nosec B324 # usedforsecurity=False flag is compatible with python 3.9+
309+
checksum = hashlib.sha1() # nosec B324 - usedforsecurity=False flag is compatible with python 3.9+
310310
checksum.update(data)
311311
return checksum.hexdigest()
312312

0 commit comments

Comments
 (0)