mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
fix: add folder exists check to dashboard router endpoint
This commit is contained in:
@@ -703,6 +703,9 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
|
||||
// prevent older projects from accessing endpoint
|
||||
if (!shouldUseSecretV2Bridge) throw new BadRequestError({ message: "Project version not supported" });
|
||||
|
||||
// verify folder exists and user has project permission
|
||||
await server.services.folder.getFolderByPath({ projectId, environment, secretPath }, req.permission);
|
||||
|
||||
const tags = req.query.tags?.split(",") ?? [];
|
||||
|
||||
let remainingLimit = limit;
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
TDeleteFolderDTO,
|
||||
TDeleteManyFoldersDTO,
|
||||
TGetFolderByIdDTO,
|
||||
TGetFolderByPathDTO,
|
||||
TGetFolderDTO,
|
||||
TGetFoldersDeepByEnvsDTO,
|
||||
TUpdateFolderDTO,
|
||||
@@ -1398,6 +1399,31 @@ export const secretFolderServiceFactory = ({
|
||||
};
|
||||
};
|
||||
|
||||
const getFolderByPath = async (
|
||||
{ projectId, environment, secretPath }: TGetFolderByPathDTO,
|
||||
actor: OrgServiceActor
|
||||
) => {
|
||||
// folder check is allowed to be read by anyone
|
||||
// permission is to check if user has access
|
||||
await permissionService.getProjectPermission({
|
||||
actor: actor.type,
|
||||
actorId: actor.id,
|
||||
projectId,
|
||||
actorAuthMethod: actor.authMethod,
|
||||
actorOrgId: actor.orgId,
|
||||
actionProjectType: ActionProjectType.SecretManager
|
||||
});
|
||||
|
||||
const folder = await folderDAL.findBySecretPath(projectId, environment, secretPath);
|
||||
|
||||
if (!folder)
|
||||
throw new NotFoundError({
|
||||
message: `Could not find folder with path "${secretPath}" in environment "${environment}" for project with ID "${projectId}"`
|
||||
});
|
||||
|
||||
return folder;
|
||||
};
|
||||
|
||||
return {
|
||||
createFolder,
|
||||
updateFolder,
|
||||
@@ -1405,6 +1431,7 @@ export const secretFolderServiceFactory = ({
|
||||
deleteFolder,
|
||||
getFolders,
|
||||
getFolderById,
|
||||
getFolderByPath,
|
||||
getProjectFolderCount,
|
||||
getFoldersMultiEnv,
|
||||
getFoldersDeepByEnvs,
|
||||
|
||||
@@ -91,3 +91,9 @@ export type TDeleteManyFoldersDTO = {
|
||||
idOrName: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type TGetFolderByPathDTO = {
|
||||
projectId: string;
|
||||
environment: string;
|
||||
secretPath: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user