Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump ruff to 0.8.1 #11350

Merged
merged 7 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dojo/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def update_azure_groups(backend, uid, user=None, social=None, *args, **kwargs):


def is_group_id(group):
return bool(re.search("^[a-zA-Z0-9]{8,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{12,}$", group))
return bool(re.search(r"^[a-zA-Z0-9]{8,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{4,}-[a-zA-Z0-9]{12,}$", group))


def assign_user_to_groups(user, group_names, social_provider):
Expand Down
2 changes: 1 addition & 1 deletion dojo/tools/crashtest_security/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_items(self, tree, test):
title = re.sub(r" \([0-9]*\)$", "", title)

# Attache CVEs
vulnerability_id = re.findall("CVE-\\d{4}-\\d{4,10}", title)[0] if "CVE" in title else None
vulnerability_id = re.findall(r"CVE-\d{4}-\d{4,10}", title)[0] if "CVE" in title else None
description = failure.get("message")
severity = failure.get("type").capitalize()

Expand Down
2 changes: 1 addition & 1 deletion dojo/tools/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def requires_tool_type(scan_type):

# iterate through the modules in the current package
package_dir = str(Path(__file__).resolve().parent)
for module_name in os.listdir(package_dir):
for module_name in os.listdir(package_dir): # noqa: PTH208
# check if it's dir
if Path(os.path.join(package_dir, module_name)).is_dir():
try:
Expand Down
2 changes: 1 addition & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff==0.8.0
ruff==0.8.1
17 changes: 10 additions & 7 deletions tests/Import_scanner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def setUp(self):
git.Repo.clone_from("https://github.com/DefectDojo/sample-scan-files", self.repo_path)
self.remove_items = ["__init__.py", "__init__.pyc", "factory.py", "factory.pyc",
"factory.py", "LICENSE", "README.md", ".gitignore", ".git", "__pycache__"]
tool_path = dir_path[:-5] + "dojo/tools"
tools = sorted(os.listdir(tool_path))
tests = sorted(os.listdir(self.repo_path))
tool_path = Path(dir_path[:-5] + "dojo/tools")
tools = sorted(any(tool_path.iterdir()))
p = Path(self.repo_path)
tests = sorted(any(p.iterdir()))
self.tools = [i for i in tools if i not in self.remove_items]
self.tests = [i for i in tests if i not in self.remove_items]

Expand All @@ -43,7 +44,8 @@ def test_check_test_file(self):
missing_tests += ["\nNO TEST FILES"]

for test in self.tests:
cases = sorted(os.listdir(self.repo_path + "/" + test))
p = Path(self.repo_path + "/" + test)
cases = sorted(any(p.iterdir()))
cases = [i for i in cases if i not in self.remove_items]
if len(cases) == 0 and tool not in missing_tests:
missing_tests += [test]
Expand Down Expand Up @@ -145,8 +147,8 @@ def test_engagement_import_scan_result(self):
options_text = [scan.strip() for scan in options_text]

mod_options = options_text
mod_options = [re.sub(r" Scanner", "", scan) for scan in mod_options]
mod_options = [re.sub(r" Scan", "", scan) for scan in mod_options]
mod_options = [scan.replace(" Scanner", "") for scan in mod_options]
mod_options = [scan.replace(" Scan", "") for scan in mod_options]
mod_options = [scan.lower().replace("-", " ").replace(".", "") for scan in mod_options]

acronyms = []
Expand Down Expand Up @@ -180,7 +182,8 @@ def test_engagement_import_scan_result(self):

failed_tests = []
for test in self.tests:
cases = sorted(os.listdir(self.repo_path + "/" + test))
p = Path(self.repo_path + "/" + test)
cases = sorted(any(p.iterdir()))
cases = [i for i in cases if i not in self.remove_items]
if len(cases) == 0:
failed_tests += [test.upper() + ": No test cases"]
Expand Down
4 changes: 2 additions & 2 deletions unittests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_get_parser_test_active_in_db(self):

def test_parser_name_matches_module(self):
"""Test to ensure that parsers' class names match their module names"""
package_dir = "dojo/tools"
module_names = os.listdir(package_dir)
package_dir = Path("dojo/tools")
module_names = package_dir.iterdir()
missing_parsers = []
excluded_parsers = [
"wizcli_common_parsers", # common class for other wizcli parsers, there is not parsing here
Expand Down
Loading