Skip to content

Commit

Permalink
security fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xeniape committed May 27, 2024
1 parent feaf6c5 commit d48f08e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions opa/stackable/bin/process-logs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# and forwarded to the output destinations console and/or file.
#

set -euo pipefail

parse_args() {
while true; do
case $1 in
Expand Down Expand Up @@ -122,18 +124,18 @@ get_levels() {
main() {
parse_args $@

local DECISION_LEVELS=$(get_levels $DECISION_LEVEL)
local SERVER_LEVELS=$(get_levels $SERVER_LEVEL)
local CONSOLE_LEVELS=$(get_levels $CONSOLE_LEVEL)
local FILE_LEVELS=$(get_levels $FILE_LEVEL)
local DECISION_LEVELS=$(get_levels "$DECISION_LEVEL")
local SERVER_LEVELS=$(get_levels "$SERVER_LEVEL")
local CONSOLE_LEVELS=$(get_levels "$CONSOLE_LEVEL")
local FILE_LEVELS=$(get_levels "$FILE_LEVEL")

jq -c --unbuffered 'if .decision_id then .logger = "decision" else .logger = "server" end' |
jq -c --unbuffered --arg decision_levels $DECISION_LEVELS --arg server_levels $SERVER_LEVELS \
jq -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \
'select(((.logger == "decision") and (.level | inside($decision_levels))) or
((.logger == "server") and (.level | inside($server_levels))))' |
tee >(jq -c --unbuffered --arg file_levels $FILE_LEVELS 'select(.level | inside($file_levels))' \
> >(/stackable/multilog s$OPA_ROLLING_LOG_FILE_SIZE_BYTES n$OPA_ROLLING_LOG_FILES $STACKABLE_LOG_DIR/$CONTAINER_NAME)) |
jq -c --unbuffered --arg console_levels $CONSOLE_LEVELS 'select(.level | inside($console_levels))'
tee >(jq -c --unbuffered --arg file_levels "$FILE_LEVELS" 'select(.level | inside($file_levels))' \
> >(/stackable/multilog s"$OPA_ROLLING_LOG_FILE_SIZE_BYTES" n"$OPA_ROLLING_LOG_FILES" "$STACKABLE_LOG_DIR"/"$CONTAINER_NAME")) |
jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))'
}

main $@

0 comments on commit d48f08e

Please sign in to comment.