1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[PM-166] [PM-198] - Add Event Logs for CLI Actions (#6527)

* Added the DeviceType changes for windows CLI

* Event logging for CLI commands

* Changing the icons to cli icons
This commit is contained in:
ttalty
2023-11-09 15:17:25 -05:00
committed by GitHub
parent 4446c09fd2
commit 801141f90e
12 changed files with 93 additions and 14 deletions

View File

@@ -1,9 +1,11 @@
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { EventType } from "@bitwarden/common/enums";
import { CardExport } from "@bitwarden/common/models/export/card.export";
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
@@ -53,7 +55,8 @@ export class GetCommand extends DownloadCommand {
private stateService: StateService,
private searchService: SearchService,
private apiService: ApiService,
private organizationService: OrganizationService
private organizationService: OrganizationService,
private eventCollectionService: EventCollectionService
) {
super(cryptoService);
}
@@ -137,6 +140,14 @@ export class GetCommand extends DownloadCommand {
return Response.multipleResults(decCipher.map((c) => c.id));
}
}
this.eventCollectionService.collect(
EventType.Cipher_ClientViewed,
id,
true,
decCipher.organizationId
);
const res = new CipherResponse(decCipher);
return Response.success(res);
}

View File

@@ -1,7 +1,9 @@
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { OrganizationUserService } from "@bitwarden/common/admin-console/abstractions/organization-user/organization-user.service";
import { EventType } from "@bitwarden/common/enums";
import { ListResponse as ApiListResponse } from "@bitwarden/common/models/response/list.response";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
@@ -32,7 +34,8 @@ export class ListCommand {
private organizationService: OrganizationService,
private searchService: SearchService,
private organizationUserService: OrganizationUserService,
private apiService: ApiService
private apiService: ApiService,
private eventCollectionService: EventCollectionService
) {}
async run(object: string, cmdOptions: Record<string, any>): Promise<Response> {
@@ -123,6 +126,17 @@ export class ListCommand {
ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash);
}
ciphers.forEach((c, index) => {
// Set upload immediately on the last item in the ciphers collection to avoid the event collection
// service from uploading each time.
this.eventCollectionService.collect(
EventType.Cipher_ClientViewed,
c.id,
index === ciphers.length - 1,
c.organizationId
);
});
const res = new ListResponse(ciphers.map((o) => new CipherResponse(o)));
return Response.success(res);
}

View File

@@ -66,7 +66,8 @@ export class ServeCommand {
this.main.stateService,
this.main.searchService,
this.main.apiService,
this.main.organizationService
this.main.organizationService,
this.main.eventCollectionService
);
this.listCommand = new ListCommand(
this.main.cipherService,
@@ -75,7 +76,8 @@ export class ServeCommand {
this.main.organizationService,
this.main.searchService,
this.main.organizationUserService,
this.main.apiService
this.main.apiService,
this.main.eventCollectionService
);
this.createCommand = new CreateCommand(
this.main.cipherService,