mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[PM-25614] Add Encrichment Logic for Risk Insights Data Service (#16577)
* Add encryption logic. Minor updates to critical apps service * Fix possibly null type
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
||||
import { RiskInsightsEncryptionService } from "@bitwarden/bit-common/dirt/reports/risk-insights/services/risk-insights-encryption.service";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { AccountService as AccountServiceAbstraction } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { KeyGenerationService } from "@bitwarden/common/key-management/crypto";
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength/password-strength.service.abstraction";
|
||||
@@ -36,10 +38,15 @@ import { RiskInsightsComponent } from "./risk-insights.component";
|
||||
MemberCipherDetailsApiService,
|
||||
],
|
||||
},
|
||||
{
|
||||
safeProvider({
|
||||
provide: RiskInsightsDataService,
|
||||
deps: [RiskInsightsReportService],
|
||||
},
|
||||
deps: [
|
||||
AccountServiceAbstraction,
|
||||
CriticalAppsService,
|
||||
OrganizationService,
|
||||
RiskInsightsReportService,
|
||||
],
|
||||
}),
|
||||
{
|
||||
provide: RiskInsightsEncryptionService,
|
||||
useClass: RiskInsightsEncryptionService,
|
||||
|
||||
@@ -66,40 +66,42 @@ export class CriticalApplicationsComponent implements OnInit {
|
||||
"organizationId",
|
||||
) as OrganizationId;
|
||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
||||
this.criticalAppsService.setOrganizationId(this.organizationId as OrganizationId, userId);
|
||||
// this.criticalAppsService.setOrganizationId(this.organizationId as OrganizationId);
|
||||
combineLatest([
|
||||
this.dataService.applications$,
|
||||
this.criticalAppsService.getAppsListForOrg(this.organizationId as OrganizationId),
|
||||
])
|
||||
.pipe(
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
map(([applications, criticalApps]) => {
|
||||
const criticalUrls = criticalApps.map((ca) => ca.uri);
|
||||
const data = applications?.map((app) => ({
|
||||
...app,
|
||||
isMarkedAsCritical: criticalUrls.includes(app.applicationName),
|
||||
})) as LEGACY_ApplicationHealthReportDetailWithCriticalFlag[];
|
||||
return data?.filter((app) => app.isMarkedAsCritical);
|
||||
}),
|
||||
switchMap(async (data) => {
|
||||
if (data) {
|
||||
const dataWithCiphers = await this.reportService.identifyCiphers(
|
||||
data,
|
||||
this.organizationId,
|
||||
);
|
||||
return dataWithCiphers;
|
||||
this.criticalAppsService.loadOrganizationContext(this.organizationId as OrganizationId, userId);
|
||||
|
||||
if (this.organizationId) {
|
||||
combineLatest([
|
||||
this.dataService.applications$,
|
||||
this.criticalAppsService.getAppsListForOrg(this.organizationId as OrganizationId),
|
||||
])
|
||||
.pipe(
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
map(([applications, criticalApps]) => {
|
||||
const criticalUrls = criticalApps.map((ca) => ca.uri);
|
||||
const data = applications?.map((app) => ({
|
||||
...app,
|
||||
isMarkedAsCritical: criticalUrls.includes(app.applicationName),
|
||||
})) as LEGACY_ApplicationHealthReportDetailWithCriticalFlag[];
|
||||
return data?.filter((app) => app.isMarkedAsCritical);
|
||||
}),
|
||||
switchMap(async (data) => {
|
||||
if (data) {
|
||||
const dataWithCiphers = await this.reportService.identifyCiphers(
|
||||
data,
|
||||
this.organizationId,
|
||||
);
|
||||
return dataWithCiphers;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
)
|
||||
.subscribe((applications) => {
|
||||
if (applications) {
|
||||
this.dataSource.data = applications;
|
||||
this.applicationSummary = this.reportService.generateApplicationsSummary(applications);
|
||||
this.enableRequestPasswordChange = this.applicationSummary.totalAtRiskMemberCount > 0;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
)
|
||||
.subscribe((applications) => {
|
||||
if (applications) {
|
||||
this.dataSource.data = applications;
|
||||
this.applicationSummary = this.reportService.generateApplicationsSummary(applications);
|
||||
this.enableRequestPasswordChange = this.applicationSummary.totalAtRiskMemberCount > 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
goToAllAppsTab = async () => {
|
||||
|
||||
@@ -127,7 +127,10 @@ export class RiskInsightsComponent implements OnInit {
|
||||
this.appsCount = applications.length;
|
||||
}
|
||||
|
||||
this.criticalAppsService.setOrganizationId(this.organizationId as OrganizationId, userId);
|
||||
this.criticalAppsService.loadOrganizationContext(
|
||||
this.organizationId as OrganizationId,
|
||||
userId,
|
||||
);
|
||||
this.criticalApps$ = this.criticalAppsService.getAppsListForOrg(
|
||||
this.organizationId as OrganizationId,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user