From b7b4042ab00e99e117e544bcf2428fdd3c20285a Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:48:25 -0400 Subject: [PATCH] SM-1487-AccessedSecretsandDeletedSecretsBulkMessaging --- apps/web/src/app/core/event.service.ts | 31 +++++++++++++++++++ apps/web/src/locales/en/messages.json | 18 +++++++++++ libs/common/src/enums/event-type.enum.ts | 2 ++ .../src/models/response/event.response.ts | 2 ++ 4 files changed, 53 insertions(+) diff --git a/apps/web/src/app/core/event.service.ts b/apps/web/src/app/core/event.service.ts index 14c87181f62..2ac55617a1b 100644 --- a/apps/web/src/app/core/event.service.ts +++ b/apps/web/src/app/core/event.service.ts @@ -470,6 +470,17 @@ export class EventService { msg = this.i18nService.t("accessedSecretWithId", this.formatSecretId(ev)); humanReadableMsg = this.i18nService.t("accessedSecretWithId", this.getShortId(ev.secretId)); break; + case EventType.Secrets_Retrieved_Bulk: + msg = this.i18nService.t("accessedSecretWithIds", this.formatSecretIds(ev)); + humanReadableMsg = this.i18nService.t( + "accessedSecretWithIds", + this.getShortId(ev.secretId), + ); + break; + case EventType.Secrets_Deleted_Bulk: + msg = this.i18nService.t("deletedSecretWithIds", this.formatSecretIds(ev)); + humanReadableMsg = this.i18nService.t("deletedSecretWithIds", this.getShortId(ev.secretId)); + break; case EventType.Secret_Created: msg = this.i18nService.t("createdSecretWithId", this.formatSecretId(ev)); humanReadableMsg = this.i18nService.t("createdSecretWithId", this.getShortId(ev.secretId)); @@ -644,6 +655,26 @@ export class EventService { return a.outerHTML; } + formatSecretIds(ev: EventResponse): string { + if (!ev.secretIds || ev.secretIds.trim() === "") { + return ""; + } + + const ids = ev.secretIds + .split(",") + .map((id) => id.trim()) + .filter((id) => id); + + return ids + .map((secretId) => { + const shortId = this.getShortId(secretId); + const a = this.makeAnchor(shortId); + a.setAttribute("href", `#/sm/${ev.organizationId}/secrets?search=${shortId}`); + return a.outerHTML; + }) + .join(", "); + } + private makeAnchor(shortId: string) { const a = document.createElement("a"); a.title = this.i18nService.t("view"); diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 869b5505f87..efd54434a45 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -8237,6 +8237,15 @@ } } }, + "accessedSecretWithIds": { + "message": "Accessed secrets with the following identifiers: $SECRET_ID$", + "placeholders": { + "secret_id": { + "content": "$1", + "example": "4d34e8a8" + } + } + }, "accessedSecret": { "message": "Accessed secret $SECRET_ID$.", "placeholders": { @@ -8263,6 +8272,15 @@ "example": "4d34e8a8" } } + }, + "deletedSecretWithIds": { + "message": "Deleted secrets with these identifiers: $SECRET_ID$", + "placeholders": { + "secret_id": { + "content": "$1", + "example": "4d34e8a8" + } + } }, "createdSecretWithId": { "message": "Created a new secret with identifier: $SECRET_ID$", diff --git a/libs/common/src/enums/event-type.enum.ts b/libs/common/src/enums/event-type.enum.ts index 914dac00abb..dc44a117dff 100644 --- a/libs/common/src/enums/event-type.enum.ts +++ b/libs/common/src/enums/event-type.enum.ts @@ -93,4 +93,6 @@ export enum EventType { Secret_Created = 2101, Secret_Edited = 2102, Secret_Deleted = 2103, + Secrets_Retrieved_Bulk = 2104, + Secrets_Deleted_Bulk = 2105, } diff --git a/libs/common/src/models/response/event.response.ts b/libs/common/src/models/response/event.response.ts index 58551b34c2c..0b8559ca4b1 100644 --- a/libs/common/src/models/response/event.response.ts +++ b/libs/common/src/models/response/event.response.ts @@ -23,6 +23,7 @@ export class EventResponse extends BaseResponse { domainName: string; secretId: string; serviceAccountId: string; + secretIds: string | null; constructor(response: any) { super(response); @@ -46,5 +47,6 @@ export class EventResponse extends BaseResponse { this.domainName = this.getResponseProperty("DomainName"); this.secretId = this.getResponseProperty("SecretId"); this.serviceAccountId = this.getResponseProperty("ServiceAccountId"); + this.secretIds = this.getResponseProperty("SecretIds"); } }