From 05f98fe9934c2d42f4697ad95009638aede38862 Mon Sep 17 00:00:00 2001 From: Sergio Garcia <38561120+sergargar@users.noreply.github.com> Date: Mon, 20 Jun 2022 13:27:54 +0200 Subject: [PATCH] fix(junit_xml output): Fix XML output integration (#1210) Co-authored-by: sergargar --- include/execute_check | 8 ++++---- include/junit_integration | 8 -------- include/outputs | 2 +- include/validate_options | 2 +- prowler | 1 + 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/include/execute_check b/include/execute_check index 9c1c958c17..c81d5106d3 100644 --- a/include/execute_check +++ b/include/execute_check @@ -84,12 +84,12 @@ execute_check() { fi fi show_check_title ${alternate_name} - if is_junit_output_enabled; then + if [[ " ${MODE} " =~ "junit-xml" ]]; then prepare_junit_check_output "$1" fi # Execute the check IGNORES="${ignores}" CHECK_NAME="$1" ${alternate_name} - if is_junit_output_enabled; then + if [[ " ${MODE} " =~ "junit-xml" ]]; then finalise_junit_check_output "$1" fi @@ -108,13 +108,13 @@ execute_check() { fi fi show_check_title "$1" - if is_junit_output_enabled; then + if [[ " ${MODE} " =~ "junit-xml" ]]; then prepare_junit_check_output "$1" fi # Execute the check IGNORES="${ignores}" CHECK_NAME="$1" $1 - if is_junit_output_enabled; then + if [[ " ${MODE} " =~ "junit-xml" ]]; then finalise_junit_check_output "$1" fi diff --git a/include/junit_integration b/include/junit_integration index 3cb7031189..4750b86ddc 100644 --- a/include/junit_integration +++ b/include/junit_integration @@ -20,14 +20,6 @@ JUNIT_FAILURES_COUNT="0" JUNIT_SKIPPED_COUNT="0" JUNIT_ERRORS_COUNT="0" -is_junit_output_enabled() { - if [[ " ${MODE} " =~ "junit-xml" ]]; then - true - else - false - fi -} - xml_escape() { sed 's/&/\&/g; s//\>/g; s/\"/\"/g; s/'"'"'/\'/g' <<< "$1" } diff --git a/include/outputs b/include/outputs index 65dc6b16c4..b6a3106c06 100644 --- a/include/outputs +++ b/include/outputs @@ -170,7 +170,7 @@ general_output() { if [[ "${SEND_TO_SECURITY_HUB}" -eq 1 ]]; then sendToSecurityHub "${JSON_ASFF_OUTPUT}" "${REGION_FROM_CHECK}" fi - elif is_junit_output_enabled + elif [[ "${MODE_TYPE}" == "junit-xml" ]] then if [ "${CHECK_RESULT}" == 'PASS' ] then diff --git a/include/validate_options b/include/validate_options index 3ae627f61e..e87a39ae57 100644 --- a/include/validate_options +++ b/include/validate_options @@ -96,7 +96,7 @@ validate_assume_role() { # JUnit output if -M junit-xml validate_junit_output() { - if is_junit_output_enabled + if [[ " ${MODE} " =~ "junit-xml" ]]; then prepare_junit_output fi diff --git a/prowler b/prowler index 8ddb2b9b58..7e80c61119 100755 --- a/prowler +++ b/prowler @@ -329,6 +329,7 @@ validate_custom_checks # Add headers to certain output files output_files_init +validate_junit_output # Execute checks for CHECK in "${TOTAL_CHECKS[@]}"