Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 47a926e

Browse files
authored
Merge pull request #3 from ilbumi/add_safety_checks
Add safety checks
2 parents c32b3ae + 839b61d commit 47a926e

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

project/config/bandit.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.bandit]
2+
exclude_dirs = ["tests"]
3+
skips = ["B101"]

project/noxfile.py.jinja

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
"""File with common jobs definitions. Run them with 'pdm run nox -e [job_name]'."""
22
import os
3+
import tempfile
34

45
import nox
56
from nox.sessions import Session
67

78
os.environ.update(PDM_IGNORE_SAVED_PYTHON="1", PDM_USE_VENV="1")
89

9-
PYSRC = [
10-
"src/",
11-
"noxfile.py",
12-
"tests/"
13-
]
10+
PYSRC = ["src/", "noxfile.py", "tests/"]
11+
1412

1513
@nox.session
1614
def test(session: Session) -> None:
1715
"""Run tests.
1816

1917
Args:
2018
session (Session): nox session object
21-
"""
19+
"""
2220
session.run_always("pdm", "install", "-G", "ci-tests", external=True)
2321
session.run("pytest", "tests/")
2422

@@ -56,3 +54,18 @@ def check_types(session: Session) -> None:
5654
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
5755
session.run("mypy", "--config-file", "config/mypy.ini", *PYSRC)
5856

57+
58+
@nox.session
59+
def check_safety(session: Session) -> None:
60+
"""Run safety checks.
61+
62+
Args:
63+
session (Session): nox session object
64+
"""
65+
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
66+
session.run("bandit", "--configfile", "config/bandit.toml", *PYSRC)
67+
with tempfile.NamedTemporaryFile() as requirements:
68+
session.run(
69+
"pdm", "export", "-f", "requirements", "-o", requirements.name, "--without-hashes", external=True
70+
)
71+
session.run("safety", "check", f"--file={requirements.name}", "--full-report")

tests/test_generate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ echo
2121
pdm run nox -e format
2222
pdm run nox -e check_types
2323
pdm run nox -e lint
24+
pdm run nox -e check_safety
2425

2526
popd
2627
rm -rf $DEST

0 commit comments

Comments
 (0)