From 2918d46b62c674dfd9cfd631f3995c70ae25ebc2 Mon Sep 17 00:00:00 2001
From: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Date: Fri, 9 May 2025 10:12:43 -0400
Subject: [PATCH] Resolve Vault warnings (#5786)
- Also remove extra exclusions
---
src/Core/Core.csproj | 2 +-
.../Vault/Queries/GetCipherPermissionsForUserQuery.cs | 4 ++--
src/Core/Vault/Repositories/ICipherRepository.cs | 1 +
src/Infrastructure.Dapper/Infrastructure.Dapper.csproj | 5 -----
.../Infrastructure.EntityFramework.csproj | 2 +-
test/Api.Test/Api.Test.csproj | 2 --
test/Core.Test/Core.Test.csproj | 2 --
.../Vault/Queries/GetTasksForOrganizationQueryTests.cs | 8 ++++----
8 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index ba48b6175b..4411a3de9b 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -4,7 +4,7 @@
false
bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
- $(WarningsNotAsErrors);CS1574;CS9113;CS1998
+ $(WarningsNotAsErrors);CS1574;CS9113
diff --git a/src/Core/Vault/Queries/GetCipherPermissionsForUserQuery.cs b/src/Core/Vault/Queries/GetCipherPermissionsForUserQuery.cs
index 5cce87e958..07e9d07299 100644
--- a/src/Core/Vault/Queries/GetCipherPermissionsForUserQuery.cs
+++ b/src/Core/Vault/Queries/GetCipherPermissionsForUserQuery.cs
@@ -45,7 +45,7 @@ public class GetCipherPermissionsForUserQuery : IGetCipherPermissionsForUserQuer
cipher.Value.ViewPassword = true;
}
}
- else if (await CanAccessUnassignedCiphersAsync(org))
+ else if (CanAccessUnassignedCiphers(org))
{
var unassignedCiphers = await _cipherRepository.GetManyUnassignedOrganizationDetailsByOrganizationIdAsync(organizationId);
foreach (var unassignedCipher in unassignedCiphers)
@@ -83,7 +83,7 @@ public class GetCipherPermissionsForUserQuery : IGetCipherPermissionsForUserQuer
return false;
}
- private async Task CanAccessUnassignedCiphersAsync(CurrentContextOrganization org)
+ private bool CanAccessUnassignedCiphers(CurrentContextOrganization org)
{
if (org is
{ Type: OrganizationUserType.Owner or OrganizationUserType.Admin } or
diff --git a/src/Core/Vault/Repositories/ICipherRepository.cs b/src/Core/Vault/Repositories/ICipherRepository.cs
index b094b42044..f6767fada2 100644
--- a/src/Core/Vault/Repositories/ICipherRepository.cs
+++ b/src/Core/Vault/Repositories/ICipherRepository.cs
@@ -3,6 +3,7 @@ using Bit.Core.KeyManagement.UserKey;
using Bit.Core.Repositories;
using Bit.Core.Vault.Entities;
using Bit.Core.Vault.Models.Data;
+using Bit.Core.Vault.Queries;
namespace Bit.Core.Vault.Repositories;
diff --git a/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj b/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
index b26dc938cf..8feb455feb 100644
--- a/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
+++ b/src/Infrastructure.Dapper/Infrastructure.Dapper.csproj
@@ -1,10 +1,5 @@
-
-
- $(WarningsNotAsErrors);CS8618
-
-
diff --git a/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj b/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj
index a11a209b39..639d88524b 100644
--- a/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj
+++ b/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj
@@ -2,7 +2,7 @@
- $(WarningsNotAsErrors);CS0108;CS8632
+ $(WarningsNotAsErrors);CS0108
diff --git a/test/Api.Test/Api.Test.csproj b/test/Api.Test/Api.Test.csproj
index ec22583caf..d6b31ce930 100644
--- a/test/Api.Test/Api.Test.csproj
+++ b/test/Api.Test/Api.Test.csproj
@@ -2,8 +2,6 @@
false
-
- $(WarningsNotAsErrors);CS8620;CS0169
diff --git a/test/Core.Test/Core.Test.csproj b/test/Core.Test/Core.Test.csproj
index cc19c50c35..c0f91a7bd3 100644
--- a/test/Core.Test/Core.Test.csproj
+++ b/test/Core.Test/Core.Test.csproj
@@ -2,8 +2,6 @@
false
Bit.Core.Test
-
- $(WarningsNotAsErrors);CS4014
diff --git a/test/Core.Test/Vault/Queries/GetTasksForOrganizationQueryTests.cs b/test/Core.Test/Vault/Queries/GetTasksForOrganizationQueryTests.cs
index 59ec7350da..f72a1f5f82 100644
--- a/test/Core.Test/Vault/Queries/GetTasksForOrganizationQueryTests.cs
+++ b/test/Core.Test/Vault/Queries/GetTasksForOrganizationQueryTests.cs
@@ -40,12 +40,12 @@ public class GetTasksForOrganizationQueryTests
var result = await sutProvider.Sut.GetTasksAsync(org.Id, status);
Assert.Equal(2, result.Count);
- sutProvider.GetDependency().Received(1).AuthorizeAsync(
+ await sutProvider.GetDependency().Received(1).AuthorizeAsync(
Arg.Any(), org, Arg.Is>(
e => e.Contains(SecurityTaskOperations.ListAllForOrganization)
)
);
- sutProvider.GetDependency().Received(1).GetManyByOrganizationIdStatusAsync(org.Id, SecurityTaskStatus.Pending);
+ await sutProvider.GetDependency().Received(1).GetManyByOrganizationIdStatusAsync(org.Id, SecurityTaskStatus.Pending);
}
[Theory, BitAutoData]
@@ -82,11 +82,11 @@ public class GetTasksForOrganizationQueryTests
await Assert.ThrowsAsync(() => sutProvider.Sut.GetTasksAsync(org.Id));
- sutProvider.GetDependency().Received(1).AuthorizeAsync(
+ await sutProvider.GetDependency().Received(1).AuthorizeAsync(
Arg.Any(), org, Arg.Is>(
e => e.Contains(SecurityTaskOperations.ListAllForOrganization)
)
);
- sutProvider.GetDependency().Received(0).GetManyByOrganizationIdStatusAsync(org.Id, SecurityTaskStatus.Pending);
+ await sutProvider.GetDependency().Received(0).GetManyByOrganizationIdStatusAsync(org.Id, SecurityTaskStatus.Pending);
}
}