From e859b89cec0b2ec058cfe10764957cda2058a00a Mon Sep 17 00:00:00 2001 From: teoberi Date: Sun, 3 Jan 2021 11:54:35 +0200 Subject: [PATCH 1/3] Update consts Fix the variable name for PostgreSQL --- include/consts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/consts b/include/consts index bb1d63ff..9c4e1ea0 100644 --- a/include/consts +++ b/include/consts @@ -232,7 +232,7 @@ ETC_PATHS="/etc /usr/local/etc" PLUGINDIR="" PLUGIN_PHASE=0 POSTFIXBINARY="" - POSTGRES_RUNNING=0 + POSTGRESQL_RUNNING=0 PREVIOUS_TEST="No test ID" PREVIOUS_TS=0 PROFILES="" From 49b53982663d597d143b508ac95d7d47700c7c4a Mon Sep 17 00:00:00 2001 From: teoberi Date: Sun, 3 Jan 2021 12:02:38 +0200 Subject: [PATCH 2/3] Update tests_databases Fix the process name for PostgreSQL Add new path to variable FIND_PATHS Fix variable CONFIG_FILES Check permissions for configuration files --- include/tests_databases | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/tests_databases b/include/tests_databases index 9c8e1de0..3f8777f0 100644 --- a/include/tests_databases +++ b/include/tests_databases @@ -174,7 +174,7 @@ # Description : Check if PostgreSQL is being used Register --test-no DBS-1826 --weight L --network NO --category security --description "Checking active PostgreSQL processes" if [ ${SKIPTEST} -eq 0 ]; then - if IsRunning "postgres:"; then + if IsRunning "postgres"; then Display --indent 2 --text "- PostgreSQL processes status" --result "${STATUS_FOUND}" --color GREEN LogText "Result: PostgreSQL is active" POSTGRESQL_RUNNING=1 @@ -203,11 +203,17 @@ Register --test-no DBS-1828 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Test PostgreSQL configuration" if [ ${SKIPTEST} -eq 0 ]; then - FIND_PATHS="${ROOTDIR}etc/postgres ${ROOTDIR}var/lib/postgres/data" - CONFIG_FILES=$(${FINDBINARY} ${FIND_PATHS} -type f -name "postgresql.conf" -print0 2> /dev/null | ${TRBINARY} -cd '[:print:]\0' | ${TRBINARY} -d '\n' | ${TRBINARY} '\0' '\n' | xargs -i sh -c 'test -r "{}" && echo "{}" | ${SEDBINARY} "s/ /:space:/g"') + FIND_PATHS="${ROOTDIR}etc/postgres ${ROOTDIR}var/lib/postgres/data ${ROOTDIR}usr/local/pgsql/data" + CONFIG_FILES=$(${FINDBINARY} ${FIND_PATHS} -type f -name "postgresql.conf" -print0 2> /dev/null | ${TRBINARY} -cd '[:print:]\0' | ${TRBINARY} -d '\n' | ${TRBINARY} '\0' '\n' | xargs -i sh -c 'test -r "{}" && echo "{}"' | ${SEDBINARY} "s/ /:space:/g") for CF in ${CONFIG_FILES}; do Report "postgresql_config_file[]=${CF}" LogText "Found configuration file (${CF})" + if IsWorldReadable ${CF}; then + LogText "Result: configuration file ${CF} is world readable, this might leak sensitive information!" + ReportWarning "${TEST_NO}" "PostgreSQL configuration file ${CF} is world readable and might leak sensitive details" "${CF}" "Use chmod 600 to change file permissions" + else + LogText "Result: great, configuration file ${CF} is not world readable" + fi done fi # From 82db00202598d274bf9dd602761c44e4abaec74f Mon Sep 17 00:00:00 2001 From: teoberi Date: Thu, 7 Jan 2021 21:16:19 +0200 Subject: [PATCH 3/3] Update tests_databases Change pattern to detect all configuration files --- include/tests_databases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tests_databases b/include/tests_databases index 3f8777f0..1fcafa25 100644 --- a/include/tests_databases +++ b/include/tests_databases @@ -204,7 +204,7 @@ Register --test-no DBS-1828 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Test PostgreSQL configuration" if [ ${SKIPTEST} -eq 0 ]; then FIND_PATHS="${ROOTDIR}etc/postgres ${ROOTDIR}var/lib/postgres/data ${ROOTDIR}usr/local/pgsql/data" - CONFIG_FILES=$(${FINDBINARY} ${FIND_PATHS} -type f -name "postgresql.conf" -print0 2> /dev/null | ${TRBINARY} -cd '[:print:]\0' | ${TRBINARY} -d '\n' | ${TRBINARY} '\0' '\n' | xargs -i sh -c 'test -r "{}" && echo "{}"' | ${SEDBINARY} "s/ /:space:/g") + CONFIG_FILES=$(${FINDBINARY} ${FIND_PATHS} -type f -name "*.conf" -print0 2> /dev/null | ${TRBINARY} -cd '[:print:]\0' | ${TRBINARY} -d '\n' | ${TRBINARY} '\0' '\n' | xargs -i sh -c 'test -r "{}" && echo "{}"' | ${SEDBINARY} "s/ /:space:/g") for CF in ${CONFIG_FILES}; do Report "postgresql_config_file[]=${CF}" LogText "Found configuration file (${CF})"