Skip to content

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

apply codex recommendations

adilson95a3d104985a
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
index 0259d40ca4..9df5e46b35 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
@@ -960,7 +960,12 @@ export const secretRotationV2ServiceFactory = ({
message: `Could not find ${SECRET_ROTATION_NAME_MAP[type]} Rotation with ID "${rotationId}"`
});
- const { projectId, folderId: sourceFolderId, secretsMapping, folder, environment } = secretRotation;
+ const { projectId, folderId: sourceFolderId, secretsMapping, folder, environment, connection } = secretRotation;
+
+ if (connection.app !== SECRET_ROTATION_CONNECTION_MAP[type])
+ throw new BadRequestError({
+ message: `Secret Rotation with ID "${rotationId}" is not configured for ${SECRET_ROTATION_NAME_MAP[type]}`
+ });
const { permission } = await permissionService.getProjectPermission({
actor: actor.type,
@@ -1000,6 +1005,16 @@ export const secretRotationV2ServiceFactory = ({
})
);
+ const conflictingRotation = await secretRotationV2DAL.findOne({
+ name: secretRotation.name,
+ folderId: destinationFolder.id
+ });
+
+ if (conflictingRotation)
+ throw new BadRequestError({
+ message: `A Secret Rotation with the name "${secretRotation.name}" already exists at the secret path "${destinationSecretPath}"`
+ });
+
const mappedKeys = Object.values(secretsMapping as TSecretRotationV2["secretsMapping"]);
await $throwOnConflictingSecrets({
diff --git a/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts b/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts
index 3cd799e5e4..556e5c72df 100644
--- a/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts
+++ b/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts
@@ -470,7 +470,7 @@ export const AwsParameterStoreSyncFns = {
if (!(key in secretMap) || !secretMap[key].value) {
parametersToDelete.push(parameter);
- deletedSecretKeys.push(parameter.Name);
+ deletedSecretKeys.push(key);
}
}
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
index f9d713e7b8..5ee6b332d0 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
@@ -224,6 +224,7 @@ export const fnSecretBulkUpdate = async ({
})
);
+ // const allHaveIds = sanitizedInputSecrets.every((s): s is typeof s & { filter: { id: string } } => !!s.filter.id);
const newSecrets = await secretDAL.bulkUpdate(sanitizedInputSecrets, tx);
const versionData = newSecrets.map(
({ skipMultilineEncoding, type, key, userId, encryptedComment, version, encryptedValue, id: secretId }, index) => ({
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
index 67e714caf2..01f64d1bbe 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
@@ -35,7 +35,10 @@ import {
} from "@app/components/v3";
import { FilterableSelect } from "@app/components/v3/generic/ReactSelect";
import { ProjectPermissionSub, useProjectPermission } from "@app/context";
-import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
+import {
+ ProjectPermissionSecretActions,
+ ProjectPermissionSecretRotationActions
+} from "@app/context/ProjectPermissionContext/types";
import { useDebounce } from "@app/hooks";
import { useMoveSecrets } from "@app/hooks/api";
import { useGetProjectSecretsQuickSearch } from "@app/hooks/api/dashboard";
@@ -465,12 +468,12 @@ const MultiEnvContent = ({
}
});
- const moveSecretsEligibility = useMemo(() => {
+ const moveEligibility = useMemo(() => {
return Object.fromEntries(
environments.map((env) => [
env.slug,
{
- missingPermissions: permission.cannot(
+ cannotMoveSecrets: permission.cannot(
ProjectPermissionSecretActions.Delete,
subject(ProjectPermissionSub.Secrets, {
environment: env.slug,
@@ -478,6 +481,13 @@ const MultiEnvContent = ({
secretName: "*",
secretTags: ["*"]
})
+ ),
+ cannotMoveRotations: permission.cannot(
+ ProjectPermissionSecretRotationActions.Delete,
+ subject(ProjectPermissionSub.SecretRotation, {
+ environment: env.slug,
+ secretPath: sourceSecretPath
+ })
)
}
])
@@ -494,17 +504,27 @@ const MultiEnvContent = ({
[];
environments.forEach((env) => {
- if (moveSecretsEligibility[env.slug].missingPermissions) {
+ const { cannotMoveSecrets, cannotMoveRotations } = moveEligibility[env.slug];
+
+ if (cannotMoveSecrets) {
+ environmentWarnings.push({
+ id: `${env.id}-secrets`,
+ type: "permission",
+ message: `${env.name}: You do not have permission to move secrets from this environment`
+ });
+ }
+
+ if (cannotMoveRotations) {
environmentWarnings.push({
- id: env.id,
+ id: `${env.id}-rotations`,
type: "permission",
- message: `${env.name}: You do not have permission to remove secrets from this environment`
+ message: `${env.name}: You do not have permission to move secret rotations from this environment`
});
}
});
return environmentWarnings;
- }, [moveSecretsEligibility, destinationSelected, environments]);
+ }, [moveEligibility, destinationSelected, environments]);
const handleFormSubmit = async (data: TMultiEnvFormSchema) => {
if (!selectedPath) {
@@ -542,14 +562,16 @@ const MultiEnvContent = ({
for await (const environment of environments) {
const envSlug = environment.slug;
- const secretsToMove = secretsByEnv[envSlug];
- const rotationsToMove = rotationsByEnv[envSlug];
+ const { cannotMoveSecrets, cannotMoveRotations } = moveEligibility[envSlug];
- if (moveSecretsEligibility[envSlug].missingPermissions) {
+ if (cannotMoveSecrets && cannotMoveRotations) {
// eslint-disable-next-line no-continue
continue;
}
+ const secretsToMove = cannotMoveSecrets ? [] : secretsByEnv[envSlug];
+ const rotationsToMove = cannotMoveRotations ? [] : rotationsByEnv[envSlug];
+
if (!secretsToMove.length && !rotationsToMove.length) {
results.push({
name: environment.name,