From fc7b0d20d6917a6993f2dfc12aac17a1c2776381 Mon Sep 17 00:00:00 2001 From: Dominic Whewell <122788350+domwhewell-sage@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:18:13 +0100 Subject: [PATCH] Move adaptive card from self to in format message --- bbot/modules/output/teams.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bbot/modules/output/teams.py b/bbot/modules/output/teams.py index 98ab3e432..52b17ae1a 100644 --- a/bbot/modules/output/teams.py +++ b/bbot/modules/output/teams.py @@ -15,26 +15,10 @@ class Teams(WebhookOutputModule): "min_severity": "Only allow VULNERABILITY events of this severity or higher", } _module_threads = 5 - adaptive_card = { - "type": "message", - "attachments": [ - { - "contentType": "application/vnd.microsoft.card.adaptive", - "contentUrl": None, - "content": { - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", - "type": "AdaptiveCard", - "version": "1.2", - "msteams": {"width": "full"}, - "body": [], - }, - } - ], - } async def handle_event(self, event): while 1: - data = self.format_message(self.adaptive_card.copy(), event) + data = self.format_message(event) response = await self.helpers.request( url=self.webhook_url, @@ -89,7 +73,23 @@ def get_severity_color(self, event): color = "Good" return color - def format_message(self, adaptive_card, event): + def format_message(self, event): + adaptive_card = { + "type": "message", + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "contentUrl": None, + "content": { + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.2", + "msteams": {"width": "full"}, + "body": [], + }, + } + ], + } heading = {"type": "TextBlock", "text": f"{event.type}", "wrap": True, "size": "Large", "style": "heading"} body = adaptive_card["attachments"][0]["content"]["body"] body.append(heading)