mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 04:27:29 +00:00
add sslmode parsing to audit log db
This commit is contained in:
@@ -108,13 +108,23 @@ export const initAuditLogDbConnection = ({
|
|||||||
dbConnectionUri: string;
|
dbConnectionUri: string;
|
||||||
dbRootCert?: string;
|
dbRootCert?: string;
|
||||||
}) => {
|
}) => {
|
||||||
|
// Parse out ?sslmode=... from the connection URI if its not equal to "disable" and dbRootCert is defined
|
||||||
|
let modifiedDbConnectionUri = dbConnectionUri;
|
||||||
|
if (dbRootCert) {
|
||||||
|
const url = new URL(dbConnectionUri);
|
||||||
|
if (url.searchParams.has("sslmode") && url.searchParams.get("sslmode") !== "disable") {
|
||||||
|
url.searchParams.delete("sslmode");
|
||||||
|
modifiedDbConnectionUri = url.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// akhilmhdh: the default Knex is knex.Knex<any, any[]>. but when assigned with knex({<config>}) the value is knex.Knex<any, unknown[]>
|
// akhilmhdh: the default Knex is knex.Knex<any, any[]>. but when assigned with knex({<config>}) the value is knex.Knex<any, unknown[]>
|
||||||
// this was causing issue with files like `snapshot-dal` `findRecursivelySnapshots` this i am explicitly putting the any and unknown[]
|
// this was causing issue with files like `snapshot-dal` `findRecursivelySnapshots` this i am explicitly putting the any and unknown[]
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const db: Knex<any, unknown[]> = knex({
|
const db: Knex<any, unknown[]> = knex({
|
||||||
client: "pg",
|
client: "pg",
|
||||||
connection: {
|
connection: {
|
||||||
connectionString: dbConnectionUri,
|
connectionString: modifiedDbConnectionUri,
|
||||||
host: process.env.AUDIT_LOGS_DB_HOST,
|
host: process.env.AUDIT_LOGS_DB_HOST,
|
||||||
// @ts-expect-error I have no clue why only for the port there is a type error
|
// @ts-expect-error I have no clue why only for the port there is a type error
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|||||||
Reference in New Issue
Block a user