From ee771be952051a5c81fbffcba13e73f1ff942933 Mon Sep 17 00:00:00 2001 From: Matthias Veit Date: Fri, 1 Nov 2024 12:13:09 +0100 Subject: [PATCH] small adjustments --- plugins/azure/fix_plugin_azure/resource/security.py | 13 +++---------- plugins/azure/test/collector_test.py | 2 ++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/azure/fix_plugin_azure/resource/security.py b/plugins/azure/fix_plugin_azure/resource/security.py index 328998bc76..20f139e167 100644 --- a/plugins/azure/fix_plugin_azure/resource/security.py +++ b/plugins/azure/fix_plugin_azure/resource/security.py @@ -97,14 +97,7 @@ class AzureAssessmentStatus: @define(eq=False, slots=False) class AzureSecurityAssessment(MicrosoftResource, PhantomBaseResource): kind: ClassVar[str] = "azure_security_assessment" - _kind_display: ClassVar[str] = "Azure Security Assessment" - _kind_service: ClassVar[Optional[str]] = service_name - _kind_description: ClassVar[str] = "Azure Security Assessment is a service that evaluates Azure resources for potential security vulnerabilities and compliance issues. It scans configurations, identifies risks, and provides recommendations to improve security posture. The assessment covers various aspects including network security, data protection, and access control, offering insights to help organizations strengthen their Azure environment's security." # fmt: skip - _docs_url: ClassVar[str] = ( - "https://learn.microsoft.com/en-us/azure/defender-for-cloud/secure-score-security-controls" - ) - _metadata: ClassVar[Dict[str, Any]] = {"icon": "log", "group": "management"} - _reference_kinds: ClassVar[ModelReference] = {"successors": {"default": [MicrosoftResource.kind]}} + _model_export: ClassVar[bool] = False api_spec: ClassVar[AzureResourceSpec] = AzureResourceSpec( service=service_name, version="2021-06-01", @@ -140,7 +133,7 @@ def parse_finding(self, source: Json) -> Finding: "HIGH": Severity.high, "CRITICAL": Severity.critical, } - remidiation = finding_title = self.safe_name + remediation = finding_title = self.safe_name properties = source.get("properties") or {} if metadata := properties.get("metadata", {}): finding_severity = severity_mapping.get(metadata.get("severity", "").upper(), Severity.medium) @@ -153,7 +146,7 @@ def parse_finding(self, source: Json) -> Finding: description = None updated_at = None details = self.additional_data or {} | properties.get("metadata", {}) - return Finding(finding_title, finding_severity, description, remidiation, updated_at, details) + return Finding(finding_title, finding_severity, description, remediation, updated_at, details) @classmethod def collect_resources(cls, builder: GraphBuilder, **kwargs: Any) -> List["AzureSecurityAssessment"]: diff --git a/plugins/azure/test/collector_test.py b/plugins/azure/test/collector_test.py index cd1aea1062..0540019dc8 100644 --- a/plugins/azure/test/collector_test.py +++ b/plugins/azure/test/collector_test.py @@ -113,6 +113,8 @@ def all_base_classes(cls: Type[Any]) -> Set[Type[Any]]: expected_declared_properties = ["kind", "_kind_display"] expected_props_in_hierarchy = ["_kind_service", "_metadata"] for rc in all_resources: + if not rc._model_export: + continue for prop in expected_declared_properties: assert prop in rc.__dict__, f"{rc.__name__} missing {prop}" with_bases = (all_base_classes(rc) | {rc}) - {MicrosoftResource, BaseResource}