From e53f2217ecc26316d462685f301f36f760888c58 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Mon, 7 Jun 2021 17:24:22 -0400 Subject: [PATCH] Add so-elasticsearch-query tool --- salt/common/tools/sbin/so-elasticsearch-query | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 salt/common/tools/sbin/so-elasticsearch-query diff --git a/salt/common/tools/sbin/so-elasticsearch-query b/salt/common/tools/sbin/so-elasticsearch-query new file mode 100644 index 000000000..ffae93a0d --- /dev/null +++ b/salt/common/tools/sbin/so-elasticsearch-query @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +. /usr/sbin/so-common + +if [[ $# -lt 1 ]]; then + echo "Submit a cURL request to the local Security Onion Elasticsearch host." + echo "" + echo "Usage: $0 [ARGS,...]" + echo "" + echo "Where " + echo " PATH represents the elastic function being requested." + echo " ARGS is used to specify additional, optional curl parameters." + echo "" + echo "Examples:" + echo " $0 / | jq" + echo " $0 '*:so-*/_search' -d '{\"query\": {\"match_all\": {}},\"size\": 1}' | jq" + exit 1 +fi + +PATH=$1 +shift + +{{ ELASTICCURL }} -s -k -L -H "Content-Type: application/json" "https://localhost:9200/${PATH}" "$@"