mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-05-05 19:08:10 +02:00
Add 'so-elastic-fleet-integration-policy-bulk-delete' to perform bulk deletion of integration policies
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
#/bin/bash
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
POLICY_ID=$1
|
||||||
|
|
||||||
|
# Let's snag a cookie from Kibana
|
||||||
|
SESSIONCOOKIE=$(curl -q -K /opt/so/conf/elasticsearch/curl.config -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}')
|
||||||
|
|
||||||
|
# Get integration policies relative to agent policy
|
||||||
|
INTEGRATION_POLICY_IDS=$(curl -q -K /opt/so/conf/elasticsearch/curl.config -b "sid=$SESSIONCOOKIE" -L -X GET "localhost:5601/api/fleet/agent_policies/$POLICY_ID" | jq -r '.item.package_policies[].id')
|
||||||
|
|
||||||
|
for i in $INTEGRATION_POLICY_IDS; do
|
||||||
|
# Delete integration policies
|
||||||
|
echo "Deleting integration policy: $i..."
|
||||||
|
curl -K /opt/so/conf/elasticsearch/curl.config -b "sid=$SESSIONCOOKIE" -L -X POST "localhost:5601/api/fleet/package_policies/delete" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d"{\"packagePolicyIds\": [\"$i\"], \"force\":true}";
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user