From c623d3afdd0e20631f29d9101b15ce7a8392ef68 Mon Sep 17 00:00:00 2001 From: Razvan Stoica Date: Thu, 11 Mar 2021 09:32:29 +0200 Subject: [PATCH] Print the remediation measure only if the check is not passed --- output_lib.sh | 2 +- tests/1_host_configuration.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/output_lib.sh b/output_lib.sh index 29083ba..b6580a1 100644 --- a/output_lib.sh +++ b/output_lib.sh @@ -103,7 +103,7 @@ resulttestjson() { printf "\"result\": \"%s\", \"details\": \"%s: %s\", \"items\": %s" "$1" "$2" "$truncItems" "$itemsJson" | tee -a "$logger.json" 2>/dev/null 1>&2 fi # Log remediation measure - if [ -n "$remediation" ]; then + if [ -n "$remediation" ] && [ "$1" != "PASS" ]; then printf ", \"remediation\": \"%s\"" "$remediation" | tee -a "$logger.json" 2>/dev/null 1>&2 if [ -n "$remediationImpact" ]; then printf ", \"remediation-impact\": \"%s\"" "$remediationImpact" | tee -a "$logger.json" 2>/dev/null 1>&2 diff --git a/tests/1_host_configuration.sh b/tests/1_host_configuration.sh index 9069d33..00a2261 100644 --- a/tests/1_host_configuration.sh +++ b/tests/1_host_configuration.sh @@ -180,6 +180,7 @@ check_1_2_4() { else info "$check" info " * Directory not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "Directory not found" currentScore=$((currentScore + 0)) fi @@ -221,6 +222,7 @@ check_1_2_5() { else info "$check" info " * Directory not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "Directory not found" currentScore=$((currentScore + 0)) fi @@ -262,6 +264,7 @@ check_1_2_6() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -303,6 +306,7 @@ check_1_2_7() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -344,6 +348,7 @@ check_1_2_8() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -385,6 +390,7 @@ check_1_2_9() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -426,6 +432,7 @@ check_1_2_10() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -467,6 +474,7 @@ check_1_2_11() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi @@ -508,6 +516,7 @@ check_1_2_12() { else info "$check" info " * File not found" + saveRemediation --id "${id}" --rem "${remediation}" --imp "${remediationImpact}" resulttestjson "INFO" "File not found" currentScore=$((currentScore + 0)) fi