use nosec instead of disabling mktemp rule

This commit is contained in:
Evgenii Alekseev 2021-08-11 02:51:29 +03:00
parent 48e79ce39c
commit 990d5dda81
3 changed files with 7 additions and 7 deletions

View File

@ -1 +1 @@
skips: ['B101', 'B306', 'B404'] skips: ['B101', 'B404']

View File

@ -111,7 +111,7 @@ def test_clear(lock: Lock) -> None:
""" """
must remove lock file must remove lock file
""" """
lock.path = Path(tempfile.mktemp()) lock.path = Path(tempfile.mktemp()) # nosec
lock.path.touch() lock.path.touch()
lock.clear() lock.clear()
@ -122,7 +122,7 @@ def test_clear_missing(lock: Lock) -> None:
""" """
must not fail on lock removal if file is missing must not fail on lock removal if file is missing
""" """
lock.path = Path(tempfile.mktemp()) lock.path = Path(tempfile.mktemp()) # nosec
lock.clear() lock.clear()
@ -139,7 +139,7 @@ def test_create(lock: Lock) -> None:
""" """
must create lock must create lock
""" """
lock.path = Path(tempfile.mktemp()) lock.path = Path(tempfile.mktemp()) # nosec
lock.create() lock.create()
assert lock.path.is_file() assert lock.path.is_file()
@ -150,7 +150,7 @@ def test_create_exception(lock: Lock) -> None:
""" """
must raise exception if file already exists must raise exception if file already exists
""" """
lock.path = Path(tempfile.mktemp()) lock.path = Path(tempfile.mktemp()) # nosec
lock.path.touch() lock.path.touch()
with pytest.raises(DuplicateRun): with pytest.raises(DuplicateRun):
@ -172,7 +172,7 @@ def test_create_unsafe(lock: Lock) -> None:
must not raise exception if force flag set must not raise exception if force flag set
""" """
lock.force = True lock.force = True
lock.path = Path(tempfile.mktemp()) lock.path = Path(tempfile.mktemp()) # nosec
lock.path.touch() lock.path.touch()
lock.create() lock.create()

View File

@ -106,7 +106,7 @@ def test_cache_save_load(watcher: Watcher, package_ahriman: Package, mocker: Moc
""" """
must save state to cache which can be loaded later must save state to cache which can be loaded later
""" """
dump_file = Path(tempfile.mktemp()) dump_file = Path(tempfile.mktemp()) # nosec
mocker.patch("ahriman.core.status.watcher.Watcher.cache_path", mocker.patch("ahriman.core.status.watcher.Watcher.cache_path",
new_callable=PropertyMock, return_value=dump_file) new_callable=PropertyMock, return_value=dump_file)
known_current = {package_ahriman.base: (package_ahriman, BuildStatus())} known_current = {package_ahriman.base: (package_ahriman, BuildStatus())}