You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Entering the container for reference: inspec shell -t docker://test_postgres --input-file ./crunchy-data-postgresql-stig-baseline/inputs_postgres14_example.yml
Error: Querying pgaudit.log_level without specifying the database name (this is what is written in the InSpec control V-233512):
sql.query('show pgaudit.log_level')
@desc="PostgreSQL query with error: show pgaudit.log_level",
@output="\npsql: error: connection to server at \"localhost\" (::1), port 5432 failed: FATAL: database \"testuser\" does not exist\n">
Success: Querying pgaudit.log_level with specifying the database name:
sql.query('show pgaudit.log_level', [input('pg_db')])
@desc="PostgreSQL query: show pgaudit.log_level", @output="log"
cobbling some stuff together and using this bitnami image that has pgaudit installed by default:
docker run -it --name postgres-audit -e ALLOW_EMPTY_PASSWORD=yes -e POSTGRESQL_PGAUDIT_LOG=ALL docker.io/bitnami/postgresql:15
spins up postgres and enables pgaudit (see the line in the console saying 'pgaudit extension initialized')
$ docker exec -it postgres-audit psql -U postgres -A -t -c "SHOW pgaudit.log_level;"
log
runs that query of yours and returns a value without crashing like yours did
the line i'm running i actually pulled from this similar control from some vmware stig: https://www.stigviewer.com/stig/vmware_vsphere_8.0_vcenter_appliance_postgresql/2023-10-29/finding/V-259169 - the flags are basically just formatting things but you can look at it yourself if you want
the key thing to note i think is that i'm coming in as the postgres user and there is a postgres db created by default in the instance
$ docker exec -it postgres-audit psql -U postgres -A -t -c "\l"
postgres|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|
template0|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|=c/postgres
postgres=CTc/postgres
template1|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|=c/postgres
postgres=CTc/postgres
i think you are coming in as testuser and are not explicitly setting a database in which you are doing this. looking at the docs, i think if you don't explicitly provide a database name then it uses the username as the name of the database: see "Usage" section here near the end of that first paragraph: https://www.postgresql.org/docs/15/app-psql.html. and then as the error states, since there is no database containing the name testuser it blows up.
resolution would probably be to just provide the database name
The text was updated successfully, but these errors were encountered:
Entering the container for reference:
inspec shell -t docker://test_postgres --input-file ./crunchy-data-postgresql-stig-baseline/inputs_postgres14_example.yml
Error: Querying pgaudit.log_level without specifying the database name (this is what is written in the InSpec control V-233512):
Success: Querying pgaudit.log_level with specifying the database name:
cobbling some stuff together and using this bitnami image that has pgaudit installed by default:
docker run -it --name postgres-audit -e ALLOW_EMPTY_PASSWORD=yes -e POSTGRESQL_PGAUDIT_LOG=ALL docker.io/bitnami/postgresql:15
spins up postgres and enables pgaudit (see the line in the console saying 'pgaudit extension initialized')
$ docker exec -it postgres-audit psql -U postgres -A -t -c "SHOW pgaudit.log_level;"
log
runs that query of yours and returns a value without crashing like yours did
the line i'm running i actually pulled from this similar control from some vmware stig: https://www.stigviewer.com/stig/vmware_vsphere_8.0_vcenter_appliance_postgresql/2023-10-29/finding/V-259169 - the flags are basically just formatting things but you can look at it yourself if you want
the key thing to note i think is that i'm coming in as the postgres user and there is a postgres db created by default in the instance
$ docker exec -it postgres-audit psql -U postgres -A -t -c "\l"
postgres|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|
template0|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|=c/postgres
postgres=CTc/postgres
template1|postgres|UTF8|en_US.UTF-8|en_US.UTF-8||libc|=c/postgres
postgres=CTc/postgres
i think you are coming in as testuser and are not explicitly setting a database in which you are doing this. looking at the docs, i think if you don't explicitly provide a database name then it uses the username as the name of the database: see "Usage" section here near the end of that first paragraph: https://www.postgresql.org/docs/15/app-psql.html. and then as the error states, since there is no database containing the name testuser it blows up.
resolution would probably be to just provide the database name
The text was updated successfully, but these errors were encountered: