1
0
mirror of https://github.com/bitwarden/server synced 2025-12-26 13:13:24 +00:00

explicitly select cipher columns in CipherDetails queries

This commit is contained in:
jaasen-livefront
2025-11-17 10:34:08 -08:00
parent 5b300de5f4
commit 9ed0c162fd
5 changed files with 235 additions and 19 deletions

View File

@@ -786,7 +786,7 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
{
CipherStateAction.Unarchive => ucd.ArchivedDate != null,
CipherStateAction.Archive => ucd.ArchivedDate == null,
_ => true,
_ => true
};
}

View File

@@ -5,11 +5,23 @@ BEGIN
SET NOCOUNT ON
SELECT
*
c.Id,
c.UserId,
c.OrganizationId,
c.Type,
c.Data,
c.Favorites,
c.Folders,
c.Attachments,
c.CreationDate,
c.RevisionDate,
c.DeletedDate,
c.Reprompt,
c.Key,
ca.ArchivedDate
FROM
[dbo].[UserCipherDetails](@UserId)
LEFT JOIN [dbo].[CipherArchive] ca
ON ca.CipherId = c.Id
AND ca.UserId = @UserId
WHERE
[dbo].[UserCipherDetails](@UserId) AS c
LEFT JOIN [dbo].[CipherArchive] AS ca
ON ca.CipherId = c.Id
AND ca.UserId = @UserId
END

View File

@@ -5,16 +5,29 @@ BEGIN
SET NOCOUNT ON
SELECT
*,
c.Id,
c.UserId,
c.OrganizationId,
c.Type,
c.Data,
c.Favorites,
c.Folders,
c.Attachments,
c.CreationDate,
c.RevisionDate,
c.DeletedDate,
c.Reprompt,
c.Key,
1 [Edit],
1 [ViewPassword],
1 [Manage],
0 [OrganizationUseTotp]
0 [OrganizationUseTotp],
ca.ArchivedDate
FROM
[dbo].[CipherDetails](@UserId)
LEFT JOIN [dbo].[CipherArchive] ca
ON ca.CipherId = c.Id
AND ca.UserId = @UserId
[dbo].[CipherDetails](@UserId) AS c
LEFT JOIN [dbo].[CipherArchive] AS ca
ON ca.CipherId = c.Id
AND ca.UserId = @UserId
WHERE
[UserId] = @UserId
c.[UserId] = @UserId
END

View File

@@ -22,11 +22,6 @@ ADD CONSTRAINT [FK_CipherArchive_User]
ON DELETE CASCADE;
GO
ALTER TABLE [dbo].[CipherArchive]
ADD CONSTRAINT [UX_CipherArchive_CipherId_UserId]
UNIQUE (CipherId, UserId);
GO
CREATE NONCLUSTERED INDEX [IX_CipherArchive_UserId]
ON [dbo].[CipherArchive]([UserId]);
GO