Skip to content

Commit

Permalink
Merge branch 'dev' into ruff_pth113
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-sommer authored Nov 12, 2024
2 parents 350acc8 + 6ec33d0 commit 2e3516d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dojo/tools/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def requires_tool_type(scan_type):
package_dir = str(Path(__file__).resolve().parent)
for module_name in os.listdir(package_dir):
# check if it's dir
if os.path.isdir(os.path.join(package_dir, module_name)):
if Path(os.path.join(package_dir, module_name)).is_dir():
try:
# check if it's a Python module
if find_spec(f"dojo.tools.{module_name}.parser"):
Expand Down
2 changes: 1 addition & 1 deletion dojo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ def get_page_items_and_count(request, items, page_size, prefix="", do_count=True
def handle_uploaded_threat(f, eng):
_name, extension = os.path.splitext(f.name)
# Check if threat folder exist.
if not os.path.isdir(settings.MEDIA_ROOT + "/threat/"):
if not Path(settings.MEDIA_ROOT + "/threat/").is_dir():
# Create the folder
Path(settings.MEDIA_ROOT + "/threat/").mkdir()
with open(settings.MEDIA_ROOT + f"/threat/{eng.id}{extension}",
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ select = [
"TCH",
"INT",
"ARG003", "ARG004", "ARG005",
"PTH2", "PTH101", "PTH102", "PTH103", "PTH104", "PTH105", "PTH106", "PTH107", "PTH108", "PTH109", "PTH110", "PTH111", "PTH113", "PTH114", "PTH115", "PTH116", "PTH117", "PTH119", "PTH121", "PTH124",
"PTH2", "PTH101", "PTH102", "PTH103", "PTH104", "PTH105", "PTH106", "PTH107", "PTH108", "PTH109", "PTH110", "PTH111", "PTH112", "PTH113", "PTH114", "PTH115", "PTH116", "PTH117", "PTH119", "PTH121", "PTH124",
"TD001", "TD004", "TD005",
"PD",
"PGH",
Expand Down
2 changes: 1 addition & 1 deletion tests/Import_scanner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ScannerTest(BaseTestCase):
def setUp(self):
super().setUp(self)
self.repo_path = dir_path + "/scans"
if os.path.isdir(self.repo_path):
if Path(self.repo_path).is_dir():
shutil.rmtree(self.repo_path)
Path(self.repo_path).mkdir()
git.Repo.clone_from("https://github.com/DefectDojo/sample-scan-files", self.repo_path)
Expand Down
3 changes: 2 additions & 1 deletion unittests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from importlib import import_module
from importlib.util import find_spec
from inspect import isclass
from pathlib import Path

from dojo.models import Test, Test_Type
from dojo.tools.factory import get_parser
Expand Down Expand Up @@ -72,7 +73,7 @@ def test_parser_name_matches_module(self):
for module_name in module_names:
if module_name in excluded_parsers:
continue
if os.path.isdir(os.path.join(package_dir, module_name)):
if Path(os.path.join(package_dir, module_name)).is_dir():
found = False
if find_spec(f"dojo.tools.{module_name}.parser"):
module = import_module(f"dojo.tools.{module_name}.parser")
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_file_existence(self):
with self.subTest(parser=parser_dir.name, category="testfiles"):
scan_dir = os.path.join(basedir, "unittests", "scans", parser_dir.name)
self.assertTrue(
os.path.isdir(scan_dir),
Path(scan_dir).is_dir(),
f"Test files for unittest of parser '{scan_dir}' are missing or using different name",
)

Expand Down

0 comments on commit 2e3516d

Please sign in to comment.