Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: append api_key as a query parameter when setting Splunk webhook url #2175

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions keep/providers/splunk_provider/splunk_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ def dispose(self):
def setup_webhook(
self, tenant_id: str, keep_api_url: str, api_key: str, setup_alerts: bool = True
):
self.logger.info("Setting up Splunk webhook on all Alerts")
creation_updation_kwargs = {
self.logger.info("Setting up Splunk webhook for all saved searches")
webhook_url = f"{keep_api_url}&api_key={api_key}"
webhook_kwargs = {
"actions": "webhook",
"action.webhook": "1",
"action.webhook.param.url": keep_api_url,
"action.webhook.param.url": webhook_url,
}
service = connect(
token=self.authentication_config.api_key,
Expand All @@ -218,8 +219,21 @@ def setup_webhook(
existing_webhook_url = saved_search["_state"]["content"].get(
"action.webhook.param.url", None
)
if existing_webhook_url is None or existing_webhook_url != keep_api_url:
saved_search.update(**creation_updation_kwargs).refresh()
if existing_webhook_url and existing_webhook_url == webhook_url:
self.logger.info(
f"Webhook already set for saved search {saved_search.name}",
extra={
"webhook_url": webhook_url,
},
)
continue
self.logger.info(
f"Updating saved search with webhook {saved_search.name}",
extra={
"webhook_url": webhook_url,
},
)
saved_search.update(**webhook_kwargs).refresh()

@staticmethod
def _format_alert(
Expand Down
Loading