Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

patch issues in migration

Matheus Nogueirabbbf480a2ad4
diff --git a/backend/src/db/migrations/20260924120000_encrypt-secret-scanning-finding-details.ts b/backend/src/db/migrations/20260924120000_encrypt-secret-scanning-finding-details.ts
index c25369f33d..fd22270733 100644
--- a/backend/src/db/migrations/20260924120000_encrypt-secret-scanning-finding-details.ts
+++ b/backend/src/db/migrations/20260924120000_encrypt-secret-scanning-finding-details.ts
@@ -36,7 +36,12 @@ const rewriteFindings = async (
const kmsRootConfigDAL = kmsRootConfigDALFactory(knex);
const envConfig = await getMigrationEnvConfig(superAdminDAL, hsmService, kmsRootConfigDAL);
const keyStore = inMemoryKeyStore();
- const { kmsService } = await getMigrationEncryptionServices({ envConfig, keyStore, db: knex });
+ const { kmsService } = await getMigrationEncryptionServices({
+ envConfig,
+ keyStore,
+ db: knex,
+ skipHsmLicenseCheck: true
+ });
const projectKmsCache = createCircularCache<TProjectKms>(25);
let lastId: string | undefined;
@@ -112,9 +117,14 @@ export async function down(knex: Knex): Promise<void> {
if (!(await knex.schema.hasColumn(TableName.SecretScanningFinding, "encryptedDetails"))) return;
- await rewriteFindings(knex, "encryptedDetails", (row, projectKms) => ({
- details: projectKms.decryptor({ cipherTextBlob: row.encryptedDetails as Buffer }).toString()
- }));
+ // Findings collected after the up migration carry the detected secret, which must not land in plaintext.
+ await rewriteFindings(knex, "encryptedDetails", (row, projectKms) => {
+ const { secret, match, ...details } = JSON.parse(
+ projectKms.decryptor({ cipherTextBlob: row.encryptedDetails as Buffer }).toString()
+ ) as Record<string, unknown>;
+
+ return { details: JSON.stringify(details) };
+ });
await knex.schema.alterTable(TableName.SecretScanningFinding, (t) => {
t.jsonb("details").notNullable().alter();