Audit PostgreSQL, MongoDB, Cassandra, and RHEL Targets¶
Read Reference Index before you start.
Prerequisites¶
- Make sure that Python
3.8+exists on the controller. - Install client tools (
psql,mongosh, orcqlsh) for your targets. - Confirm
sudo -naccess 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¶
- Restrict
~/.pgpassand~/.cassandra/cqlshrcpermissions to mode0600:
- Run PostgreSQL
16,17, or18audits 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
- Export
CIS_DB_PASSWORDin the shell environment:
- Run MongoDB
7.0or8.0audits 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
- Unset
CIS_DB_PASSWORDimmediately after the MongoDB audit ends:
- Run Apache Cassandra
4.0,4.1, or5.0audits withcqlshrc:
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
- Run Red Hat Enterprise Linux
8,9, or10audits 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¶
- Confirm exit code
0for eachaudit_cis.pycommand. - Confirm zero
Errorentries 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'))]]"
- Confirm that
CIS_DB_PASSWORDis empty withtest -z "${CIS_DB_PASSWORD:-}".
Rollback¶
- Unset
CIS_DB_PASSWORDin the active shell session. - Stop any stuck
audit_cis.pyprocess on the controller. - Delete partial report files from
reports/. - Restore previous
.pgpass,cqlshrc, orsudoersfile permissions.