Skip to content

Commit

Permalink
small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Nov 1, 2024
1 parent 779588d commit ee771be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 3 additions & 10 deletions plugins/azure/fix_plugin_azure/resource/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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"]:
Expand Down
2 changes: 2 additions & 0 deletions plugins/azure/test/collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit ee771be

Please sign in to comment.