Skip to content

Commit bdbff66

Browse files
authored
Merge pull request #293 from MerginMaps/qgis-security-scan
Mark security issues as safe for security checks
2 parents 661f72c + d20d130 commit bdbff66

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

mergin/merginproject.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ 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': '1111111111111111111111111111111111111111', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]
334+
>>> current = [{'checksum': '2222222222222222222222222222222222222222', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}]
335335
>>> self.compare_file_sets(origin, current)
336-
{"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": []}
336+
{"added": [{'checksum': '2222222222222222222222222222222222222222', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}], "removed": [[{'checksum': '1111111111111111111111111111111111111111', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]], "renamed": [], "updated": []}
337337
338338
:param origin: origin set of files metadata
339339
:type origin: list[dict]

mergin/test/test_client.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
import pytest
1111
import pytz
1212
import sqlite3
13-
import glob
1413
import secrets
15-
from unittest.mock import patch, Mock
14+
from unittest.mock import patch
1615

17-
from unittest.mock import patch, Mock
1816

1917
from .. import InvalidProject
2018
from ..client import (
@@ -1441,16 +1439,6 @@ def _create_spatial_table(db_file):
14411439
cursor.execute("COMMIT;")
14421440

14431441

1444-
def _delete_spatial_table(db_file):
1445-
"""Drops spatial table called 'test' in sqlite database. Useful to simulate change of database schema."""
1446-
con = sqlite3.connect(db_file)
1447-
cursor = con.cursor()
1448-
cursor.execute("DROP TABLE poi;")
1449-
cursor.execute("DELETE FROM gpkg_geometry_columns WHERE table_name='poi';")
1450-
cursor.execute("DELETE FROM gpkg_contents WHERE table_name='poi';")
1451-
cursor.execute("COMMIT;")
1452-
1453-
14541442
def _check_test_table(db_file):
14551443
"""Checks whether the 'test' table exists and has one row - otherwise fails with an exception."""
14561444
assert _get_table_row_count(db_file, "test") == 1

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)