1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +00:00

[PM-21713] Include CipherId and find Ciphers in Risk Insights report (#14823)

This commit is contained in:
Vijay Oommen
2025-06-04 14:33:46 -05:00
committed by GitHub
parent a17cc0b265
commit 0032d1457f
7 changed files with 80 additions and 17 deletions

View File

@@ -32,13 +32,18 @@ export type ApplicationHealthReportDetail = {
atRiskMemberCount: number;
memberDetails: MemberDetailsFlat[];
atRiskMemberDetails: MemberDetailsFlat[];
cipher: CipherView;
cipherIds: string[];
};
export type ApplicationHealthReportDetailWithCriticalFlag = ApplicationHealthReportDetail & {
isMarkedAsCritical: boolean;
};
export type ApplicationHealthReportDetailWithCriticalFlagAndCipher =
ApplicationHealthReportDetailWithCriticalFlag & {
ciphers: CipherView[];
};
/**
* Breaks the cipher health info out by uri and passes
* along the password health and member info

View File

@@ -141,6 +141,11 @@ export class CriticalAppsService {
const uri = await this.encryptService.decryptString(encrypted, key);
return { id: r.id, organizationId: r.organizationId, uri: uri };
});
if (results.length === 0) {
return of([]); // emits an empty array immediately
}
return forkJoin(results);
}),
first(),

View File

@@ -20,6 +20,7 @@ import {
MemberDetailsFlat,
WeakPasswordDetail,
WeakPasswordScore,
ApplicationHealthReportDetailWithCriticalFlagAndCipher,
} from "../models/password-health";
import { MemberCipherDetailsApiService } from "./member-cipher-details-api.service";
@@ -164,6 +165,22 @@ export class RiskInsightsReportService {
};
}
async identifyCiphers(
data: ApplicationHealthReportDetail[],
organizationId: string,
): Promise<ApplicationHealthReportDetailWithCriticalFlagAndCipher[]> {
const cipherViews = await this.cipherService.getAllFromApiForOrganization(organizationId);
const dataWithCiphers = data.map(
(app, index) =>
({
...app,
ciphers: cipherViews.filter((c) => app.cipherIds.some((a) => a === c.id)),
}) as ApplicationHealthReportDetailWithCriticalFlagAndCipher,
);
return dataWithCiphers;
}
/**
* Associates the members with the ciphers they have access to. Calculates the password health.
* Finds the trimmed uris.
@@ -358,7 +375,9 @@ export class RiskInsightsReportService {
atRiskPasswordCount: existingUriDetail ? existingUriDetail.atRiskPasswordCount : 0,
atRiskCipherIds: existingUriDetail ? existingUriDetail.atRiskCipherIds : [],
atRiskMemberCount: existingUriDetail ? existingUriDetail.atRiskMemberDetails.length : 0,
cipher: newUriDetail.cipher,
cipherIds: existingUriDetail
? existingUriDetail.cipherIds.concat(newUriDetail.cipherId)
: [newUriDetail.cipherId],
} as ApplicationHealthReportDetail;
if (isAtRisk) {