diff --git a/Makefile b/Makefile index 2b970315ce5b4e74910a731228e2357bade1b6bc..96c58dfd624162d9b6c1afca6a1ff573d7b5c11e 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ ruff-check-format: . venv/bin/activate ruff format lib --check -ruff-autoformat: +ruff-format: . venv/bin/activate ruff format lib diff --git a/lib/__init__.py b/lib/__init__.py index ca81f7b9ff1fdd5f2ac3e85fdedcbd67fa9fc0a6..22e838eea3036640cb23e1f556fbe2a43791f9a0 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -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 diff --git a/lib/event/history.py b/lib/event/history.py index ad461a8e5f684b86080138c581e33efce351c306..79efd0b55dbde3de1b8417ad0f0aa740b8952d13 100644 --- a/lib/event/history.py +++ b/lib/event/history.py @@ -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() diff --git a/lib/event/rescan.py b/lib/event/rescan.py index 2f667485705784355c54ec0d56c9b06b8699591c..fd8a84979360b8f94978b5d213828a3a500b8065 100644 --- a/lib/event/rescan.py +++ b/lib/event/rescan.py @@ -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.") diff --git a/lib/event/sner.py b/lib/event/sner.py index 32222a08944475b503942bdee1838fa69d6447e9..70193d06b98acdb07eb5b1c6a6cd85d2d6278ec6 100644 --- a/lib/event/sner.py +++ b/lib/event/sner.py @@ -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, []): diff --git a/lib/playground.py b/lib/playground.py index 8110f64c5f80c68c8059f9b6cd9e5764779c4df2..66d84c515458c0088851afbc25325b7bd93bbe5a 100644 --- a/lib/playground.py +++ b/lib/playground.py @@ -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="*", ) ) diff --git a/lib/report/__init__.py b/lib/report/__init__.py index 3d74ff0a7fb302e58ee3ffbf5fe37647c71dc512..0c6bfe49da199a5695f047201257e814a48bb94b 100644 --- a/lib/report/__init__.py +++ b/lib/report/__init__.py @@ -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]: diff --git a/lib/test/test_reports.py b/lib/test/test_reports.py index 5fa62c07b55f7ccd17ffac4217b2a5e05f1ed79f..2e16131f5625e32f0f241c8b0f91eeae352fb53b 100644 --- a/lib/test/test_reports.py +++ b/lib/test/test_reports.py @@ -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):