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