mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat(infisical-pg): resolved import secret breaking cli backward compatiability
This commit is contained in:
@@ -250,7 +250,8 @@ export const registerSecretImportRouter = async (server: FastifyZodProvider) =>
|
||||
secrets: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
environment: z.string(),
|
||||
environmentInfo: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
SecretsSchema,
|
||||
SecretTagsSchema,
|
||||
SecretType,
|
||||
ServiceTokenScopes,
|
||||
ServiceTokenScopes
|
||||
} from "@app/db/schemas";
|
||||
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
||||
import { CommitType } from "@app/ee/services/secret-approval-request/secret-approval-request-types";
|
||||
@@ -36,11 +36,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
imports: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
}),
|
||||
environment: z.string(),
|
||||
folderId: z.string().optional(),
|
||||
secrets: secretRawSchema.array()
|
||||
})
|
||||
@@ -68,7 +64,8 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
}
|
||||
}
|
||||
|
||||
if(!workspaceId || !environment) throw new BadRequestError({message:"Missing workspace id or environment"})
|
||||
if (!workspaceId || !environment)
|
||||
throw new BadRequestError({ message: "Missing workspace id or environment" });
|
||||
|
||||
const { secrets, imports } = await server.services.secret.getSecretsRaw({
|
||||
actorId: req.permission.id,
|
||||
@@ -360,11 +357,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
imports: z
|
||||
.object({
|
||||
secretPath: z.string(),
|
||||
environment: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string()
|
||||
}),
|
||||
environment: z.string(),
|
||||
folderId: z.string().optional(),
|
||||
secrets: SecretsSchema.omit({ secretBlindIndex: true }).array()
|
||||
})
|
||||
|
||||
@@ -33,7 +33,8 @@ export const fnSecretsFromImports = async ({
|
||||
const importedSecsGroupByFolderId = groupBy(importedSecrets, (i) => i.folderId);
|
||||
return allowedImports.map(({ importPath, importEnv }, i) => ({
|
||||
secretPath: importPath,
|
||||
environment: importEnv,
|
||||
environment: importEnv.slug,
|
||||
environmentInfo: importEnv,
|
||||
folderId: importedFolders?.[i]?.id,
|
||||
secrets: importedFolders?.[i]?.id
|
||||
? importedSecsGroupByFolderId[importedFolders?.[i]?.id as string]
|
||||
|
||||
@@ -585,7 +585,7 @@ export const secretServiceFactory = ({
|
||||
return {
|
||||
...importedSecrets[i].secrets[j],
|
||||
workspace: projectId,
|
||||
environment: importedSecrets[i].environment.slug
|
||||
environment: importedSecrets[i].environment
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -825,10 +825,7 @@ export const secretServiceFactory = ({
|
||||
imports: (imports || [])?.map(({ secrets: importedSecrets, ...el }) => ({
|
||||
...el,
|
||||
secrets: importedSecrets.map((sec) =>
|
||||
decryptSecretRaw(
|
||||
{ ...sec, environment: el.environment.slug, workspace: projectId },
|
||||
botKey
|
||||
)
|
||||
decryptSecretRaw({ ...sec, environment: el.environment, workspace: projectId }, botKey)
|
||||
)
|
||||
}))
|
||||
};
|
||||
|
||||
@@ -118,6 +118,7 @@ export const useGetImportedSecrets = ({
|
||||
return data.map((el) => ({
|
||||
environment: el.environment,
|
||||
secretPath: el.secretPath,
|
||||
environmentInfo: el.environmentInfo,
|
||||
folderId: el.folderId,
|
||||
secrets: el.secrets.map((encSecret) => {
|
||||
const secretKey = decryptSymmetric({
|
||||
|
||||
@@ -13,7 +13,8 @@ export type TSecretImport = {
|
||||
};
|
||||
|
||||
export type TImportedSecrets = {
|
||||
environment: WorkspaceEnv;
|
||||
environment: string;
|
||||
environmentInfo: WorkspaceEnv;
|
||||
secretPath: string;
|
||||
folderId: string;
|
||||
secrets: EncryptedSecret[];
|
||||
|
||||
@@ -14,7 +14,6 @@ import { arrayMove, SortableContext, verticalListSortingStrategy } from "@dnd-ki
|
||||
|
||||
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
|
||||
import { DeleteActionModal } from "@app/components/v2";
|
||||
import { useWorkspace } from "@app/context";
|
||||
import { usePopUp } from "@app/hooks";
|
||||
import { useDeleteSecretImport, useUpdateSecretImport } from "@app/hooks/api";
|
||||
import { TSecretImport } from "@app/hooks/api/secretImports/types";
|
||||
@@ -25,7 +24,7 @@ import { SecretImportItem } from "./SecretImportItem";
|
||||
const SECRET_IN_DASHBOARD = "Present In Dashboard";
|
||||
|
||||
type TImportedSecrets = Array<{
|
||||
environment: WorkspaceEnv;
|
||||
environmentInfo: WorkspaceEnv;
|
||||
secretPath: string;
|
||||
folderId: string;
|
||||
secrets: DecryptedSecret[];
|
||||
@@ -35,27 +34,22 @@ export const computeImportedSecretRows = (
|
||||
importedSecEnv: string,
|
||||
importedSecPath: string,
|
||||
importSecrets: TImportedSecrets = [],
|
||||
secrets: DecryptedSecret[] = [],
|
||||
environments: { name: string; slug: string }[] = []
|
||||
secrets: DecryptedSecret[] = []
|
||||
) => {
|
||||
const importedSecIndex = importSecrets.findIndex(
|
||||
({ secretPath, environment }) =>
|
||||
secretPath === importedSecPath && importedSecEnv === environment.slug
|
||||
({ secretPath, environmentInfo }) =>
|
||||
secretPath === importedSecPath && importedSecEnv === environmentInfo.slug
|
||||
);
|
||||
if (importedSecIndex === -1) return [];
|
||||
|
||||
const importedSec = importSecrets[importedSecIndex];
|
||||
|
||||
const overridenSec: Record<string, { env: string; secretPath: string }> = {};
|
||||
const envSlug2Name: Record<string, string> = {};
|
||||
environments.forEach((el) => {
|
||||
envSlug2Name[el.slug] = el.name;
|
||||
});
|
||||
|
||||
for (let i = importedSecIndex + 1; i < importSecrets.length; i += 1) {
|
||||
importSecrets[i].secrets.forEach((el) => {
|
||||
overridenSec[el.key] = {
|
||||
env: envSlug2Name?.[importSecrets[i].environment.slug] || "unknown",
|
||||
env: importSecrets[i].environmentInfo.name,
|
||||
secretPath: importSecrets[i].secretPath
|
||||
};
|
||||
});
|
||||
@@ -96,9 +90,7 @@ export const SecretImportListView = ({
|
||||
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
||||
"deleteSecretImport"
|
||||
] as const);
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { createNotification } = useNotificationContext();
|
||||
const environments = currentWorkspace?.environments || [];
|
||||
const sensors = useSensors(
|
||||
useSensor(MouseSensor, {}),
|
||||
useSensor(TouchSensor, {}),
|
||||
@@ -179,8 +171,7 @@ export const SecretImportListView = ({
|
||||
importEnv.slug,
|
||||
importPath,
|
||||
importedSecrets,
|
||||
secrets,
|
||||
environments
|
||||
secrets
|
||||
)}
|
||||
secretPath={secretPath}
|
||||
environment={environment}
|
||||
|
||||
Reference in New Issue
Block a user