2018-12-12 04:09:16 +01:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
ComponentFactoryResolver,
|
2018-12-12 15:29:51 +01:00
|
|
|
OnInit,
|
2018-12-12 04:09:16 +01:00
|
|
|
} from '@angular/core';
|
|
|
|
|
|
|
|
import { AuditService } from 'jslib/abstractions/audit.service';
|
|
|
|
import { CipherService } from 'jslib/abstractions/cipher.service';
|
2018-12-12 15:29:51 +01:00
|
|
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
|
|
|
import { UserService } from 'jslib/abstractions/user.service';
|
2018-12-12 04:09:16 +01:00
|
|
|
|
|
|
|
import { CipherView } from 'jslib/models/view/cipherView';
|
|
|
|
|
|
|
|
import { CipherType } from 'jslib/enums/cipherType';
|
|
|
|
|
2018-12-12 15:11:10 +01:00
|
|
|
import { CipherReportComponent } from './cipher-report.component';
|
2018-12-12 04:09:16 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-exposed-passwords-report',
|
|
|
|
templateUrl: 'exposed-passwords-report.component.html',
|
|
|
|
})
|
2018-12-12 15:29:51 +01:00
|
|
|
export class ExposedPasswordsReportComponent extends CipherReportComponent implements OnInit {
|
2018-12-12 04:09:16 +01:00
|
|
|
exposedPasswordMap = new Map<string, number>();
|
|
|
|
|
|
|
|
constructor(private ciphersService: CipherService, private auditService: AuditService,
|
2018-12-12 15:29:51 +01:00
|
|
|
componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService,
|
|
|
|
userService: UserService) {
|
|
|
|
super(componentFactoryResolver, userService, messagingService, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.checkPremium();
|
|
|
|
}
|
|
|
|
|
|
|
|
async load() {
|
|
|
|
if (await this.checkPremium()) {
|
|
|
|
super.load();
|
|
|
|
}
|
2018-12-12 15:11:10 +01:00
|
|
|
}
|
2018-12-12 04:09:16 +01:00
|
|
|
|
2018-12-12 15:11:10 +01:00
|
|
|
async setCiphers() {
|
2018-12-12 04:09:16 +01:00
|
|
|
const allCiphers = await this.ciphersService.getAllDecrypted();
|
|
|
|
const exposedPasswordCiphers: CipherView[] = [];
|
|
|
|
const promises: Array<Promise<void>> = [];
|
|
|
|
allCiphers.forEach((c) => {
|
|
|
|
if (c.type !== CipherType.Login || c.login.password == null || c.login.password === '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const promise = this.auditService.passwordLeaked(c.login.password).then((exposedCount) => {
|
|
|
|
if (exposedCount > 0) {
|
|
|
|
exposedPasswordCiphers.push(c);
|
|
|
|
this.exposedPasswordMap.set(c.id, exposedCount);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
promises.push(promise);
|
|
|
|
});
|
|
|
|
await Promise.all(promises);
|
|
|
|
this.ciphers = exposedPasswordCiphers;
|
|
|
|
}
|
|
|
|
}
|