From a18ab213e43416b2b999b0e2af189e28d23c1d63 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 9 Mar 2023 08:15:22 -0500 Subject: [PATCH] SM-609: Block imports where any secret is associated with more than one project (#2789) --- .../Controllers/SecretsManagerPortingController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs b/src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs index d54ec3624..e077d67cb 100644 --- a/src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs +++ b/src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs @@ -61,6 +61,11 @@ public class SecretsManagerPortingController : Controller throw new BadRequestException("You cannot import this much data at once, the limit is 1000 projects and 6000 secrets."); } + if (importRequest.Secrets.Any(s => s.ProjectIds.Count() > 1)) + { + throw new BadRequestException("A secret can only be in one project at a time."); + } + await _importCommand.ImportAsync(organizationId, importRequest.ToSMImport()); } }