mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 15:40:47 +00:00
Block secret mutations during upgrade
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TDbClient } from "@app/db";
|
||||
import { ProjectsSchema, ProjectUpgradeStatus, TableName, TProjectsUpdate } from "@app/db/schemas";
|
||||
import { ProjectsSchema, ProjectUpgradeStatus, ProjectVersion, TableName, TProjectsUpdate } from "@app/db/schemas";
|
||||
import { DatabaseError } from "@app/lib/errors";
|
||||
import { ormify, selectAllTableCols, sqlNestRelationships } from "@app/lib/knex";
|
||||
|
||||
@@ -160,12 +160,18 @@ export const projectDALFactory = (db: TDbClient) => {
|
||||
}
|
||||
};
|
||||
|
||||
const isProjectBeingUpgraded = async (projectId: string) => {
|
||||
const project = await projectOrm.findById(projectId);
|
||||
return project.upgradeStatus === ProjectUpgradeStatus.InProgress && project.version === ProjectVersion.V1;
|
||||
};
|
||||
|
||||
return {
|
||||
...projectOrm,
|
||||
findAllProjects,
|
||||
setProjectUpgradeStatus,
|
||||
findAllProjectsByIdentity,
|
||||
findProjectGhostUser,
|
||||
findProjectById
|
||||
findProjectById,
|
||||
isProjectBeingUpgraded
|
||||
};
|
||||
};
|
||||
|
||||
@@ -150,12 +150,6 @@ export const projectQueueFactory = ({
|
||||
oldProjectKey
|
||||
);
|
||||
|
||||
console.log(
|
||||
decryptedSecrets
|
||||
.filter((s) => s.docType === SecretDocType.ApprovalSecret)
|
||||
.map((s) => `${s.secretKey} - ${s.secretValue}`)
|
||||
);
|
||||
|
||||
if (secrets.length !== decryptedSecrets.length) {
|
||||
throw new Error("Failed to decrypt some secret versions");
|
||||
}
|
||||
@@ -396,10 +390,10 @@ export const projectQueueFactory = ({
|
||||
|
||||
await projectDAL.setProjectUpgradeStatus(data.projectId, null, tx);
|
||||
|
||||
throw new Error("Transaction was successful!");
|
||||
// await new Promise((resolve) => setTimeout(resolve, 60_000));
|
||||
// throw new Error("Transaction was successful!");
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
const [project] = await projectDAL
|
||||
.find({
|
||||
id: data.projectId,
|
||||
|
||||
Reference in New Issue
Block a user