Skip to content
Snippets Groups Projects
Commit 1175d40c authored by Jakub Judiny's avatar Jakub Judiny
Browse files

Refactor: formatting with trailing commas

parent 2c5b913c
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ ruff-check-format:
. venv/bin/activate
ruff format lib --check
ruff-autoformat:
ruff-format:
. venv/bin/activate
ruff format lib
......
......@@ -28,7 +28,9 @@ def get_script_argument_parser() -> ArgumentParser:
help="do not print anything but errors to the standard output",
)
parser.add_argument(
"--debug", action="store_true", help="also log the debug outputs"
"--debug",
action="store_true",
help="also log the debug outputs",
)
return parser
......
......@@ -90,12 +90,19 @@ class EventHistory:
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("--print", help="print the history for the given report")
parser.add_argument(
"--print-all", action="store_true", help="print the history for all reports"
"--print",
help="print the history for the given report",
)
parser.add_argument(
"-d", "--delete", help="delete the history for the given report item"
"--print-all",
action="store_true",
help="print the history for all reports",
)
parser.add_argument(
"-d",
"--delete",
help="delete the history for the given report item",
)
args = parser.parse_args()
......
......@@ -16,7 +16,9 @@ def rescan(debug: bool = False, silent: bool = False) -> None:
for filename, path in get_report_files(config.reports_dir()):
logger.info("Started rescanning for report %s.", filename)
generator = Events(
VulnerabilityReport(path, logger=logger), logger=logger, is_rescan=True
VulnerabilityReport(path, logger=logger),
logger=logger,
is_rescan=True,
)
generator.send_to_warden(rescan=True)
logger.info("Rescanning completed.")
......
......@@ -28,7 +28,10 @@ class SnerSearcher:
Note: Sner's API key must be set in the config file.
"""
headers = {"Accept": "application/json", "X-API-KEY": config.SNER_apikey()}
headers = {
"Accept": "application/json",
"X-API-KEY": config.SNER_apikey(),
}
response = post(url, headers=headers, json=post_obj, timeout=600)
if not response.ok:
# 404 is returned also when nothing is found, which is a valid
......@@ -110,7 +113,11 @@ class SnerSearcher:
Calls Sner's versioninfo API for given product, OS and version specification.
The results are then filtered to get only relevant results.
"""
post_obj = {"product": product, "versionspec": version_spec, "filter": ""}
post_obj = {
"product": product,
"versionspec": version_spec,
"filter": "",
}
results = []
for result in self._post(self.VERSION_INFO_URL, post_obj, []):
......
......@@ -23,7 +23,9 @@ def try_sner_searcher():
searcher = SnerSearcher()
print(
searcher.version_search(
product="openssh", version_spec=">=4.3,<4.3.3", os_spec="*"
product="openssh",
version_spec=">=4.3,<4.3.3",
os_spec="*",
)
)
......
......@@ -183,7 +183,9 @@ class ReportItem:
return self.search_in_sner
def get_name(self) -> str:
return capitalize_and_fix_spaces(self._get("name", required=True))
return capitalize_and_fix_spaces(
self._get("name", required=True),
)
def get_created(self) -> Optional[str]:
created = self.item.get("created")
......@@ -227,7 +229,7 @@ class ReportItem:
def get_description(self) -> str:
return capitalize_and_fix_spaces(
self._get_from_attrs("description", required=True)
self._get_from_attrs("description", required=True),
)
def get_recommendations(self) -> Optional[str]:
......
......@@ -115,10 +115,12 @@ class Test(unittest.TestCase):
def test_date_functions(self):
self.assertEqual(
format_date({"day": 2, "month": 10, "year": 2023}), "2. 10. 2023"
format_date({"day": 2, "month": 10, "year": 2023}),
"2. 10. 2023",
)
self.assertEqual(
format_date({"month": 12, "year": 1984, "day": 25}), "25. 12. 1984"
format_date({"month": 12, "year": 1984, "day": 25}),
"25. 12. 1984",
)
for input_dict in [{"month": 12, "day": 25}, {"month": 12}, None]:
with self.assertRaises(ValueError):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment