Skip to content

Commit 0357c20

Browse files
committed
fix: lint
1 parent 51b7081 commit 0357c20

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

functions/notify_slack.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
SECURITY_HUB_CLIENT = boto3.client('securityhub', region_name=REGION)
3030

31+
3132
class AwsService(Enum):
3233
"""AWS service supported by function"""
3334

@@ -141,21 +142,18 @@ def format_aws_security_hub(message: Dict[str, Any], region: str) -> Dict[str, A
141142
compliance_status = finding["Compliance"].get("Status", "UNKNOWN")
142143
workflow_status = finding["Workflow"].get("Status", "UNKNOWN")
143144
if compliance_status == "FAILED" and workflow_status == "NEW":
144-
notified = SECURITY_HUB_CLIENT.batch_update_findings(
145-
FindingIdentifiers=[{
146-
'Id': finding.get('Id'),
147-
'ProductArn': finding.get("ProductArn")
148-
}],
149-
Workflow={"Status": "NOTIFIED"}
150-
)
151-
logging.warning(f"Successfully updated finding status to NOTIFIED: {json.dumps(notified)}")
145+
notified = SECURITY_HUB_CLIENT.batch_update_findings(
146+
FindingIdentifiers=[{
147+
'Id': finding.get('Id'),
148+
'ProductArn': finding.get("ProductArn")
149+
}],
150+
Workflow={"Status": "NOTIFIED"}
151+
)
152+
logging.warning(f"Successfully updated finding status to NOTIFIED: {json.dumps(notified)}")
152153
except Exception as e:
153154
logging.error(f"Failed to update finding status: {str(e)}")
154155
pass
155156

156-
157-
158-
159157
if finding.get("ProductName") == "Inspector":
160158
severity = finding["Severity"].get("Label", "INFORMATIONAL")
161159
compliance_status = finding["Compliance"].get("Status", "UNKNOWN")
@@ -178,7 +176,7 @@ def format_aws_security_hub(message: Dict[str, Any], region: str) -> Dict[str, A
178176

179177
color = SecurityHubSeverity.get(severity.upper(), SecurityHubSeverity.INFORMATIONAL).value
180178
if compliance_status == "PASSED":
181-
color = "#4BB543"
179+
color = "#4BB543"
182180

183181
slack_message = {
184182
"color": color,
@@ -225,7 +223,7 @@ def format_aws_security_hub(message: Dict[str, Any], region: str) -> Dict[str, A
225223

226224
color = SecurityHubSeverity.get(severity.upper(), SecurityHubSeverity.INFORMATIONAL).value
227225
if compliance_status == "PASSED":
228-
color = "#4BB543"
226+
color = "#4BB543"
229227

230228
slack_message = {
231229
"color": color,
@@ -250,9 +248,9 @@ def format_aws_security_hub(message: Dict[str, Any], region: str) -> Dict[str, A
250248

251249
return slack_message
252250

253-
254251
return format_default(message=message)
255252

253+
256254
class SecurityHubSeverity(Enum):
257255
"""Maps Security Hub finding severity to Slack message format color"""
258256

@@ -269,13 +267,15 @@ def get(name, default):
269267
except KeyError:
270268
return default
271269

270+
272271
class GuardDutyFindingSeverity(Enum):
273272
"""Maps GuardDuty finding severity to Slack message format color"""
274273

275274
Low = "#777777"
276275
Medium = "warning"
277276
High = "danger"
278277

278+
279279
def format_guardduty_finding(message: Dict[str, Any], region: str) -> Dict[str, Any]:
280280
"""
281281
Format GuardDuty finding event into Slack message format

0 commit comments

Comments
 (0)