Skip to content

Instantly share code, notes, and snippets.

@foospidy
Last active April 4, 2023 23:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save foospidy/c93149f206c3bd25a7be8a13152a625c to your computer and use it in GitHub Desktop.
Save foospidy/c93149f206c3bd25a7be8a13152a625c to your computer and use it in GitHub Desktop.
Update/replace integration configuration in Signal Sciences
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-integration-replace.sh
# For a given configuration, the script will delete all instances based on type and url,
# it will then recreate the configuration with the specified events.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
# Edit these varables to specify your config.
INTEGRATION_TYPE="slack"
INTEGRATION_URL="https://example.slack.com/webhook_url"
INTEGRATION_EVENTS='"agentAlert", "flag"'
for identifier in `pysigsci --get integrations --all-sites | jq ".data[] | { type: .type, id: .id, url: .url } | select(.type == \"${INTEGRATION_TYPE}\") | select(.url == \"${INTEGRATION_URL}\") | .id"`;
do
id=`echo ${identifier} | tr '"' '\ '`
for site in `pysigsci --get corp-sites | jq ".data[] | .name"`;
do
site_name=`echo ${site} | tr '"' '\ '`
pysigsci --delete integration --site ${site_name} --id ${id} | grep "successful";
done;
done;
pysigsci --add integration --all-sites --data "{\"url\": \"${INTEGRATION_URL}\", \"type\": \"${INTEGRATION_TYPE}\", \"events\": [${INTEGRATION_EVENTS}]}"
@Lilpay331
Copy link

Teach me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment