From ea2b46db718203693f5be6b221c36a72df1e748f Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Fri, 15 Nov 2024 09:32:34 -0800 Subject: [PATCH] remove unused components --- ...password-health-members-uri.component.html | 55 -------- ...sword-health-members-uri.component.spec.ts | 73 ---------- .../password-health-members-uri.component.ts | 110 --------------- .../password-health-members.component.html | 64 --------- .../password-health-members.component.ts | 130 ------------------ .../password-health.component.html | 57 -------- .../password-health.component.spec.ts | 70 ---------- .../password-health.component.ts | 100 -------------- .../services/password-health.service.ts | 1 - 9 files changed, 660 deletions(-) delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members.component.html delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health-members.component.ts delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health.component.html delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts delete mode 100644 apps/web/src/app/tools/access-intelligence/password-health.component.ts diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html b/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html deleted file mode 100644 index bdccc523e76..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html +++ /dev/null @@ -1,55 +0,0 @@ - -

{{ "passwordsReportDesc" | i18n }}

-
- - {{ "loading" | i18n }} -
-
- - - - {{ "application" | i18n }} - {{ "weakness" | i18n }} - {{ "timesReused" | i18n }} - {{ "timesExposed" | i18n }} - {{ "totalMembers" | i18n }} - - - - - - - {{ r.hostURI }} - - - - - {{ passwordStrengthMap.get(r.id)[0] | i18n }} - - - - - {{ "reusedXTimes" | i18n: passwordUseMap.get(r.login.password) }} - - - - - {{ "exposedXTimes" | i18n: exposedPasswordMap.get(r.id) }} - - - - {{ totalMembersMap.get(r.id) || 0 }} - - - - -
-
diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts b/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts deleted file mode 100644 index e3011604a45..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.spec.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { ActivatedRoute, convertToParamMap } from "@angular/router"; -import { mock, MockProxy } from "jest-mock-extended"; -import { of } from "rxjs"; - -// eslint-disable-next-line no-restricted-imports -import { - MemberCipherDetailsApiService, - PasswordHealthService, -} from "@bitwarden/bit-common/tools/reports/risk-insights"; -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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { TableModule } from "@bitwarden/components"; - -import { LooseComponentsModule } from "../../shared"; -import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; - -import { PasswordHealthMembersURIComponent } from "./password-health-members-uri.component"; - -describe("PasswordHealthMembersUriComponent", () => { - let component: PasswordHealthMembersURIComponent; - let fixture: ComponentFixture; - let cipherServiceMock: MockProxy; - const passwordHealthServiceMock = mock(); - - const activeRouteParams = convertToParamMap({ organizationId: "orgId" }); - - beforeEach(async () => { - cipherServiceMock = mock(); - await TestBed.configureTestingModule({ - imports: [PasswordHealthMembersURIComponent, PipesModule, TableModule, LooseComponentsModule], - providers: [ - { provide: CipherService, useValue: cipherServiceMock }, - { provide: I18nService, useValue: mock() }, - { provide: AuditService, useValue: mock() }, - { provide: OrganizationService, useValue: mock() }, - { - provide: PasswordStrengthServiceAbstraction, - useValue: mock(), - }, - { provide: PasswordHealthService, useValue: passwordHealthServiceMock }, - { - provide: ActivatedRoute, - useValue: { - paramMap: of(activeRouteParams), - url: of([]), - }, - }, - { - provide: MemberCipherDetailsApiService, - useValue: mock(), - }, - { - provide: ApiService, - useValue: mock(), - }, - ], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PasswordHealthMembersURIComponent); - component = fixture.componentInstance; - }); - - it("should initialize component", () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts b/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts deleted file mode 100644 index c8aea97ef77..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { CommonModule } from "@angular/common"; -import { Component, DestroyRef, inject, OnInit } from "@angular/core"; -import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; -import { ActivatedRoute } from "@angular/router"; -import { map } from "rxjs"; - -import { JslibModule } from "@bitwarden/angular/jslib.module"; -// eslint-disable-next-line no-restricted-imports -import { - MemberCipherDetailsApiService, - PasswordHealthService, -} from "@bitwarden/bit-common/tools/reports/risk-insights"; -import { AuditService } from "@bitwarden/common/abstractions/audit.service"; -import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; -import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; -import { - BadgeModule, - BadgeVariant, - ContainerComponent, - TableDataSource, - TableModule, -} from "@bitwarden/components"; - -// eslint-disable-next-line no-restricted-imports -import { HeaderModule } from "../../layouts/header/header.module"; -// eslint-disable-next-line no-restricted-imports -import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; - -@Component({ - standalone: true, - selector: "tools-password-health-members-uri", - templateUrl: "password-health-members-uri.component.html", - imports: [ - BadgeModule, - CommonModule, - ContainerComponent, - PipesModule, - JslibModule, - HeaderModule, - TableModule, - ], - providers: [PasswordHealthService, MemberCipherDetailsApiService], -}) -export class PasswordHealthMembersURIComponent implements OnInit { - passwordStrengthMap = new Map(); - - weakPasswordCiphers: CipherView[] = []; - - passwordUseMap = new Map(); - - exposedPasswordMap = new Map(); - - totalMembersMap = new Map(); - - dataSource = new TableDataSource(); - - reportCiphers: (CipherView & { hostURI: string })[] = []; - reportCipherURIs: string[] = []; - - organization: Organization; - - loading = true; - - private destroyRef = inject(DestroyRef); - - constructor( - protected cipherService: CipherService, - protected passwordStrengthService: PasswordStrengthServiceAbstraction, - protected organizationService: OrganizationService, - protected auditService: AuditService, - protected i18nService: I18nService, - protected activatedRoute: ActivatedRoute, - protected memberCipherDetailsApiService: MemberCipherDetailsApiService, - ) {} - - ngOnInit() { - this.activatedRoute.paramMap - .pipe( - takeUntilDestroyed(this.destroyRef), - map(async (params) => { - const organizationId = params.get("organizationId"); - await this.setCiphers(organizationId); - }), - ) - .subscribe(); - } - - async setCiphers(organizationId: string) { - const passwordHealthService = new PasswordHealthService( - this.passwordStrengthService, - this.auditService, - this.cipherService, - this.memberCipherDetailsApiService, - organizationId, - ); - - await passwordHealthService.generateReport(); - - this.dataSource.data = passwordHealthService.groupCiphersByLoginUri(); - this.exposedPasswordMap = passwordHealthService.exposedPasswordMap; - this.passwordStrengthMap = passwordHealthService.passwordStrengthMap; - this.passwordUseMap = passwordHealthService.passwordUseMap; - this.totalMembersMap = passwordHealthService.totalMembersMap; - this.loading = false; - } -} diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members.component.html b/apps/web/src/app/tools/access-intelligence/password-health-members.component.html deleted file mode 100644 index 7f9b37f2a82..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members.component.html +++ /dev/null @@ -1,64 +0,0 @@ -

{{ "passwordsReportDesc" | i18n }}

-
- - {{ "loading" | i18n }} -
-
- - - - - {{ "name" | i18n }} - {{ "weakness" | i18n }} - {{ "timesReused" | i18n }} - {{ "timesExposed" | i18n }} - {{ "totalMembers" | i18n }} - - - - - - - - - - {{ r.name }} - -
- {{ r.subTitle }} - - - - {{ passwordStrengthMap.get(r.id)[0] | i18n }} - - - - - {{ "reusedXTimes" | i18n: passwordUseMap.get(r.login.password) }} - - - - - {{ "exposedXTimes" | i18n: exposedPasswordMap.get(r.id) }} - - - - {{ totalMembersMap.get(r.id) || 0 }} - - -
-
-
diff --git a/apps/web/src/app/tools/access-intelligence/password-health-members.component.ts b/apps/web/src/app/tools/access-intelligence/password-health-members.component.ts deleted file mode 100644 index 66ff348e9f9..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health-members.component.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { Component, DestroyRef, inject, OnInit } from "@angular/core"; -import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; -import { FormControl, FormsModule } from "@angular/forms"; -import { ActivatedRoute } from "@angular/router"; -import { debounceTime, map } from "rxjs"; - -// eslint-disable-next-line no-restricted-imports -import { - MemberCipherDetailsApiService, - PasswordHealthService, -} from "@bitwarden/bit-common/tools/reports/risk-insights"; -import { AuditService } from "@bitwarden/common/abstractions/audit.service"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; -import { - BadgeVariant, - SearchModule, - TableDataSource, - TableModule, - ToastService, -} from "@bitwarden/components"; - -import { HeaderModule } from "../../layouts/header/header.module"; -// eslint-disable-next-line no-restricted-imports -import { SharedModule } from "../../shared"; -// eslint-disable-next-line no-restricted-imports -import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; - -@Component({ - standalone: true, - selector: "tools-password-health-members", - templateUrl: "password-health-members.component.html", - imports: [PipesModule, HeaderModule, SearchModule, FormsModule, SharedModule, TableModule], - providers: [PasswordHealthService, MemberCipherDetailsApiService], -}) -export class PasswordHealthMembersComponent implements OnInit { - passwordStrengthMap = new Map(); - - passwordUseMap = new Map(); - - exposedPasswordMap = new Map(); - - totalMembersMap = new Map(); - - dataSource = new TableDataSource(); - - loading = true; - - selectedIds: Set = new Set(); - - protected searchControl = new FormControl("", { nonNullable: true }); - - private destroyRef = inject(DestroyRef); - - constructor( - protected cipherService: CipherService, - protected passwordStrengthService: PasswordStrengthServiceAbstraction, - protected auditService: AuditService, - protected i18nService: I18nService, - protected activatedRoute: ActivatedRoute, - protected toastService: ToastService, - protected memberCipherDetailsApiService: MemberCipherDetailsApiService, - ) { - this.searchControl.valueChanges - .pipe(debounceTime(200), takeUntilDestroyed()) - .subscribe((v) => (this.dataSource.filter = v)); - } - - ngOnInit() { - this.activatedRoute.paramMap - .pipe( - takeUntilDestroyed(this.destroyRef), - map(async (params) => { - const organizationId = params.get("organizationId"); - await this.setCiphers(organizationId); - }), - ) - .subscribe(); - } - - async setCiphers(organizationId: string) { - const passwordHealthService = new PasswordHealthService( - this.passwordStrengthService, - this.auditService, - this.cipherService, - this.memberCipherDetailsApiService, - organizationId, - ); - - await passwordHealthService.generateReport(); - - this.dataSource.data = passwordHealthService.reportCiphers; - - this.exposedPasswordMap = passwordHealthService.exposedPasswordMap; - this.passwordStrengthMap = passwordHealthService.passwordStrengthMap; - this.passwordUseMap = passwordHealthService.passwordUseMap; - this.totalMembersMap = passwordHealthService.totalMembersMap; - this.loading = false; - } - - markAppsAsCritical = async () => { - // TODO: Send to API once implemented - return new Promise((resolve) => { - setTimeout(() => { - this.selectedIds.clear(); - this.toastService.showToast({ - variant: "success", - title: null, - message: this.i18nService.t("appsMarkedAsCritical"), - }); - resolve(true); - }, 1000); - }); - }; - - trackByFunction(_: number, item: CipherView) { - return item.id; - } - - onCheckboxChange(id: number, event: Event) { - const isChecked = (event.target as HTMLInputElement).checked; - if (isChecked) { - this.selectedIds.add(id); - } else { - this.selectedIds.delete(id); - } - } -} diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.html b/apps/web/src/app/tools/access-intelligence/password-health.component.html deleted file mode 100644 index 5b1fe4610d9..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health.component.html +++ /dev/null @@ -1,57 +0,0 @@ - -

