diff --git a/Composer/packages/server/src/services/project.ts b/Composer/packages/server/src/services/project.ts index 7aa5863ab1..9aebf5571e 100644 --- a/Composer/packages/server/src/services/project.ts +++ b/Composer/packages/server/src/services/project.ts @@ -147,6 +147,10 @@ export class BotProjectService { throw new Error(`file ${locationRef.path} does not exist`); } + if (!(await StorageService.checkIsBotFolder(locationRef.storageId, locationRef.path, user))) { + throw new Error(`${locationRef.path} is not a bot project folder`); + } + for (const key in BotProjectService.projectLocationMap) { if (BotProjectService.projectLocationMap[key] === locationRef.path) { // TODO: this should probably move to getProjectById diff --git a/Composer/packages/server/src/services/storage.ts b/Composer/packages/server/src/services/storage.ts index 633cdb88b1..d4931fcf43 100644 --- a/Composer/packages/server/src/services/storage.ts +++ b/Composer/packages/server/src/services/storage.ts @@ -138,6 +138,11 @@ class StorageService { } }; + public checkIsBotFolder = async (storageId: string, path: string, user?: UserIdentity) => { + const storageClient = this.getStorageClient(storageId, user); + return await this.isBotFolder(storageClient, path); + }; + private ensureDefaultBotFoldersExist = () => { this.storageConnections.forEach((s) => { this.createFolderRecurively(s.defaultPath);