mirror of
https://github.com/bitwarden/server
synced 2025-12-10 13:23:27 +00:00
PM-26966 added new metric columns to organization report table (#6486)
* PM-26966 added new metric columns to organization report table * PM-26966 fixing migration * PM-26966 fixing formatting issue. * PM-26966 updating unit tests * PM-26966 fixing SQL to read from view
This commit is contained in:
@@ -11,12 +11,24 @@ public class OrganizationReport : ITableObject<Guid>
|
||||
public Guid OrganizationId { get; set; }
|
||||
public string ReportData { get; set; } = string.Empty;
|
||||
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public string ContentEncryptionKey { get; set; } = string.Empty;
|
||||
|
||||
public string? SummaryData { get; set; } = null;
|
||||
public string? ApplicationData { get; set; } = null;
|
||||
public string? SummaryData { get; set; }
|
||||
public string? ApplicationData { get; set; }
|
||||
public DateTime RevisionDate { get; set; } = DateTime.UtcNow;
|
||||
public int? ApplicationCount { get; set; }
|
||||
public int? ApplicationAtRiskCount { get; set; }
|
||||
public int? CriticalApplicationCount { get; set; }
|
||||
public int? CriticalApplicationAtRiskCount { get; set; }
|
||||
public int? MemberCount { get; set; }
|
||||
public int? MemberAtRiskCount { get; set; }
|
||||
public int? CriticalMemberCount { get; set; }
|
||||
public int? CriticalMemberAtRiskCount { get; set; }
|
||||
public int? PasswordCount { get; set; }
|
||||
public int? PasswordAtRiskCount { get; set; }
|
||||
public int? CriticalPasswordCount { get; set; }
|
||||
public int? CriticalPasswordAtRiskCount { get; set; }
|
||||
|
||||
|
||||
|
||||
public void SetNewId()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,19 @@ CREATE PROCEDURE [dbo].[OrganizationReport_Create]
|
||||
@ContentEncryptionKey VARCHAR(MAX),
|
||||
@SummaryData NVARCHAR(MAX),
|
||||
@ApplicationData NVARCHAR(MAX),
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ApplicationCount INT = NULL,
|
||||
@ApplicationAtRiskCount INT = NULL,
|
||||
@CriticalApplicationCount INT = NULL,
|
||||
@CriticalApplicationAtRiskCount INT = NULL,
|
||||
@MemberCount INT = NULL,
|
||||
@MemberAtRiskCount INT = NULL,
|
||||
@CriticalMemberCount INT = NULL,
|
||||
@CriticalMemberAtRiskCount INT = NULL,
|
||||
@PasswordCount INT = NULL,
|
||||
@PasswordAtRiskCount INT = NULL,
|
||||
@CriticalPasswordCount INT = NULL,
|
||||
@CriticalPasswordAtRiskCount INT = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
@@ -20,7 +32,19 @@ INSERT INTO [dbo].[OrganizationReport](
|
||||
[ContentEncryptionKey],
|
||||
[SummaryData],
|
||||
[ApplicationData],
|
||||
[RevisionDate]
|
||||
[RevisionDate],
|
||||
[ApplicationCount],
|
||||
[ApplicationAtRiskCount],
|
||||
[CriticalApplicationCount],
|
||||
[CriticalApplicationAtRiskCount],
|
||||
[MemberCount],
|
||||
[MemberAtRiskCount],
|
||||
[CriticalMemberCount],
|
||||
[CriticalMemberAtRiskCount],
|
||||
[PasswordCount],
|
||||
[PasswordAtRiskCount],
|
||||
[CriticalPasswordCount],
|
||||
[CriticalPasswordAtRiskCount]
|
||||
)
|
||||
VALUES (
|
||||
@Id,
|
||||
@@ -30,6 +54,18 @@ VALUES (
|
||||
@ContentEncryptionKey,
|
||||
@SummaryData,
|
||||
@ApplicationData,
|
||||
@RevisionDate
|
||||
@RevisionDate,
|
||||
@ApplicationCount,
|
||||
@ApplicationAtRiskCount,
|
||||
@CriticalApplicationCount,
|
||||
@CriticalApplicationAtRiskCount,
|
||||
@MemberCount,
|
||||
@MemberAtRiskCount,
|
||||
@CriticalMemberCount,
|
||||
@CriticalMemberAtRiskCount,
|
||||
@PasswordCount,
|
||||
@PasswordAtRiskCount,
|
||||
@CriticalPasswordCount,
|
||||
@CriticalPasswordAtRiskCount
|
||||
);
|
||||
END
|
||||
|
||||
@@ -5,14 +5,7 @@ BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT TOP 1
|
||||
[Id],
|
||||
[OrganizationId],
|
||||
[ReportData],
|
||||
[CreationDate],
|
||||
[ContentEncryptionKey],
|
||||
[SummaryData],
|
||||
[ApplicationData],
|
||||
[RevisionDate]
|
||||
*
|
||||
FROM [dbo].[OrganizationReportView]
|
||||
WHERE [OrganizationId] = @OrganizationId
|
||||
ORDER BY [RevisionDate] DESC
|
||||
|
||||
@@ -6,7 +6,19 @@ CREATE PROCEDURE [dbo].[OrganizationReport_Update]
|
||||
@ContentEncryptionKey VARCHAR(MAX),
|
||||
@SummaryData NVARCHAR(MAX),
|
||||
@ApplicationData NVARCHAR(MAX),
|
||||
@RevisionDate DATETIME2(7)
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ApplicationCount INT = NULL,
|
||||
@ApplicationAtRiskCount INT = NULL,
|
||||
@CriticalApplicationCount INT = NULL,
|
||||
@CriticalApplicationAtRiskCount INT = NULL,
|
||||
@MemberCount INT = NULL,
|
||||
@MemberAtRiskCount INT = NULL,
|
||||
@CriticalMemberCount INT = NULL,
|
||||
@CriticalMemberAtRiskCount INT = NULL,
|
||||
@PasswordCount INT = NULL,
|
||||
@PasswordAtRiskCount INT = NULL,
|
||||
@CriticalPasswordCount INT = NULL,
|
||||
@CriticalPasswordAtRiskCount INT = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
@@ -18,6 +30,18 @@ BEGIN
|
||||
[ContentEncryptionKey] = @ContentEncryptionKey,
|
||||
[SummaryData] = @SummaryData,
|
||||
[ApplicationData] = @ApplicationData,
|
||||
[RevisionDate] = @RevisionDate
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[ApplicationCount] = @ApplicationCount,
|
||||
[ApplicationAtRiskCount] = @ApplicationAtRiskCount,
|
||||
[CriticalApplicationCount] = @CriticalApplicationCount,
|
||||
[CriticalApplicationAtRiskCount] = @CriticalApplicationAtRiskCount,
|
||||
[MemberCount] = @MemberCount,
|
||||
[MemberAtRiskCount] = @MemberAtRiskCount,
|
||||
[CriticalMemberCount] = @CriticalMemberCount,
|
||||
[CriticalMemberAtRiskCount] = @CriticalMemberAtRiskCount,
|
||||
[PasswordCount] = @PasswordCount,
|
||||
[PasswordAtRiskCount] = @PasswordAtRiskCount,
|
||||
[CriticalPasswordCount] = @CriticalPasswordCount,
|
||||
[CriticalPasswordAtRiskCount] = @CriticalPasswordAtRiskCount
|
||||
WHERE [Id] = @Id;
|
||||
END;
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
CREATE TABLE [dbo].[OrganizationReport] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReportData] NVARCHAR(MAX) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[ContentEncryptionKey] VARCHAR(MAX) NOT NULL,
|
||||
[SummaryData] NVARCHAR(MAX) NULL,
|
||||
[ApplicationData] NVARCHAR(MAX) NULL,
|
||||
[RevisionDate] DATETIME2 (7) NULL,
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReportData] NVARCHAR(MAX) NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[ContentEncryptionKey] VARCHAR(MAX) NOT NULL,
|
||||
[SummaryData] NVARCHAR(MAX) NULL,
|
||||
[ApplicationData] NVARCHAR(MAX) NULL,
|
||||
[RevisionDate] DATETIME2 (7) NULL,
|
||||
[ApplicationCount] INT NULL,
|
||||
[ApplicationAtRiskCount] INT NULL,
|
||||
[CriticalApplicationCount] INT NULL,
|
||||
[CriticalApplicationAtRiskCount] INT NULL,
|
||||
[MemberCount] INT NULL,
|
||||
[MemberAtRiskCount] INT NULL,
|
||||
[CriticalMemberCount] INT NULL,
|
||||
[CriticalMemberAtRiskCount] INT NULL,
|
||||
[PasswordCount] INT NULL,
|
||||
[PasswordAtRiskCount] INT NULL,
|
||||
[CriticalPasswordCount] INT NULL,
|
||||
[CriticalPasswordAtRiskCount] INT NULL,
|
||||
CONSTRAINT [PK_OrganizationReport] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_OrganizationReport_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||
);
|
||||
|
||||
@@ -49,6 +49,75 @@ public class OrganizationReportRepositoryTests
|
||||
Assert.True(records.Count == 4);
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfOrganizationReportAutoData]
|
||||
public async Task CreateAsync_ShouldPersistAllMetricProperties_WhenSet(
|
||||
List<EntityFramework.Dirt.Repositories.OrganizationReportRepository> suts,
|
||||
List<EfRepo.OrganizationRepository> efOrganizationRepos,
|
||||
OrganizationReportRepository sqlOrganizationReportRepo,
|
||||
SqlRepo.OrganizationRepository sqlOrganizationRepo)
|
||||
{
|
||||
// Arrange - Create a report with explicit metric values
|
||||
var fixture = new Fixture();
|
||||
var organization = fixture.Create<Organization>();
|
||||
var report = fixture.Build<OrganizationReport>()
|
||||
.With(x => x.ApplicationCount, 10)
|
||||
.With(x => x.ApplicationAtRiskCount, 3)
|
||||
.With(x => x.CriticalApplicationCount, 5)
|
||||
.With(x => x.CriticalApplicationAtRiskCount, 2)
|
||||
.With(x => x.MemberCount, 25)
|
||||
.With(x => x.MemberAtRiskCount, 7)
|
||||
.With(x => x.CriticalMemberCount, 12)
|
||||
.With(x => x.CriticalMemberAtRiskCount, 4)
|
||||
.With(x => x.PasswordCount, 100)
|
||||
.With(x => x.PasswordAtRiskCount, 15)
|
||||
.With(x => x.CriticalPasswordCount, 50)
|
||||
.With(x => x.CriticalPasswordAtRiskCount, 8)
|
||||
.Create();
|
||||
|
||||
var retrievedReports = new List<OrganizationReport>();
|
||||
|
||||
// Act & Assert - Test EF repositories
|
||||
foreach (var sut in suts)
|
||||
{
|
||||
var i = suts.IndexOf(sut);
|
||||
var efOrganization = await efOrganizationRepos[i].CreateAsync(organization);
|
||||
sut.ClearChangeTracking();
|
||||
|
||||
report.OrganizationId = efOrganization.Id;
|
||||
var createdReport = await sut.CreateAsync(report);
|
||||
sut.ClearChangeTracking();
|
||||
|
||||
var savedReport = await sut.GetByIdAsync(createdReport.Id);
|
||||
retrievedReports.Add(savedReport);
|
||||
}
|
||||
|
||||
// Act & Assert - Test SQL repository
|
||||
var sqlOrganization = await sqlOrganizationRepo.CreateAsync(organization);
|
||||
report.OrganizationId = sqlOrganization.Id;
|
||||
var sqlCreatedReport = await sqlOrganizationReportRepo.CreateAsync(report);
|
||||
var savedSqlReport = await sqlOrganizationReportRepo.GetByIdAsync(sqlCreatedReport.Id);
|
||||
retrievedReports.Add(savedSqlReport);
|
||||
|
||||
// Assert - Verify all metric properties are persisted correctly across all repositories
|
||||
Assert.True(retrievedReports.Count == 4);
|
||||
foreach (var retrievedReport in retrievedReports)
|
||||
{
|
||||
Assert.NotNull(retrievedReport);
|
||||
Assert.Equal(10, retrievedReport.ApplicationCount);
|
||||
Assert.Equal(3, retrievedReport.ApplicationAtRiskCount);
|
||||
Assert.Equal(5, retrievedReport.CriticalApplicationCount);
|
||||
Assert.Equal(2, retrievedReport.CriticalApplicationAtRiskCount);
|
||||
Assert.Equal(25, retrievedReport.MemberCount);
|
||||
Assert.Equal(7, retrievedReport.MemberAtRiskCount);
|
||||
Assert.Equal(12, retrievedReport.CriticalMemberCount);
|
||||
Assert.Equal(4, retrievedReport.CriticalMemberAtRiskCount);
|
||||
Assert.Equal(100, retrievedReport.PasswordCount);
|
||||
Assert.Equal(15, retrievedReport.PasswordAtRiskCount);
|
||||
Assert.Equal(50, retrievedReport.CriticalPasswordCount);
|
||||
Assert.Equal(8, retrievedReport.CriticalPasswordAtRiskCount);
|
||||
}
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfOrganizationReportAutoData]
|
||||
public async Task RetrieveByOrganisation_Works(
|
||||
OrganizationReportRepository sqlOrganizationReportRepo,
|
||||
@@ -66,6 +135,67 @@ public class OrganizationReportRepositoryTests
|
||||
Assert.Equal(secondOrg.Id, secondRetrievedReport.OrganizationId);
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfOrganizationReportAutoData]
|
||||
public async Task UpdateAsync_ShouldUpdateAllMetricProperties_WhenChanged(
|
||||
OrganizationReportRepository sqlOrganizationReportRepo,
|
||||
SqlRepo.OrganizationRepository sqlOrganizationRepo)
|
||||
{
|
||||
// Arrange - Create initial report with specific metric values
|
||||
var fixture = new Fixture();
|
||||
var organization = fixture.Create<Organization>();
|
||||
var org = await sqlOrganizationRepo.CreateAsync(organization);
|
||||
|
||||
var report = fixture.Build<OrganizationReport>()
|
||||
.With(x => x.OrganizationId, org.Id)
|
||||
.With(x => x.ApplicationCount, 10)
|
||||
.With(x => x.ApplicationAtRiskCount, 3)
|
||||
.With(x => x.CriticalApplicationCount, 5)
|
||||
.With(x => x.CriticalApplicationAtRiskCount, 2)
|
||||
.With(x => x.MemberCount, 25)
|
||||
.With(x => x.MemberAtRiskCount, 7)
|
||||
.With(x => x.CriticalMemberCount, 12)
|
||||
.With(x => x.CriticalMemberAtRiskCount, 4)
|
||||
.With(x => x.PasswordCount, 100)
|
||||
.With(x => x.PasswordAtRiskCount, 15)
|
||||
.With(x => x.CriticalPasswordCount, 50)
|
||||
.With(x => x.CriticalPasswordAtRiskCount, 8)
|
||||
.Create();
|
||||
|
||||
var createdReport = await sqlOrganizationReportRepo.CreateAsync(report);
|
||||
|
||||
// Act - Update all metric properties with new values
|
||||
createdReport.ApplicationCount = 20;
|
||||
createdReport.ApplicationAtRiskCount = 6;
|
||||
createdReport.CriticalApplicationCount = 10;
|
||||
createdReport.CriticalApplicationAtRiskCount = 4;
|
||||
createdReport.MemberCount = 50;
|
||||
createdReport.MemberAtRiskCount = 14;
|
||||
createdReport.CriticalMemberCount = 24;
|
||||
createdReport.CriticalMemberAtRiskCount = 8;
|
||||
createdReport.PasswordCount = 200;
|
||||
createdReport.PasswordAtRiskCount = 30;
|
||||
createdReport.CriticalPasswordCount = 100;
|
||||
createdReport.CriticalPasswordAtRiskCount = 16;
|
||||
|
||||
await sqlOrganizationReportRepo.UpsertAsync(createdReport);
|
||||
|
||||
// Assert - Verify all metric properties were updated correctly
|
||||
var updatedReport = await sqlOrganizationReportRepo.GetByIdAsync(createdReport.Id);
|
||||
Assert.NotNull(updatedReport);
|
||||
Assert.Equal(20, updatedReport.ApplicationCount);
|
||||
Assert.Equal(6, updatedReport.ApplicationAtRiskCount);
|
||||
Assert.Equal(10, updatedReport.CriticalApplicationCount);
|
||||
Assert.Equal(4, updatedReport.CriticalApplicationAtRiskCount);
|
||||
Assert.Equal(50, updatedReport.MemberCount);
|
||||
Assert.Equal(14, updatedReport.MemberAtRiskCount);
|
||||
Assert.Equal(24, updatedReport.CriticalMemberCount);
|
||||
Assert.Equal(8, updatedReport.CriticalMemberAtRiskCount);
|
||||
Assert.Equal(200, updatedReport.PasswordCount);
|
||||
Assert.Equal(30, updatedReport.PasswordAtRiskCount);
|
||||
Assert.Equal(100, updatedReport.CriticalPasswordCount);
|
||||
Assert.Equal(16, updatedReport.CriticalPasswordAtRiskCount);
|
||||
}
|
||||
|
||||
[CiSkippedTheory, EfOrganizationReportAutoData]
|
||||
public async Task Delete_Works(
|
||||
List<EntityFramework.Dirt.Repositories.OrganizationReportRepository> suts,
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
IF COL_LENGTH('dbo.OrganizationReport', 'ApplicationCount') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE [dbo].[OrganizationReport]
|
||||
ADD [ApplicationCount] INT NULL,
|
||||
[ApplicationAtRiskCount] INT NULL,
|
||||
[CriticalApplicationCount] INT NULL,
|
||||
[CriticalApplicationAtRiskCount] INT NULL,
|
||||
[MemberCount] INT NULL,
|
||||
[MemberAtRiskCount] INT NULL,
|
||||
[CriticalMemberCount] INT NULL,
|
||||
[CriticalMemberAtRiskCount] INT NULL,
|
||||
[PasswordCount] INT NULL,
|
||||
[PasswordAtRiskCount] INT NULL,
|
||||
[CriticalPasswordCount] INT NULL,
|
||||
[CriticalPasswordAtRiskCount] INT NULL
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationReport_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ReportData NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX),
|
||||
@SummaryData NVARCHAR(MAX),
|
||||
@ApplicationData NVARCHAR(MAX),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ApplicationCount INT = NULL,
|
||||
@ApplicationAtRiskCount INT = NULL,
|
||||
@CriticalApplicationCount INT = NULL,
|
||||
@CriticalApplicationAtRiskCount INT = NULL,
|
||||
@MemberCount INT = NULL,
|
||||
@MemberAtRiskCount INT = NULL,
|
||||
@CriticalMemberCount INT = NULL,
|
||||
@CriticalMemberAtRiskCount INT = NULL,
|
||||
@PasswordCount INT = NULL,
|
||||
@PasswordAtRiskCount INT = NULL,
|
||||
@CriticalPasswordCount INT = NULL,
|
||||
@CriticalPasswordAtRiskCount INT = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
INSERT INTO [dbo].[OrganizationReport](
|
||||
[Id],
|
||||
[OrganizationId],
|
||||
[ReportData],
|
||||
[CreationDate],
|
||||
[ContentEncryptionKey],
|
||||
[SummaryData],
|
||||
[ApplicationData],
|
||||
[RevisionDate],
|
||||
[ApplicationCount],
|
||||
[ApplicationAtRiskCount],
|
||||
[CriticalApplicationCount],
|
||||
[CriticalApplicationAtRiskCount],
|
||||
[MemberCount],
|
||||
[MemberAtRiskCount],
|
||||
[CriticalMemberCount],
|
||||
[CriticalMemberAtRiskCount],
|
||||
[PasswordCount],
|
||||
[PasswordAtRiskCount],
|
||||
[CriticalPasswordCount],
|
||||
[CriticalPasswordAtRiskCount]
|
||||
)
|
||||
VALUES (
|
||||
@Id,
|
||||
@OrganizationId,
|
||||
@ReportData,
|
||||
@CreationDate,
|
||||
@ContentEncryptionKey,
|
||||
@SummaryData,
|
||||
@ApplicationData,
|
||||
@RevisionDate,
|
||||
@ApplicationCount,
|
||||
@ApplicationAtRiskCount,
|
||||
@CriticalApplicationCount,
|
||||
@CriticalApplicationAtRiskCount,
|
||||
@MemberCount,
|
||||
@MemberAtRiskCount,
|
||||
@CriticalMemberCount,
|
||||
@CriticalMemberAtRiskCount,
|
||||
@PasswordCount,
|
||||
@PasswordAtRiskCount,
|
||||
@CriticalPasswordCount,
|
||||
@CriticalPasswordAtRiskCount
|
||||
);
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationReport_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ReportData NVARCHAR(MAX),
|
||||
@CreationDate DATETIME2(7),
|
||||
@ContentEncryptionKey VARCHAR(MAX),
|
||||
@SummaryData NVARCHAR(MAX),
|
||||
@ApplicationData NVARCHAR(MAX),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@ApplicationCount INT = NULL,
|
||||
@ApplicationAtRiskCount INT = NULL,
|
||||
@CriticalApplicationCount INT = NULL,
|
||||
@CriticalApplicationAtRiskCount INT = NULL,
|
||||
@MemberCount INT = NULL,
|
||||
@MemberAtRiskCount INT = NULL,
|
||||
@CriticalMemberCount INT = NULL,
|
||||
@CriticalMemberAtRiskCount INT = NULL,
|
||||
@PasswordCount INT = NULL,
|
||||
@PasswordAtRiskCount INT = NULL,
|
||||
@CriticalPasswordCount INT = NULL,
|
||||
@CriticalPasswordAtRiskCount INT = NULL
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
UPDATE [dbo].[OrganizationReport]
|
||||
SET
|
||||
[OrganizationId] = @OrganizationId,
|
||||
[ReportData] = @ReportData,
|
||||
[CreationDate] = @CreationDate,
|
||||
[ContentEncryptionKey] = @ContentEncryptionKey,
|
||||
[SummaryData] = @SummaryData,
|
||||
[ApplicationData] = @ApplicationData,
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[ApplicationCount] = @ApplicationCount,
|
||||
[ApplicationAtRiskCount] = @ApplicationAtRiskCount,
|
||||
[CriticalApplicationCount] = @CriticalApplicationCount,
|
||||
[CriticalApplicationAtRiskCount] = @CriticalApplicationAtRiskCount,
|
||||
[MemberCount] = @MemberCount,
|
||||
[MemberAtRiskCount] = @MemberAtRiskCount,
|
||||
[CriticalMemberCount] = @CriticalMemberCount,
|
||||
[CriticalMemberAtRiskCount] = @CriticalMemberAtRiskCount,
|
||||
[PasswordCount] = @PasswordCount,
|
||||
[PasswordAtRiskCount] = @PasswordAtRiskCount,
|
||||
[CriticalPasswordCount] = @CriticalPasswordCount,
|
||||
[CriticalPasswordAtRiskCount] = @CriticalPasswordAtRiskCount
|
||||
WHERE [Id] = @Id;
|
||||
END;
|
||||
GO
|
||||
|
||||
CREATE OR ALTER VIEW [dbo].[OrganizationReportView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[OrganizationReport]
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationReport_GetLatestByOrganizationId]
|
||||
@OrganizationId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT TOP 1
|
||||
*
|
||||
FROM [dbo].[OrganizationReportView]
|
||||
WHERE [OrganizationId] = @OrganizationId
|
||||
ORDER BY [RevisionDate] DESC
|
||||
END
|
||||
GO
|
||||
|
||||
3440
util/MySqlMigrations/Migrations/20251028135609_2025-10-28_00_AddOrganizationReportMetricColumns.Designer.cs
generated
Normal file
3440
util/MySqlMigrations/Migrations/20251028135609_2025-10-28_00_AddOrganizationReportMetricColumns.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,137 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20251028_00_AddOrganizationReportMetricColumns : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport");
|
||||
}
|
||||
}
|
||||
@@ -1014,6 +1014,12 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int?>("ApplicationAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("ApplicationCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ApplicationData")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@@ -1024,9 +1030,39 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<int?>("CriticalApplicationAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CriticalApplicationCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CriticalMemberAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CriticalMemberCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CriticalPasswordAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CriticalPasswordCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MemberAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("MemberCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<Guid>("OrganizationId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int?>("PasswordAtRiskCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PasswordCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ReportData")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,137 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20251028_00_AddOrganizationReportMetricColumns : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport");
|
||||
}
|
||||
}
|
||||
@@ -1019,6 +1019,12 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int?>("ApplicationAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("ApplicationCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ApplicationData")
|
||||
.HasColumnType("text");
|
||||
|
||||
@@ -1029,9 +1035,39 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("CriticalApplicationAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("CriticalApplicationCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("CriticalMemberAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("CriticalMemberCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("CriticalPasswordAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("CriticalPasswordCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MemberAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("MemberCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("OrganizationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int?>("PasswordAtRiskCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("PasswordCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ReportData")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
3429
util/SqliteMigrations/Migrations/20251028135617_2025-10-28_00_AddOrganizationReportMetricColumns.Designer.cs
generated
Normal file
3429
util/SqliteMigrations/Migrations/20251028135617_2025-10-28_00_AddOrganizationReportMetricColumns.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,137 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.SqliteMigrations.Migrations;
|
||||
|
||||
/// <inheritdoc />
|
||||
public partial class _20251028_00_AddOrganizationReportMetricColumns : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalApplicationCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalMemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CriticalPasswordCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "MemberCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordAtRiskCount",
|
||||
table: "OrganizationReport");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PasswordCount",
|
||||
table: "OrganizationReport");
|
||||
}
|
||||
}
|
||||
@@ -1003,6 +1003,12 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ApplicationAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ApplicationCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ApplicationData")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -1013,9 +1019,39 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("CriticalApplicationAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("CriticalApplicationCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("CriticalMemberAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("CriticalMemberCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("CriticalPasswordAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("CriticalPasswordCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("MemberAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("MemberCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("OrganizationId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("PasswordAtRiskCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("PasswordCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ReportData")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
Reference in New Issue
Block a user