-
Notifications
You must be signed in to change notification settings - Fork 1.5k
PM-20574 & PM-20575 Adding Risk Insight Report tables, repositories, and migrations #5839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
prograhamming
merged 45 commits into
main
from
dirt/pm-20574/database_tables_and_scripts_riskinsights
Jun 23, 2025
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
e6da387
PM-20574 fixing namespaces on reporting work that got moved over fromโฆ
prograhamming 1b6adf4
PM-20574 adding tables, stored procedures, and migration files
prograhamming 9d5835f
PM-20574 adding dapper and ef repos and migrations
prograhamming 7d9d14c
Merge branch 'main' into dirt/pm-20574/database_tables_and_scripts_riโฆ
prograhamming 3f9ffbb
PM-20574 merging in main
prograhamming b62603f
PM-20574 changing table and repo names as requested
prograhamming dfca2f7
PM-20574 updating sql scripts to new names
prograhamming 8f996a0
PM-20574 updating sql scripts
prograhamming 9dd4334
PM-20574 updating migration script for org delete by id
prograhamming b354fea
PM-20574 adding mysql migration
prograhamming 4b952b1
Merge branch 'main' into dirt/pm-20574/database_tables_and_scripts_riโฆ
prograhamming 5c37f56
PM-20574 updating sql migration to fix database test
prograhamming c8e9f02
PM-20574 fixing migration script
prograhamming 79dbb86
PM-20574 fixing migration script
prograhamming dfd6e50
PM-20574 fixing table scripts
prograhamming 5546a38
Merge branch 'main' into dirt/pm-20574/database_tables_and_scripts_riโฆ
prograhamming 27bce10
PM-20574 fixing table scripts
prograhamming c427c36
PM-20574 fixing migration script formatting
prograhamming 47eb1ee
PM-20574 fixing syntax in migration script
prograhamming f0e709d
PM-20574 fixing file names and extensions
prograhamming 093731b
PM-20574 fixing sql file
prograhamming 85c4837
PM-20574 fixing sql
prograhamming d4e284f
PM-20574 fixing directory for entities and removing scripts from otheโฆ
prograhamming 7d2b12b
PM-20574 generating new migration scripts
prograhamming 26908b2
Merge branch 'main' into dirt/pm-20574/database_tables_and_scripts_riโฆ
prograhamming ceebfd7
PM-20574 fixed reference to a stored proc
voommen-livefront 7151ae4
PM-20574 adding index in scripts and missing table
voommen-livefront 618f533
Merge branch 'main' into dirt/pm-20574/database_tables_and_scripts_riโฆ
voommen-livefront 661528c
PM-20574 fixing merge conflicts
voommen-livefront 0d50e11
PM-20574 set OUTPUT param for Id property in create and update proc
voommen-livefront d4b2024
PM-20574 add CreateDate to the update proc
voommen-livefront 6356e94
PM-20574 amend update proc for OrganizationApplication by adding creaโฆ
voommen-livefront 7682178
PM-20574 formatted sql and updated as per PR comments
voommen-livefront f63bde0
PM-20574 updated script to fix build error
voommen-livefront 360ee89
PM-20574 fixed inconsistency in db script
voommen-livefront 22a89cc
PM-20574 removed revisionDate, update procedures and used views
voommen-livefront 57c01c3
PM-20574 removed RevisionDate from designer files
voommen-livefront bfeb572
PM-20574 removed revisionDate column that was missed previously
voommen-livefront d6f4b85
PM-20574 added revision date back into the mix
voommen-livefront a9553ae
PM-20574 updated database script to fix build error
voommen-livefront 8d61aeb
PM-20574 fixed a procedure issue
voommen-livefront 4e0caf8
PM-20574 fix dB build error
voommen-livefront d9a7d2a
PM-020574 fixed additional PR comments - files cleaned up
voommen-livefront e132e1d
PM-20574 updated procedure was inconsistent
voommen-livefront bd4cd1a
Update 2025-06-13-00_OrganizationReport.sql
voommen-livefront File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/Api/Dirt/Models/Response/MemberCipherDetailsResponseModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ๏ปฟ#nullable enable | ||
|
|
||
| using Bit.Core.Entities; | ||
| using Bit.Core.Utilities; | ||
|
|
||
| namespace Bit.Core.Dirt.Entities; | ||
|
|
||
| public class OrganizationApplication : ITableObject<Guid>, IRevisable | ||
| { | ||
| public Guid Id { get; set; } | ||
| public Guid OrganizationId { get; set; } | ||
| public string Applications { get; set; } = string.Empty; | ||
| public DateTime CreationDate { get; set; } = DateTime.UtcNow; | ||
| public DateTime RevisionDate { get; set; } = DateTime.UtcNow; | ||
|
|
||
| public void SetNewId() | ||
| { | ||
| Id = CoreHelpers.GenerateComb(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ๏ปฟ#nullable enable | ||
|
|
||
| using Bit.Core.Entities; | ||
| using Bit.Core.Utilities; | ||
|
|
||
| namespace Bit.Core.Dirt.Entities; | ||
|
|
||
| public class OrganizationReport : ITableObject<Guid> | ||
| { | ||
| public Guid Id { get; set; } | ||
| public Guid OrganizationId { get; set; } | ||
| public DateTime Date { get; set; } | ||
| public string ReportData { get; set; } = string.Empty; | ||
| public DateTime CreationDate { get; set; } = DateTime.UtcNow; | ||
|
|
||
| public void SetNewId() | ||
| { | ||
| Id = CoreHelpers.GenerateComb(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../Models/Data/MemberAccessCipherDetails.cs โ .../Models/Data/MemberAccessCipherDetails.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
src/Core/Dirt/Reports/ReportFeatures/AddPasswordHealthReportApplicationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Core/Dirt/Reports/ReportFeatures/DropPasswordHealthReportApplicationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Core/Dirt/Reports/ReportFeatures/GetPasswordHealthReportApplicationQuery.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Core/Dirt/Reports/ReportFeatures/Interfaces/IAddPasswordHealthReportApplicationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Core/Dirt/Reports/ReportFeatures/Interfaces/IGetPasswordHealthReportApplicationQuery.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/Core/Dirt/Repositories/IOrganizationApplicationRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ๏ปฟusing Bit.Core.Dirt.Entities; | ||
| using Bit.Core.Repositories; | ||
|
|
||
| namespace Bit.Core.Dirt.Repositories; | ||
|
|
||
| public interface IOrganizationApplicationRepository : IRepository<OrganizationApplication, Guid> | ||
| { | ||
| Task<ICollection<OrganizationApplication>> GetByOrganizationIdAsync(Guid organizationId); | ||
| } |
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
src/Core/Dirt/Repositories/IOrganizationReportRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ๏ปฟusing Bit.Core.Dirt.Entities; | ||
| using Bit.Core.Repositories; | ||
|
|
||
| namespace Bit.Core.Dirt.Repositories; | ||
|
|
||
| public interface IOrganizationReportRepository : IRepository<OrganizationReport, Guid> | ||
| { | ||
| Task<ICollection<OrganizationReport>> GetByOrganizationIdAsync(Guid organizationId); | ||
| } | ||
|
|
4 changes: 2 additions & 2 deletions
4
...swordHealthReportApplicationRepository.cs โ ...swordHealthReportApplicationRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Infrastructure.Dapper/Dirt/OrganizationApplicationRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ๏ปฟusing System.Data; | ||
| using Bit.Core.Dirt.Entities; | ||
| using Bit.Core.Dirt.Repositories; | ||
| using Bit.Core.Settings; | ||
| using Bit.Infrastructure.Dapper.Repositories; | ||
| using Dapper; | ||
| using Microsoft.Data.SqlClient; | ||
|
|
||
| namespace Bit.Infrastructure.Dapper.Dirt; | ||
|
|
||
| public class OrganizationApplicationRepository : Repository<OrganizationApplication, Guid>, IOrganizationApplicationRepository | ||
| { | ||
| public OrganizationApplicationRepository(GlobalSettings globalSettings) | ||
| : this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString) | ||
| { | ||
| } | ||
|
|
||
| public OrganizationApplicationRepository(string connectionString, string readOnlyConnectionString) | ||
| : base(connectionString, readOnlyConnectionString) | ||
| { | ||
| } | ||
|
|
||
| public async Task<ICollection<OrganizationApplication>> GetByOrganizationIdAsync(Guid organizationId) | ||
| { | ||
| using (var connection = new SqlConnection(ReadOnlyConnectionString)) | ||
| { | ||
| var results = await connection.QueryAsync<OrganizationApplication>( | ||
| $"[{Schema}].[OrganizationApplication_ReadByOrganizationId]", | ||
| new { OrganizationId = organizationId }, | ||
| commandType: CommandType.StoredProcedure); | ||
|
|
||
| return results.ToList(); | ||
| } | ||
| } | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
src/Infrastructure.Dapper/Dirt/OrganizationReportRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ๏ปฟusing System.Data; | ||
| using Bit.Core.Dirt.Entities; | ||
| using Bit.Core.Dirt.Repositories; | ||
| using Bit.Core.Settings; | ||
| using Bit.Infrastructure.Dapper.Repositories; | ||
| using Dapper; | ||
| using Microsoft.Data.SqlClient; | ||
|
|
||
| namespace Bit.Infrastructure.Dapper.Dirt; | ||
|
|
||
| public class OrganizationReportRepository : Repository<OrganizationReport, Guid>, IOrganizationReportRepository | ||
| { | ||
| public OrganizationReportRepository(GlobalSettings globalSettings) | ||
| : this(globalSettings.SqlServer.ConnectionString, globalSettings.SqlServer.ReadOnlyConnectionString) | ||
| { | ||
| } | ||
|
|
||
| public OrganizationReportRepository(string connectionString, string readOnlyConnectionString) | ||
| : base(connectionString, readOnlyConnectionString) | ||
| { | ||
| } | ||
|
|
||
| public async Task<ICollection<OrganizationReport>> GetByOrganizationIdAsync(Guid organizationId) | ||
| { | ||
| using (var connection = new SqlConnection(ReadOnlyConnectionString)) | ||
| { | ||
| var results = await connection.QueryAsync<OrganizationReport>( | ||
| $"[{Schema}].[OrganizationReport_ReadByOrganizationId]", | ||
| new { OrganizationId = organizationId }, | ||
| commandType: CommandType.StoredProcedure); | ||
|
|
||
| return results.ToList(); | ||
| } | ||
| } | ||
| } | ||
4 changes: 2 additions & 2 deletions
4
src/Infrastructure.Dapper/Dirt/PasswordHealthReportApplicationRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ure.EntityFramework/Dirt/Configurations/OrganizationApplicationEntityTypeConfiguration.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ๏ปฟusing Bit.Infrastructure.EntityFramework.Dirt.Models; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
|
||
| namespace Bit.Infrastructure.EntityFramework.Dirt.Configurations; | ||
|
|
||
| public class OrganizationApplicationEntityTypeConfiguration : IEntityTypeConfiguration<OrganizationApplication> | ||
| { | ||
| public void Configure(EntityTypeBuilder<OrganizationApplication> builder) | ||
| { | ||
| builder | ||
| .Property(s => s.Id) | ||
| .ValueGeneratedNever(); | ||
|
|
||
| builder.HasIndex(s => s.Id) | ||
| .IsClustered(true); | ||
|
|
||
| builder | ||
| .HasIndex(s => s.OrganizationId) | ||
| .IsClustered(false); | ||
|
|
||
| builder | ||
| .HasOne(s => s.Organization) | ||
| .WithMany() | ||
| .HasForeignKey(s => s.OrganizationId) | ||
| .OnDelete(DeleteBehavior.Cascade); | ||
|
|
||
| builder.ToTable(nameof(OrganizationApplication)); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
...tructure.EntityFramework/Dirt/Configurations/OrganizationReportEntityTypeConfiguration.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ๏ปฟusing Bit.Infrastructure.EntityFramework.Dirt.Models; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
|
||
| namespace Bit.Infrastructure.EntityFramework.Dirt.Configurations; | ||
|
|
||
| public class OrganizationReportEntityTypeConfiguration : IEntityTypeConfiguration<OrganizationReport> | ||
| { | ||
| public void Configure(EntityTypeBuilder<OrganizationReport> builder) | ||
| { | ||
| builder | ||
| .Property(s => s.Id) | ||
| .ValueGeneratedNever(); | ||
|
|
||
| builder.HasIndex(s => s.Id) | ||
| .IsClustered(true); | ||
|
|
||
| builder | ||
| .HasIndex(s => s.OrganizationId) | ||
| .IsClustered(false); | ||
|
|
||
| builder | ||
| .HasOne(s => s.Organization) | ||
| .WithMany() | ||
| .HasForeignKey(s => s.OrganizationId) | ||
| .OnDelete(DeleteBehavior.Cascade); | ||
|
|
||
| builder.ToTable(nameof(OrganizationReport)); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/Infrastructure.EntityFramework/Dirt/Models/OrganizationApplication.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ๏ปฟusing AutoMapper; | ||
| using Bit.Infrastructure.EntityFramework.AdminConsole.Models; | ||
|
|
||
| namespace Bit.Infrastructure.EntityFramework.Dirt.Models; | ||
| public class OrganizationApplication : Core.Dirt.Entities.OrganizationApplication | ||
| { | ||
| public virtual Organization Organization { get; set; } | ||
| } | ||
|
|
||
| public class OrganizationApplicationProfile : Profile | ||
| { | ||
| public OrganizationApplicationProfile() | ||
| { | ||
| CreateMap<Core.Dirt.Entities.OrganizationApplication, OrganizationApplication>() | ||
| .ReverseMap(); | ||
| } | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
src/Infrastructure.EntityFramework/Dirt/Models/OrganizationReport.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ๏ปฟusing AutoMapper; | ||
| using Bit.Infrastructure.EntityFramework.AdminConsole.Models; | ||
|
|
||
| namespace Bit.Infrastructure.EntityFramework.Dirt.Models; | ||
| public class OrganizationReport : Core.Dirt.Entities.OrganizationReport | ||
| { | ||
| public virtual Organization Organization { get; set; } | ||
| } | ||
|
|
||
| public class OrganizationReportProfile : Profile | ||
| { | ||
| public OrganizationReportProfile() | ||
| { | ||
| CreateMap<Core.Dirt.Entities.OrganizationReport, OrganizationReport>() | ||
| .ReverseMap(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to look up what
IRevisableeven was -- it can stay I guess but it really never caught on here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand IRevisable - I put it there since most other entities have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only a few actually.