Skip to content

Commit

Permalink
baseline repo with ruff format
Browse files Browse the repository at this point in the history
- add pyproject.toml to keep line length same as in `.pre-commit-config.yaml`
  • Loading branch information
mstrlc committed Oct 1, 2024
1 parent 1161eaa commit 9de50aa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.ruff]
line-length = 120
7 changes: 6 additions & 1 deletion scanners/generic/tools/oobtkube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion scanners/zap/zap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"])
Expand Down
6 changes: 5 additions & 1 deletion tests/scanners/generic/tools/test_convert_trivy_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9de50aa

Please sign in to comment.