Skip to content

Audit PostgreSQL, MongoDB, Cassandra, and RHEL Targets

Read Reference Index before you start.

Prerequisites

  1. Make sure that Python 3.8+ exists on the controller.
  2. Install client tools (psql, mongosh, or cqlsh) for your targets.
  3. Confirm sudo -n access on target RHEL hosts.

Safety Instructions

CAUTION: Set mode 0600 on .pgpass and cqlshrc before you start. Open permissions expose secrets and cause client tools to fail.

CAUTION: Do not pass database passwords on the command line. Command arguments expose secrets in process tables (ps aux).

CAUTION: Confirm sudo -n rules before you run --sudo audits. Interactive password prompts stop automated runs with permission errors.

Procedure

  1. Restrict ~/.pgpass and ~/.cassandra/cqlshrc permissions to mode 0600:
chmod 0600 ~/.pgpass ~/.cassandra/cqlshrc
  1. Run PostgreSQL 16, 17, or 18 audits with --defaults-file:
python3 audit_cis.py -t postgresql16 --local -H 127.0.0.1 -P 5432 -u postgres -D postgres --defaults-file ~/.pgpass -f json -o reports/pg16.json
python3 audit_cis.py -t postgresql17 --docker pg17-prod --defaults-file ~/.pgpass -f html -o reports/pg17.html
python3 audit_cis.py -t postgresql18 -m ssh -r admin@192.168.1.50 -i ~/.ssh/id_ed25519 --defaults-file ~/.pgpass -f json -o reports/pg18.json
  1. Export CIS_DB_PASSWORD in the shell environment:
export CIS_DB_PASSWORD="$(vault_fetch_secret)"
  1. Run MongoDB 7.0 or 8.0 audits with --auth-db:
python3 audit_cis.py -t mongodb7 --local -H 127.0.0.1 -P 27017 -u audit_user --auth-db admin -f json -o reports/mongo7.json
python3 audit_cis.py -t mongodb8 --docker mongo8-prod -u audit_user --auth-db admin -f html -o reports/mongo8.html
  1. Unset CIS_DB_PASSWORD immediately after the MongoDB audit ends:
unset CIS_DB_PASSWORD
  1. Run Apache Cassandra 4.0, 4.1, or 5.0 audits with cqlshrc:
python3 audit_cis.py -t cassandra40 --local -H 127.0.0.1 -P 9042 --defaults-file ~/.cassandra/cqlshrc -f json -o reports/cas40.json
python3 audit_cis.py -t cassandra41 --docker cas41-prod --defaults-file ~/.cassandra/cqlshrc -f html -o reports/cas41.html
python3 audit_cis.py -t cassandra50 -m ssh -r admin@192.168.1.60 -i ~/.ssh/id_ed25519 --defaults-file ~/.cassandra/cqlshrc -f json -o reports/cas50.json
  1. Run Red Hat Enterprise Linux 8, 9, or 10 audits with --sudo:
python3 audit_cis.py -t rhel8 --local --sudo -f json -o reports/rhel8.json
python3 audit_cis.py -t rhel9 -m ssh -r admin@192.168.1.70 -i ~/.ssh/id_ed25519 --sudo -f html -o reports/rhel9.html
python3 audit_cis.py -t rhel10 -m ssh -r admin@192.168.1.71 -i ~/.ssh/id_ed25519 --sudo -f sarif -o reports/rhel10.sarif

NOTE: Each PostgreSQL target checks 71 controls, MongoDB checks 23, Cassandra checks 20, and RHEL checks 20.

Verification

  1. Confirm exit code 0 for each audit_cis.py command.
  2. Confirm zero Error entries in each JSON report:
python3 -c "import glob, json; [print(p, d.get('overall_score'), sum(str(x.get('status','')).upper()=='ERROR' for x in (d['results'] if isinstance(d['results'],list) else sum(d['results'].values(),[])))) for p in sorted(glob.glob('reports/*.json')) for d in [json.load(open(p, encoding='utf-8'))]]"
  1. Confirm that CIS_DB_PASSWORD is empty with test -z "${CIS_DB_PASSWORD:-}".

Rollback

  1. Unset CIS_DB_PASSWORD in the active shell session.
  2. Stop any stuck audit_cis.py process on the controller.
  3. Delete partial report files from reports/.
  4. Restore previous .pgpass, cqlshrc, or sudoers file permissions.