Skip to content

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

refactor: simplify permission validation logic by consolidating checks for legacy actions in permission-fns

Victor Santos51fb48217c3a
diff --git a/backend/src/ee/services/permission/permission-fns.ts b/backend/src/ee/services/permission/permission-fns.ts
index fd12e313df..62dd05cafb 100644
--- a/backend/src/ee/services/permission/permission-fns.ts
+++ b/backend/src/ee/services/permission/permission-fns.ts
@@ -84,22 +84,21 @@ export function checkForInvalidPermissionCombination(permissions: z.infer<typeof
const hasReadValue = permission.action.includes(ProjectPermissionSecretActions.ReadValue);
const hasDescribeSecret = permission.action.includes(ProjectPermissionSecretActions.DescribeSecret);
- // eslint-disable-next-line no-continue
- if (!hasReadValue && !hasDescribeSecret) continue;
-
- const hasBothDescribeAndReadValue = hasReadValue && hasDescribeSecret;
-
- throw new BadRequestError({
- message: `You have selected Read, and ${
- hasBothDescribeAndReadValue
- ? "both Read Value and Describe Secret"
- : hasReadValue
- ? "Read Value"
- : hasDescribeSecret
- ? "Describe Secret"
- : ""
- }. You cannot select Read Value or Describe Secret if you have selected Read. The Read permission is a legacy action which has been replaced by Describe Secret and Read Value.`
- });
+ if (hasReadValue || hasDescribeSecret) {
+ const hasBothDescribeAndReadValue = hasReadValue && hasDescribeSecret;
+
+ throw new BadRequestError({
+ message: `You have selected Read, and ${
+ hasBothDescribeAndReadValue
+ ? "both Read Value and Describe Secret"
+ : hasReadValue
+ ? "Read Value"
+ : hasDescribeSecret
+ ? "Describe Secret"
+ : ""
+ }. You cannot select Read Value or Describe Secret if you have selected Read. The Read permission is a legacy action which has been replaced by Describe Secret and Read Value.`
+ });
+ }
}
}
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/VaultPolicyImportModal.utils.ts b/frontend/src/pages/project/RoleDetailsBySlugPage/components/VaultPolicyImportModal.utils.ts
index 57fbe578d4..d7d010a75c 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/VaultPolicyImportModal.utils.ts
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/VaultPolicyImportModal.utils.ts
@@ -308,7 +308,9 @@ const createPermissionRuleKey = (rule: SecretPermissionRule | FolderPermissionRu
.map(([key, value]) => `${key}:${value}`)
.join("|");
- const conditions = (rule.conditions || [])
+ const ruleConditions =
+ (rule.conditions as Array<{ lhs: string; operator: string; rhs: string }> | undefined) || [];
+ const conditions = ruleConditions
.map((c) => `${c.lhs}${c.operator}${c.rhs}`)
.sort()
.join("|");