@@ -824,79 +824,3 @@ def test_postgrest_read_only_session_attrs(host):
824824 print ("Warning: Failed to restart PostgreSQL after restoring config" )
825825 else :
826826 print ("Warning: Failed to restore PostgreSQL configuration" )
827-
828-
829- def test_cis_baseline_audit (host ):
830- """Run CIS baseline audit against the machine and report results.
831-
832- This test uploads the current baseline.yml from the repo and uses
833- cis-audit to validate the machine against it. The test reports findings
834- but does not fail the build - it's for visibility into configuration drift.
835- """
836- git_sha = os .environ .get ("GITHUB_SHA" , "HEAD" )
837-
838- # Find the baseline file relative to the test file location
839- test_dir = Path (__file__ ).parent .parent
840- baseline_path = test_dir / "audit-specs" / "baselines" / "baseline.yml"
841-
842- if not baseline_path .exists ():
843- print (f"\n ⚠️ Baseline file not found at { baseline_path } " )
844- print ("Skipping CIS baseline audit - no baseline file available" )
845- pytest .skip ("Baseline file not found" )
846- return
847-
848- print (f"\n { '=' * 60 } " )
849- print ("CIS BASELINE AUDIT" )
850- print (f"{ '=' * 60 } " )
851- print (f"Baseline file: { baseline_path } " )
852-
853- # Upload baseline file to the instance
854- remote_baseline_path = "/tmp/baseline.yml"
855- try :
856- upload_file_via_sftp (host ["ssh" ], str (baseline_path ), remote_baseline_path )
857- print (f"✓ Uploaded baseline to { remote_baseline_path } " )
858- except Exception as e :
859- print (f"✗ Failed to upload baseline file: { e } " )
860- pytest .skip (f"Failed to upload baseline: { e } " )
861- return
862-
863- # Install cis-audit via nix
864- print ("\n Installing cis-audit tool..." )
865- install_cmd = f"nix profile install github:supabase/postgres/{ git_sha } #cis-audit --refresh 2>&1"
866- result = run_ssh_command (host ["ssh" ], install_cmd , timeout = 300 )
867- if not result ["succeeded" ]:
868- print (f"Warning: { result ['stderr' ][:500 ]} " )
869-
870- # Run cis-audit with documentation format for readable output
871- print ("\n Running CIS baseline validation..." )
872- print (f"{ '-' * 60 } " )
873-
874- # Use the uploaded baseline file (local path, not bundled)
875- validate_cmd = f"~/.nix-profile/bin/cis-audit --spec { remote_baseline_path } --format documentation 2>&1"
876- result = run_ssh_command (host ["ssh" ], validate_cmd , timeout = 600 )
877-
878- # Print full output for visibility in GitHub Actions logs
879- print (result ["stdout" ])
880- if result ["stderr" ]:
881- print (f"\n Stderr:\n { result ['stderr' ]} " )
882-
883- print (f"{ '-' * 60 } " )
884-
885- # Also run with tap format to get summary counts
886- validate_tap_cmd = f"~/.nix-profile/bin/cis-audit --spec { remote_baseline_path } --format tap 2>&1 | tail -10"
887- result_tap = run_ssh_command (host ["ssh" ], validate_tap_cmd , timeout = 600 )
888-
889- print (f"\n Summary:" )
890- print (result_tap ["stdout" ])
891-
892- # Clean up
893- run_ssh_command (host ["ssh" ], f"rm -f { remote_baseline_path } " )
894-
895- print (f"{ '=' * 60 } " )
896- print ("CIS BASELINE AUDIT COMPLETE" )
897- print (f"{ '=' * 60 } \n " )
898-
899- # Note: This test intentionally does not assert/fail on validation results
900- # It's meant to provide visibility into configuration state
901- # To make this test fail on drift, uncomment the following:
902- # assert result["succeeded"], "CIS baseline validation found differences"
0 commit comments