Skip to content

Commit b5e24ed

Browse files
committed
Mark security issues as safe for security checks
1 parent a2fcaf0 commit b5e24ed

3 files changed

Lines changed: 8 additions & 20 deletions

File tree

mergin/merginproject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ def compare_file_sets(self, origin, current):
330330
331331
:Example:
332332
333-
>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]
334-
>>> current = [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}]
333+
>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}] # pragma: allowlist secret
334+
>>> current = [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}] # pragma: allowlist secret
335335
>>> self.compare_file_sets(origin, current)
336336
{"added": [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}], "removed": [[{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]], "renamed": [], "updated": []}
337337

mergin/test/test_client.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
import pytest
1111
import pytz
1212
import sqlite3
13-
import glob
14-
from unittest.mock import patch, Mock
13+
from unittest.mock import patch
1514

16-
from unittest.mock import patch, Mock
1715

1816
from .. import InvalidProject
1917
from ..client import (
@@ -1382,16 +1380,6 @@ def _create_spatial_table(db_file):
13821380
cursor.execute("COMMIT;")
13831381

13841382

1385-
def _delete_spatial_table(db_file):
1386-
"""Drops spatial table called 'test' in sqlite database. Useful to simulate change of database schema."""
1387-
con = sqlite3.connect(db_file)
1388-
cursor = con.cursor()
1389-
cursor.execute("DROP TABLE poi;")
1390-
cursor.execute("DELETE FROM gpkg_geometry_columns WHERE table_name='poi';")
1391-
cursor.execute("DELETE FROM gpkg_contents WHERE table_name='poi';")
1392-
cursor.execute("COMMIT;")
1393-
1394-
13951383
def _check_test_table(db_file):
13961384
"""Checks whether the 'test' table exists and has one row - otherwise fails with an exception."""
13971385
assert _get_table_row_count(db_file, "test") == 1
@@ -1401,7 +1389,7 @@ def _get_table_row_count(db_file, table):
14011389
try:
14021390
con_verify = sqlite3.connect(db_file)
14031391
cursor_verify = con_verify.cursor()
1404-
cursor_verify.execute("select count(*) from {};".format(table))
1392+
cursor_verify.execute("select count(*) from {};".format(table)) # nosec B608
14051393
return cursor_verify.fetchone()[0]
14061394
finally:
14071395
cursor_verify.close()
@@ -3097,7 +3085,7 @@ def test_uploaded_chunks_cache(mc):
30973085

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

mergin/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import tempfile
1010
from enum import Enum
1111
from typing import Optional, Type, Union, ByteString
12-
from .common import ClientError, WorkspaceRole
12+
from .common import ClientError
1313

1414

1515
def generate_checksum(file, chunk_size=4096):
@@ -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()
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()
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)