@@ -22,14 +22,6 @@ function unescapeNewlines(value: string): string {
2222 return value . replace ( / \\ n / g, "\n" ) ;
2323}
2424
25- /**
26- * Quote a PostgreSQL identifier (safe against injection).
27- * Use for database, schema, and role names in dynamic SQL.
28- */
29- export function quoteIdent ( name : string ) : string {
30- return '"' + String ( name ) . replace ( / " / g, '""' ) + '"' ;
31- }
32-
3325/**
3426 * Read certificate content from a file path.
3527 * @param filePath - Path to the certificate file
@@ -82,24 +74,15 @@ export async function configurePostgresCredentials(
8274 sslMode ?: string ;
8375 } ,
8476) : Promise < void > {
85- const sslMode = credentials . sslMode || "require" ;
8677 const data : Record < string , string > = {
8778 POSTGRES_HOST : Buffer . from ( credentials . host ) . toString ( "base64" ) ,
8879 POSTGRES_PORT : Buffer . from ( credentials . port || "5432" ) . toString ( "base64" ) ,
89- PGSSLMODE : Buffer . from ( sslMode ) . toString ( "base64" ) ,
80+ PGSSLMODE : Buffer . from ( credentials . sslMode || "require" ) . toString ( "base64" ) ,
81+ NODE_EXTRA_CA_CERTS : Buffer . from (
82+ "/opt/app-root/src/postgres-crt.pem" ,
83+ ) . toString ( "base64" ) ,
9084 } ;
9185
92- // In-cluster path where RHDH reads the mounted postgres TLS bundle (override via POSTGRES_NODE_EXTRA_CA_CERTS).
93- const nodeExtraCaCerts =
94- process . env . POSTGRES_NODE_EXTRA_CA_CERTS ||
95- "/opt/app-root/src/postgres-crt.pem" ;
96- // Only set certificate path when SSL is enabled. When disable, we omit
97- // NODE_EXTRA_CA_CERTS; createOrUpdateSecret replaces secret data entirely
98- // so a previously set value is removed.
99- if ( sslMode !== "disable" ) {
100- data . NODE_EXTRA_CA_CERTS = Buffer . from ( nodeExtraCaCerts ) . toString ( "base64" ) ;
101- }
102-
10386 if ( credentials . user ) {
10487 data . POSTGRES_USER = Buffer . from ( credentials . user ) . toString ( "base64" ) ;
10588 }
@@ -203,9 +186,7 @@ export async function clearDatabase(credentials: {
203186 for ( let attempt = 1 ; attempt <= maxRetries ; attempt ++ ) {
204187 try {
205188 // WITH (FORCE) atomically terminates connections and drops the database
206- await client . query (
207- `DROP DATABASE IF EXISTS ${ quoteIdent ( db ) } WITH (FORCE)` ,
208- ) ;
189+ await client . query ( `DROP DATABASE IF EXISTS "${ db } " WITH (FORCE)` ) ;
209190 success = true ;
210191 break ;
211192 } catch ( error ) {
0 commit comments