edge case: read write for non existing env in deniedPermissions

This commit is contained in:
Maidul Islam
2023-09-15 22:32:03 -04:00
parent f16944024b
commit d8d480f2bc

View File

@@ -723,6 +723,13 @@ export const backfillPermission = async () => {
if (ability === "read") secretAccessRule[environmentSlug].read = false;
});
// environments that are not listed in deniedPermissions should be set to allowed for both read & and write
membership.workspace.environments.forEach(env => {
if (!secretAccessRule?.[env.slug]) {
secretAccessRule[env.slug] = { read: true, write: true };
}
})
const secretPermissions: any = [];
Object.entries(secretAccessRule).forEach(([envSlug, { read, write }]) => {
if (read) {
@@ -768,7 +775,7 @@ export const backfillPermission = async () => {
const { membershipIds, permissions, workspaceId, organizationId } = value
const membership_identity = crypto.randomBytes(3).toString("hex")
const role = new Role({
name: `Migrated Role [${membership_identity.toUpperCase()}]`,
name: `Limited [${membership_identity.toUpperCase()}]`,
organization: organizationId,
workspace: workspaceId,
description: "This role was auto generated by Infisical in effort to migrate your project members to our new permission system",