mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
requested changes
This commit is contained in:
@@ -22,26 +22,6 @@ const INTERPOLATION_TEST_REGEX = new RE2(INTERPOLATION_PATTERN_STRING);
|
|||||||
|
|
||||||
export const shouldUseSecretV2Bridge = (version: number) => version === 3;
|
export const shouldUseSecretV2Bridge = (version: number) => version === 3;
|
||||||
|
|
||||||
export const validateSecretPath = async (
|
|
||||||
data: {
|
|
||||||
projectId: string;
|
|
||||||
environment: string;
|
|
||||||
secretPath: string;
|
|
||||||
},
|
|
||||||
folderDAL: Pick<TSecretFolderDALFactory, "findBySecretPath">
|
|
||||||
) => {
|
|
||||||
const { projectId, environment, secretPath } = data;
|
|
||||||
|
|
||||||
const folder = await folderDAL.findBySecretPath(projectId, environment, secretPath);
|
|
||||||
|
|
||||||
if (!folder) {
|
|
||||||
throw new NotFoundError({
|
|
||||||
message: `Folder with path '${secretPath}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
|
|
||||||
name: "SecretPathNotFound"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs and processes nested secret references from a string
|
* Grabs and processes nested secret references from a string
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ import {
|
|||||||
generatePaths,
|
generatePaths,
|
||||||
getAllSecretReferences,
|
getAllSecretReferences,
|
||||||
recursivelyGetSecretPaths,
|
recursivelyGetSecretPaths,
|
||||||
reshapeBridgeSecret,
|
reshapeBridgeSecret
|
||||||
validateSecretPath
|
|
||||||
} from "./secret-v2-bridge-fns";
|
} from "./secret-v2-bridge-fns";
|
||||||
import {
|
import {
|
||||||
SecretOperations,
|
SecretOperations,
|
||||||
@@ -1041,15 +1040,6 @@ export const secretV2BridgeServiceFactory = ({
|
|||||||
projectId
|
projectId
|
||||||
});
|
});
|
||||||
|
|
||||||
await validateSecretPath(
|
|
||||||
{
|
|
||||||
projectId,
|
|
||||||
environment,
|
|
||||||
secretPath: path
|
|
||||||
},
|
|
||||||
folderDAL
|
|
||||||
);
|
|
||||||
|
|
||||||
const encryptedCachedSecrets = await keyStore.getItem(cacheKey);
|
const encryptedCachedSecrets = await keyStore.getItem(cacheKey);
|
||||||
if (encryptedCachedSecrets) {
|
if (encryptedCachedSecrets) {
|
||||||
try {
|
try {
|
||||||
@@ -1084,12 +1074,22 @@ export const secretV2BridgeServiceFactory = ({
|
|||||||
currentPath: path
|
currentPath: path
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!deepPaths) return { secrets: [], imports: [] };
|
if (!deepPaths?.length) {
|
||||||
|
throw new NotFoundError({
|
||||||
|
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
|
||||||
|
name: "SecretPathNotFound"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
|
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
|
||||||
} else {
|
} else {
|
||||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||||
if (!folder) return { secrets: [], imports: [] };
|
if (!folder) {
|
||||||
|
throw new NotFoundError({
|
||||||
|
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
|
||||||
|
name: "SecretPathNotFound"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
paths = [{ folderId: folder.id, path }];
|
paths = [{ folderId: folder.id, path }];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ import {
|
|||||||
} from "./secret-types";
|
} from "./secret-types";
|
||||||
import { TSecretVersionDALFactory } from "./secret-version-dal";
|
import { TSecretVersionDALFactory } from "./secret-version-dal";
|
||||||
import { TSecretVersionTagDALFactory } from "./secret-version-tag-dal";
|
import { TSecretVersionTagDALFactory } from "./secret-version-tag-dal";
|
||||||
import { validateSecretPath } from "../secret-v2-bridge/secret-v2-bridge-fns";
|
|
||||||
|
|
||||||
type TSecretServiceFactoryDep = {
|
type TSecretServiceFactoryDep = {
|
||||||
secretDAL: TSecretDALFactory;
|
secretDAL: TSecretDALFactory;
|
||||||
@@ -617,15 +616,6 @@ export const secretServiceFactory = ({
|
|||||||
actionProjectType: ActionProjectType.SecretManager
|
actionProjectType: ActionProjectType.SecretManager
|
||||||
});
|
});
|
||||||
|
|
||||||
await validateSecretPath(
|
|
||||||
{
|
|
||||||
projectId,
|
|
||||||
environment,
|
|
||||||
secretPath: path
|
|
||||||
},
|
|
||||||
folderDAL
|
|
||||||
);
|
|
||||||
|
|
||||||
let paths: { folderId: string; path: string }[] = [];
|
let paths: { folderId: string; path: string }[] = [];
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
@@ -647,7 +637,12 @@ export const secretServiceFactory = ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!deepPaths) return { secrets: [], imports: [] };
|
if (!deepPaths?.length) {
|
||||||
|
throw new NotFoundError({
|
||||||
|
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
|
||||||
|
name: "SecretPathNotFound"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
|
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
|
||||||
} else {
|
} else {
|
||||||
@@ -657,7 +652,12 @@ export const secretServiceFactory = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
const folder = await folderDAL.findBySecretPath(projectId, environment, path);
|
||||||
if (!folder) return { secrets: [], imports: [] };
|
if (!folder) {
|
||||||
|
throw new NotFoundError({
|
||||||
|
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
|
||||||
|
name: "SecretPathNotFound"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
paths = [{ folderId: folder.id, path }];
|
paths = [{ folderId: folder.id, path }];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user