Skip to content

Commit

Permalink
Changed evaluate response to response.is_success
Browse files Browse the repository at this point in the history
  • Loading branch information
domwhewell-sage committed Sep 4, 2024
1 parent 262a938 commit 8e323e0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion bbot/modules/output/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Slack(WebhookOutputModule):
"event_types": "Types of events to send",
"min_severity": "Only allow VULNERABILITY events of this severity or higher",
}
good_status_code = 200
content_key = "text"

def format_message_str(self, event):
Expand Down
1 change: 0 additions & 1 deletion bbot/modules/output/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Teams(WebhookOutputModule):
"min_severity": "Only allow VULNERABILITY events of this severity or higher",
}
_module_threads = 5
good_status_code = 202
adaptive_card = {
"type": "message",
"attachments": [
Expand Down
4 changes: 1 addition & 3 deletions bbot/modules/templates/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class WebhookOutputModule(BaseOutputModule):
"""

accept_dupes = False
good_status_code = 204
message_size_limit = 2000
content_key = "content"
vuln_severities = ["UNKNOWN", "LOW", "MEDIUM", "HIGH", "CRITICAL"]
Expand Down Expand Up @@ -94,5 +93,4 @@ def format_message(self, event):
return msg

def evaluate_response(self, response):
status_code = getattr(response, "status_code", 0)
return status_code == self.good_status_code
return response.is_success
2 changes: 1 addition & 1 deletion bbot/test/test_step_2/module_tests/test_module_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def custom_response(request: httpx.Request):
if module_test.request_count == 2:
return httpx.Response(status_code=429, json={"retry_after": 0.01})
else:
return httpx.Response(status_code=module_test.module.good_status_code)
return httpx.Response(status_code=200)

module_test.httpx_mock.add_callback(custom_response, url=self.webhook_url)

Expand Down
11 changes: 8 additions & 3 deletions bbot/test/test_step_2/module_tests/test_module_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ def custom_response(request: httpx.Request):
module_test.request_count += 1
if module_test.request_count == 2:
return httpx.Response(
status_code=200,
text="Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 429 with ContextId tcid=0,server=msgapi-production-eus-azsc2-4-170,cv=deadbeef=2..",
status_code=400,
json={
"error": {
"code": "WorkflowTriggerIsNotEnabled",
"message": "Could not execute workflow 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' trigger 'manual' with state 'Disabled': trigger is not enabled.",
}
},
)
else:
return httpx.Response(status_code=202)
return httpx.Response(status_code=200)

module_test.httpx_mock.add_callback(custom_response, url=self.webhook_url)

0 comments on commit 8e323e0

Please sign in to comment.