mirror of
https://github.com/bitwarden/server
synced 2025-12-17 00:33:23 +00:00
## Type of change <!-- (mark with an `X`) --> ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Previous PR: #3434 Adds ciphers and folders to the new key rotation. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **file.ext:** Description of what was changed and why ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - If making database changes - make sure you also update Entity Framework queries and/or migrations - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using System.Data;
|
|
using Bit.Core.Vault.Entities;
|
|
using Dapper;
|
|
|
|
namespace Bit.Infrastructure.Dapper.Vault.Helpers;
|
|
|
|
public static class CipherHelpers
|
|
{
|
|
public static DataTable ToDataTable(this IEnumerable<Cipher> ciphers)
|
|
{
|
|
var ciphersTable = new DataTable();
|
|
ciphersTable.SetTypeName("[dbo].[Cipher]");
|
|
|
|
var columnData = new List<(string name, Type type, Func<Cipher, object> getter)>
|
|
{
|
|
(nameof(Cipher.Id), typeof(Guid), c => c.Id),
|
|
(nameof(Cipher.UserId), typeof(Guid), c => c.UserId),
|
|
(nameof(Cipher.OrganizationId), typeof(Guid), c => c.OrganizationId),
|
|
(nameof(Cipher.Type), typeof(short), c => c.Type),
|
|
(nameof(Cipher.Data), typeof(string), c => c.Data),
|
|
(nameof(Cipher.Favorites), typeof(string), c => c.Favorites),
|
|
(nameof(Cipher.Folders), typeof(string), c => c.Folders),
|
|
(nameof(Cipher.Attachments), typeof(string), c => c.Attachments),
|
|
(nameof(Cipher.CreationDate), typeof(DateTime), c => c.CreationDate),
|
|
(nameof(Cipher.RevisionDate), typeof(DateTime), c => c.RevisionDate),
|
|
(nameof(Cipher.DeletedDate), typeof(DateTime), c => c.DeletedDate),
|
|
(nameof(Cipher.Reprompt), typeof(short), c => c.Reprompt),
|
|
(nameof(Cipher.Key), typeof(string), c => c.Key),
|
|
};
|
|
|
|
return ciphers.BuildTable(ciphersTable, columnData);
|
|
}
|
|
}
|