{{ "passwordsReportDesc" | i18n }}

-
- - {{ "loading" | i18n }} -
-
- - - - - {{ "name" | i18n }} - {{ "weakness" | i18n }} - {{ "timesReused" | i18n }} - {{ "timesExposed" | i18n }} - - - - - - - - - - {{ r.name }} - -
- {{ r.subTitle }} - - - - {{ passwordStrengthMap.get(r.id)[0] | i18n }} - - - - - {{ "reusedXTimes" | i18n: passwordUseMap.get(r.login.password) }} - - - - - {{ "exposedXTimes" | i18n: exposedPasswordMap.get(r.id) }} - - - -
-
-
-
diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts b/apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts deleted file mode 100644 index 5e934e3edfc..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health.component.spec.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { ActivatedRoute, convertToParamMap } from "@angular/router"; -import { mock } from "jest-mock-extended"; -import { of } from "rxjs"; - -// eslint-disable-next-line no-restricted-imports -import { - MemberCipherDetailsApiService, - PasswordHealthService, -} from "@bitwarden/bit-common/tools/reports/risk-insights"; -import { ApiService } from "@bitwarden/common/abstractions/api.service"; -import { AuditService } from "@bitwarden/common/abstractions/audit.service"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { TableModule } from "@bitwarden/components"; -import { TableBodyDirective } from "@bitwarden/components/src/table/table.component"; - -import { LooseComponentsModule } from "../../shared"; -import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; - -import { PasswordHealthComponent } from "./password-health.component"; - -describe("PasswordHealthComponent", () => { - let component: PasswordHealthComponent; - let fixture: ComponentFixture; - const activeRouteParams = convertToParamMap({ organizationId: "orgId" }); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [PasswordHealthComponent, PipesModule, TableModule, LooseComponentsModule], - declarations: [TableBodyDirective], - providers: [ - { provide: CipherService, useValue: mock() }, - { provide: I18nService, useValue: mock() }, - { provide: AuditService, useValue: mock() }, - { provide: ApiService, useValue: mock() }, - { provide: MemberCipherDetailsApiService, useValue: mock() }, - { - provide: PasswordStrengthServiceAbstraction, - useValue: mock(), - }, - { - provide: PasswordHealthService, - useValue: mock(), - }, - { - provide: ActivatedRoute, - useValue: { - paramMap: of(activeRouteParams), - url: of([]), - }, - }, - ], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PasswordHealthComponent); - component = fixture.componentInstance; - - fixture.detectChanges(); - }); - - it("should initialize component", () => { - expect(component).toBeTruthy(); - }); - - it("should call generateReport on init", () => {}); -}); diff --git a/apps/web/src/app/tools/access-intelligence/password-health.component.ts b/apps/web/src/app/tools/access-intelligence/password-health.component.ts deleted file mode 100644 index 058cfb86dae..00000000000 --- a/apps/web/src/app/tools/access-intelligence/password-health.component.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { CommonModule } from "@angular/common"; -import { Component, DestroyRef, inject, OnInit } from "@angular/core"; -import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; -import { ActivatedRoute } from "@angular/router"; -import { map } from "rxjs"; - -import { JslibModule } from "@bitwarden/angular/jslib.module"; -// eslint-disable-next-line no-restricted-imports -import { - MemberCipherDetailsApiService, - PasswordHealthService, -} from "@bitwarden/bit-common/tools/reports/risk-insights"; -import { AuditService } from "@bitwarden/common/abstractions/audit.service"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength"; -import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; -import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; -import { - BadgeModule, - BadgeVariant, - ContainerComponent, - TableDataSource, - TableModule, -} from "@bitwarden/components"; - -// eslint-disable-next-line no-restricted-imports -import { HeaderModule } from "../../layouts/header/header.module"; -// eslint-disable-next-line no-restricted-imports -import { OrganizationBadgeModule } from "../../vault/individual-vault/organization-badge/organization-badge.module"; -// eslint-disable-next-line no-restricted-imports -import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; - -@Component({ - standalone: true, - selector: "tools-password-health", - templateUrl: "password-health.component.html", - imports: [ - BadgeModule, - OrganizationBadgeModule, - CommonModule, - ContainerComponent, - PipesModule, - JslibModule, - HeaderModule, - TableModule, - ], - providers: [PasswordHealthService, MemberCipherDetailsApiService], -}) -export class PasswordHealthComponent implements OnInit { - passwordStrengthMap = new Map(); - - passwordUseMap = new Map(); - - exposedPasswordMap = new Map(); - - dataSource = new TableDataSource(); - - loading = true; - - private destroyRef = inject(DestroyRef); - - constructor( - protected cipherService: CipherService, - protected passwordStrengthService: PasswordStrengthServiceAbstraction, - protected auditService: AuditService, - protected i18nService: I18nService, - protected activatedRoute: ActivatedRoute, - protected memberCipherDetailsApiService: MemberCipherDetailsApiService, - ) {} - - ngOnInit() { - this.activatedRoute.paramMap - .pipe( - takeUntilDestroyed(this.destroyRef), - map(async (params) => { - const organizationId = params.get("organizationId"); - await this.setCiphers(organizationId); - }), - ) - .subscribe(); - } - - async setCiphers(organizationId: string) { - const passwordHealthService = new PasswordHealthService( - this.passwordStrengthService, - this.auditService, - this.cipherService, - this.memberCipherDetailsApiService, - organizationId, - ); - - await passwordHealthService.generateReport(); - - this.dataSource.data = passwordHealthService.reportCiphers; - this.exposedPasswordMap = passwordHealthService.exposedPasswordMap; - this.passwordStrengthMap = passwordHealthService.passwordStrengthMap; - this.passwordUseMap = passwordHealthService.passwordUseMap; - this.loading = false; - } -} diff --git a/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts index 1161415ea58..ddfe63737ad 100644 --- a/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts +++ b/bitwarden_license/bit-common/src/tools/reports/risk-insights/services/password-health.service.ts @@ -145,7 +145,6 @@ export class PasswordHealthService { } } - // Convert map to array return { totalAtRiskMembers: totalAtRiskMembers.size, totalMembers: members.length,