Merge pull request #10102 from Security-Onion-Solutions/kilo

elastic-fleet typo fix; remote dev enhancement
This commit is contained in:
Jason Ertel
2023-04-10 14:09:20 -04:00
committed by GitHub
4 changed files with 14 additions and 13 deletions

View File

@@ -9,4 +9,4 @@
. /usr/sbin/so-common . /usr/sbin/so-common
/usr/sbin/so-restart elastic-fleet $1 /usr/sbin/so-restart elasticfleet $1

View File

@@ -9,4 +9,4 @@
. /usr/sbin/so-common . /usr/sbin/so-common
/usr/sbin/so-start elastic-fleet $1 /usr/sbin/so-start elasticfleet $1

View File

@@ -9,4 +9,4 @@
. /usr/sbin/so-common . /usr/sbin/so-common
/usr/sbin/so-stop elastic-fleet $1 /usr/sbin/so-stop elasticfleet $1

View File

@@ -6,7 +6,8 @@
PIPE_OWNER=${PIPE_OWNER:-socore} PIPE_OWNER=${PIPE_OWNER:-socore}
PIPE_GROUP=${PIPE_GROUP:-socore} PIPE_GROUP=${PIPE_GROUP:-socore}
SOC_PIPE=${SOC_PIPE_REQUEST:-/opt/so/conf/soc/salt/pipe} SOC_PIPE=${SOC_PIPE:-/opt/so/conf/soc/salt/pipe}
CMD_PREFIX=${CMD_PREFIX:-""}
PATH=${PATH}:/usr/sbin PATH=${PATH}:/usr/sbin
function log() { function log() {
@@ -26,7 +27,7 @@ function make_pipe() {
make_pipe "${SOC_PIPE}" make_pipe "${SOC_PIPE}"
function list_minions() { function list_minions() {
response=$(so-minion -o=list) response=$($CMD_PREFIX so-minion -o=list)
exit_code=$? exit_code=$?
if [[ $exit_code -eq 0 ]]; then if [[ $exit_code -eq 0 ]]; then
log "Successful command execution" log "Successful command execution"
@@ -42,7 +43,7 @@ function manage_minion() {
op=$(echo "$request" | jq -r .operation) op=$(echo "$request" | jq -r .operation)
id=$(echo "$request" | jq -r .id) id=$(echo "$request" | jq -r .id)
response=$(so-minion "-o=$op" "-m=$id") response=$($CMD_PREFIX so-minion "-o=$op" "-m=$id")
exit_code=$? exit_code=$?
if [[ exit_code -eq 0 ]]; then if [[ exit_code -eq 0 ]]; then
log "Successful command execution" log "Successful command execution"
@@ -75,14 +76,14 @@ function manage_user() {
add|enable|disable|delete) add|enable|disable|delete)
email=$(echo "$request" | jq -r .email) email=$(echo "$request" | jq -r .email)
log "Performing user '$op' for user '$email'" log "Performing user '$op' for user '$email'"
response=$(so-user "$op" --email "$email" --skip-sync) response=$($CMD_PREFIX so-user "$op" --email "$email" --skip-sync)
exit_code=$? exit_code=$?
;; ;;
addrole|delrole) addrole|delrole)
email=$(echo "$request" | jq -r .email) email=$(echo "$request" | jq -r .email)
role=$(echo "$request" | jq -r .role) role=$(echo "$request" | jq -r .role)
log "Performing '$op' for user '$email' with role '$role'" log "Performing '$op' for user '$email' with role '$role'"
response=$(so-user "$op" --email "$email" --role "$role" --skip-sync) response=$($CMD_PREFIX so-user "$op" --email "$email" --role "$role" --skip-sync)
exit_code=$? exit_code=$?
;; ;;
password) password)
@@ -98,12 +99,12 @@ function manage_user() {
lastName=$(echo "$request" | jq -r .lastName) lastName=$(echo "$request" | jq -r .lastName)
note=$(echo "$request" | jq -r .note) note=$(echo "$request" | jq -r .note)
log "Performing '$op' update for user '$email' with firstname '$firstName', lastname '$lastName', and note '$note'" log "Performing '$op' update for user '$email' with firstname '$firstName', lastname '$lastName', and note '$note'"
response=$(so-user "$op" --email "$email" --firstName "$firstName" --lastName "$lastName" --note "$note") response=$($CMD_PREFIX so-user "$op" --email "$email" --firstName "$firstName" --lastName "$lastName" --note "$note")
exit_code=$? exit_code=$?
;; ;;
sync) sync)
log "Performing '$op'" log "Performing '$op'"
response=$(so-user "$op") response=$($CMD_PREFIX so-user "$op")
exit_code=$? exit_code=$?
;; ;;
*) *)
@@ -142,17 +143,17 @@ function manage_salt() {
state) state)
log "Performing '$op' for '$state' on minion '$minion'" log "Performing '$op' for '$state' on minion '$minion'"
state=$(echo "$request" | jq -r .state) state=$(echo "$request" | jq -r .state)
response=$(salt --async "$minion" state.apply "$state" queue=True) response=$($CMD_PREFIX salt --async "$minion" state.apply "$state" queue=True)
exit_code=$? exit_code=$?
;; ;;
highstate) highstate)
log "Performing '$op' on minion $minion" log "Performing '$op' on minion $minion"
response=$(salt --async "$minion" state.highstate queue=True) response=$($CMD_PREFIX salt --async "$minion" state.highstate queue=True)
exit_code=$? exit_code=$?
;; ;;
activejobs) activejobs)
response=$($CMD_PREFIX salt-run jobs.active -out json -l quiet)
log "Querying active salt jobs" log "Querying active salt jobs"
response=$(salt-run jobs.active -out json -l quiet)
$(echo "$response" > "${SOC_PIPE}") $(echo "$response" > "${SOC_PIPE}")
return return
;; ;;