Skip to content

Commit

Permalink
Check all integrations to match integration_key input from user for P…
Browse files Browse the repository at this point in the history
…agerDuty
  • Loading branch information
jatin-baweja committed Nov 23, 2021
1 parent 34526b1 commit 8abed5f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deepfence_backend/api/user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,15 +1617,18 @@ def handle_pagerduty_post(self, request_json, user):
if response.status_code != 200:
raise InvalidUsage("Looks like no user own this Authentication token provided")
else:
service_key_found = False
for data in response.json()["services"]:
if data["integrations"]:
for integrations in data["integrations"]:
if integrations.get("integration_key", ""):
integration_key = integrations.get("integration_key", "")
break
if integration_key == service_key:
if integration_key == service_key:
service_key_found = True
break
if service_key_found:
break
if not integration_key or integration_key != service_key:
if not integration_key or not service_key_found:
raise InvalidUsage("Looks like integration key provided is not valid")
except Exception as e:
raise InvalidUsage(e)
Expand Down

0 comments on commit 8abed5f

Please sign in to comment.