From 9de50aa716fb23e6a6cfaf2b16ff0975077c930b Mon Sep 17 00:00:00 2001 From: Matyas Strelec Date: Tue, 1 Oct 2024 11:14:51 +0200 Subject: [PATCH 1/2] baseline repo with `ruff format` - add pyproject.toml to keep line length same as in `.pre-commit-config.yaml` --- pyproject.toml | 2 ++ scanners/generic/tools/oobtkube.py | 7 ++++++- scanners/zap/zap.py | 5 ++++- tests/scanners/generic/tools/test_convert_trivy_k8s.py | 6 +++++- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6faf548 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.ruff] +line-length = 120 \ No newline at end of file diff --git a/scanners/generic/tools/oobtkube.py b/scanners/generic/tools/oobtkube.py index c02548f..8f38455 100644 --- a/scanners/generic/tools/oobtkube.py +++ b/scanners/generic/tools/oobtkube.py @@ -268,7 +268,12 @@ def check_can_create(obj_data: dict) -> bool: """Check if possible to create target resources. Verifies connection, sufficient permissions etc""" resource = obj_data["kind"] # kind must always be present in resource file try: - subprocess.run(["kubectl", "auth", "can-i", "create", resource], check=True, capture_output=True, timeout=30) + subprocess.run( + ["kubectl", "auth", "can-i", "create", resource], + check=True, + capture_output=True, + timeout=30, + ) except subprocess.TimeoutExpired as e: logging.error(e) return False diff --git a/scanners/zap/zap.py b/scanners/zap/zap.py index c4a9b5b..5714e5a 100644 --- a/scanners/zap/zap.py +++ b/scanners/zap/zap.py @@ -201,7 +201,10 @@ def _get_standard_options(self): standard = [] # Proxy workaround (because it currently can't be configured from Automation Framework) - p_host, p_port = self.my_conf("proxy.proxyHost"), self.my_conf("proxy.proxyPort") + p_host, p_port = ( + self.my_conf("proxy.proxyHost"), + self.my_conf("proxy.proxyPort"), + ) if p_host and p_port: standard.extend(["-config", f"network.connection.httpProxy.host={p_host}"]) standard.extend(["-config", f"network.connection.httpProxy.port={p_port}"]) diff --git a/tests/scanners/generic/tools/test_convert_trivy_k8s.py b/tests/scanners/generic/tools/test_convert_trivy_k8s.py index c9ab63b..0c42121 100644 --- a/tests/scanners/generic/tools/test_convert_trivy_k8s.py +++ b/tests/scanners/generic/tools/test_convert_trivy_k8s.py @@ -71,7 +71,11 @@ def test_convert_json_to_sarif_no_duplicate_rules_with_same_id(): json_data = json.load(open(json_file, encoding="utf-8")) expected_rules = [ - {"id": "RULE001", "name": "First Rule Title", "shortDescription": {"text": "First rule description"}} + { + "id": "RULE001", + "name": "First Rule Title", + "shortDescription": {"text": "First rule description"}, + } ] sarif_result = convert_json_to_sarif(json_data) From 55d5bd9933526057b0259447ba5eb14ed18ca5cc Mon Sep 17 00:00:00 2001 From: Matyas Strelec Date: Tue, 8 Oct 2024 13:32:30 +0200 Subject: [PATCH 2/2] add `pyproject.toml` - to keep line length same as in .pre-commit-config.yaml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6faf548..6dbd43f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [tool.ruff] -line-length = 120 \ No newline at end of file +line-length = 120