diff --git a/include/check11 b/checks/check11 similarity index 88% rename from include/check11 rename to checks/check11 index 39e051a1..adc5400a 100644 --- a/include/check11 +++ b/checks/check11 @@ -3,10 +3,11 @@ CHECK_ID[check11]="1.1,1.01" CHECK_TITLE[check11]="Avoid the use of the root account (Scored)." CHECK_SCORED[check11]="SCORED" +CHECK_TYPE[check11]="LEVEL1" +CHECK_ALTERNATE[check101]="check11" + check11() { # "Avoid the use of the root account (Scored)." COMMAND11=$(cat $TEMP_REPORT_FILE| grep '' | cut -d, -f5,11,16 | sed 's/,/\ /g') - textTitle "$CHECK_ID" "$CHECK_TITLE" "SCORED" "LEVEL1" textNotice "Root account last accessed (password key_1 key_2): $COMMAND11" } -CHECK_ALTERNATE[check101]="check11" diff --git a/include/group1 b/groups/group1 similarity index 66% rename from include/group1 rename to groups/group1 index f77f5ae5..1663ceeb 100644 --- a/include/group1 +++ b/groups/group1 @@ -3,6 +3,5 @@ GROUP_ID[1]="group1" GROUP_NUMBER[1]="1.0" GROUP_TITLE[1]="Identity and Access Management" -GROUP_RUN_BY_DEFAULT[1]="Y" +GROUP_RUN_BY_DEFAULT[1]="Y" # run it when execute_all is called GROUP_CHECKS[1]="check11" -textTitle "$GROUP_NUMBER" "$GROUP_TITLE" diff --git a/include/colors b/include/colors new file mode 100644 index 00000000..e69de29b diff --git a/prowler2 b/prowler2 index d7338f4b..c75439d0 100755 --- a/prowler2 +++ b/prowler2 @@ -112,58 +112,7 @@ while getopts ":hlkp:r:c:f:m:M:en" OPTION; do esac done -if [[ $MODE != "mono" && $MODE != "text" && $MODE != "csv" ]]; then - echo "" - echo "$OPTRED ERROR!$OPTNORMAL Invalid output mode. Choose text, mono, or csv." - usage - EXITCODE=1 - exit $EXITCODE -fi - -if [[ "$MODE" == "mono" || "$MODE" == "csv" ]]; then - MONOCHROME=1 -fi - -if [[ $MONOCHROME -eq 1 ]]; then - # Colors - NORMAL='' - WARNING='' # Bad (red) - SECTION='' # Section (yellow) - NOTICE='' # Notice (yellow) - OK='' # Ok (green) - BAD='' # Bad (red) - CYAN='' - BLUE='' - BROWN='' - DARKGRAY='' - GRAY='' - GREEN='' - MAGENTA='' - PURPLE='' - RED='' - YELLOW='' - WHITE='' -else - # Colors - # NOTE: Your editor may NOT show the 0x1b / escape character left of the '[' - NORMAL="" - WARNING="" # Bad (red) - SECTION="" # Section (yellow) - NOTICE="" # Notice (yellow) - OK="" # Ok (green) - BAD="" # Bad (red) - CYAN="" - BLUE="" - BROWN="" - DARKGRAY="" - GRAY="" - GREEN="" - MAGENTA="" - PURPLE="" - RED="" - YELLOW="" - WHITE="" -fi +. include/colors SCRIPT_START_TIME=$( date -u +"%Y-%m-%dT%H:%M:%S%z" ) @@ -494,61 +443,29 @@ if [[ $PRINTCHECKSONLY == "1" ]]; then exit $EXITCODE fi -# Data Structures -# -# Groups -# ------ -# GROUP_NAME[X] = "groupname" -# GROUP_TITLE[X] = "Logging *****" -# GROUP_RUN_BY_DEFAULT[X] = "Y" // Whether this group is run by default -# GROUP_CHECKS[X] = "check11,check12" // etc. etc. -# -# Checks & Extras -# --------------- -# CHECK_TITLE[checkname] = "Title checkname" -# CHECK_ID[checkname] = '1.1,1.01' -# CHECK_SCORED[checkname] = 'SCORED' or 'NOT_SCORED' -# checkname() { -# // code of the function. The function should be named checkname -# } -# -# Check alternate names -# CHECK_ALTERNATE[alternatename] = "checkname" -# CHECK_ALTERNATE["check101"] = "check11" - -# # For group of checks arrays -# declare -a GROUP_NAME -# declare -a GROUP_TITLE -# declare -a GROUP_RUN_BY_DEFAULT -# declare -a GROUP_CHECKS -# -# # For checks -# declare -a CHECK_TITLE -# declare -a CHECK_ID -# declare -a CHECK_SCORED -# declare -a CHECK_ALTERNATE - # Include all of the groups of checks inside include folder -for group in $(ls include/group*); do +for group in $(ls groups/group*); do . "$group" done # Include all of the checks inside include folder # this includes also extra check since they are "check_extraNN" -for checks in $(ls include/check*); do +for checks in $(ls checks/check*); do . "$checks" done # Function to show the title of the check show_check_title() { # This would just call textTitle - textTitle "${CHECK_ID[$1]} ${CHECK_TITLE[$1]} ${CHECK_SCORED[$1]}" + textTitle "${CHECK_ID[$1]}" "${CHECK_TITLE[$1]}" "${CHECK_SCORED[$1]}" "${CHECK_TYPE[$1]}" } # Function to show the title of a group, by numeric id show_group_title() { # This would also just call textTitle in the real prowler - textTitle ${GROUP_NUMBER[$1]} - ${GROUP_TITLE[$1]} + if [[ "$MODE" != "csv" ]]; then + textTitle "${GROUP_NUMBER[$1]}" "${GROUP_TITLE[$1]}" "NOT_SCORED" "SUPPORT" + fi } # Function to execute the check @@ -586,7 +503,9 @@ execute_group_by_name() { # Function to execute all checks in all groups execute_all() { for i in ${#GROUP_TITLE[@]}; do - execute_group $i + if [ "${GROUP_RUN_BY_DEFAULT[$i]}" == "Y" ]; then + execute_group $i + fi done } @@ -613,13 +532,13 @@ genCredReport saveReport callCheck -execute_all +show_all_titles -if [[ ! $EXTRAS ]]; then - textTitle "7" "$TITLE7" "NOT_SCORED" "SUPPORT" - execute_group 7 -fi +# if [[ ! $EXTRAS ]]; then +# textTitle "7" "$TITLE7" "NOT_SCORED" "SUPPORT" +# execute_group 7 +# fi cleanTemp exit $EXITCODE