Skip to content

Commit

Permalink
make severity mapping constantly
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 1, 2024
1 parent ee771be commit 7998903
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 9 additions & 0 deletions fixlib/fixlib/baseresources.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,15 @@ class Finding:
details: Optional[Json] = None


SEVERITY_MAPPING = {
"INFORMATIONAL": Severity.info,
"LOW": Severity.low,
"MEDIUM": Severity.medium,
"HIGH": Severity.high,
"CRITICAL": Severity.critical,
}


@define(slots=True)
class Assessment:
# The provider of the security assessment
Expand Down
11 changes: 2 additions & 9 deletions plugins/azure/fix_plugin_azure/resource/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from fix_plugin_azure.azure_client import AzureResourceSpec
from fix_plugin_azure.resource.base import MicrosoftResource, AzureSystemData, GraphBuilder
from fixlib.baseresources import Finding, ModelReference, PhantomBaseResource, Severity
from fixlib.baseresources import SEVERITY_MAPPING, Finding, PhantomBaseResource, Severity
from fixlib.json_bender import Bender, S, Bend, ForallBend, F
from fixlib.types import Json

Expand Down Expand Up @@ -126,17 +126,10 @@ class AzureSecurityAssessment(MicrosoftResource, PhantomBaseResource):
subscription_issue: Optional[bool] = field(default=False, metadata={'description': 'Indicates if the assessment is a subscription issue'}) # fmt: skip

def parse_finding(self, source: Json) -> Finding:
severity_mapping = {
"INFORMATIONAL": Severity.info,
"LOW": Severity.low,
"MEDIUM": Severity.medium,
"HIGH": Severity.high,
"CRITICAL": Severity.critical,
}
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)
finding_severity = SEVERITY_MAPPING.get(metadata.get("severity", "").upper(), Severity.medium)
else:
finding_severity = Severity.medium
if status := self.assessment_status:
Expand Down

0 comments on commit 7998903

Please sign in to comment.