mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-05-22 19:15:15 +02:00
use temp files to prevent jq arg too long
This commit is contained in:
@@ -556,14 +556,23 @@ check_transform_health_and_reauthorize() {
|
|||||||
# - unhealthy (any non-green health status)
|
# - unhealthy (any non-green health status)
|
||||||
# - metadata has run_as_kibana_system: false (this fix is specific to transforms started prior to Kibana 9.3.3)
|
# - metadata has run_as_kibana_system: false (this fix is specific to transforms started prior to Kibana 9.3.3)
|
||||||
# - are not orphaned (integration is not somehow missing/corrupt/uninstalled)
|
# - are not orphaned (integration is not somehow missing/corrupt/uninstalled)
|
||||||
|
local tmp_transforms tmp_stats tmp_installed
|
||||||
|
tmp_transforms=$(mktemp)
|
||||||
|
tmp_stats=$(mktemp)
|
||||||
|
tmp_installed=$(mktemp)
|
||||||
|
|
||||||
|
echo "$transforms_doc" > "$tmp_transforms"
|
||||||
|
echo "$stats_doc" > "$tmp_stats"
|
||||||
|
echo "$installed_doc" > "$tmp_installed"
|
||||||
|
|
||||||
local unhealthy_transforms
|
local unhealthy_transforms
|
||||||
unhealthy_transforms=$(jq -c -n \
|
unhealthy_transforms=$(jq -c -n \
|
||||||
--argjson t "$transforms_doc" \
|
--slurpfile t "$tmp_transforms" \
|
||||||
--argjson s "$stats_doc" \
|
--slurpfile s "$tmp_stats" \
|
||||||
--argjson i "$installed_doc" '
|
--slurpfile i "$tmp_installed" '
|
||||||
($i.items | map({key: .name, value: .version}) | from_entries) as $pkg_ver
|
($i[0].items | map({key: .name, value: .version}) | from_entries) as $pkg_ver
|
||||||
| ($s.transforms | map({key: .id, value: .health.status}) | from_entries) as $health
|
| ($s[0].transforms | map({key: .id, value: .health.status}) | from_entries) as $health
|
||||||
| [ $t.transforms[]
|
| [ $t[0].transforms[]
|
||||||
| select(._meta.run_as_kibana_system == false)
|
| select(._meta.run_as_kibana_system == false)
|
||||||
| select(($health[.id] // "unknown") != "green")
|
| select(($health[.id] // "unknown") != "green")
|
||||||
| {id, pkg: ._meta.package.name, ver: ($pkg_ver[._meta.package.name])}
|
| {id, pkg: ._meta.package.name, ver: ($pkg_ver[._meta.package.name])}
|
||||||
@@ -604,6 +613,8 @@ check_transform_health_and_reauthorize() {
|
|||||||
(( total_failures += $(jq 'map(select(.success != true)) | length' <<< "$resp" 2>/dev/null) ))
|
(( total_failures += $(jq 'map(select(.success != true)) | length' <<< "$resp" 2>/dev/null) ))
|
||||||
done <<< "$unhealthy_transforms"
|
done <<< "$unhealthy_transforms"
|
||||||
|
|
||||||
|
rm -f "$tmp_transforms" "$tmp_stats" "$tmp_installed"
|
||||||
|
|
||||||
if [[ "$total_failures" -gt 0 ]]; then
|
if [[ "$total_failures" -gt 0 ]]; then
|
||||||
echo "Some transform(s) failed to reauthorize."
|
echo "Some transform(s) failed to reauthorize."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user