diff --git a/jslib b/jslib index ed74f73a8c..6a958afd16 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit ed74f73a8ca2d26cacf2f74b4cd14c6150711b87 +Subproject commit 6a958afd16cd727c1cfade2f4a0aff3ae22ec28a diff --git a/src/app/tools/weak-passwords-report.component.ts b/src/app/tools/weak-passwords-report.component.ts index ae19d30407..73e8bb6e21 100644 --- a/src/app/tools/weak-passwords-report.component.ts +++ b/src/app/tools/weak-passwords-report.component.ts @@ -43,11 +43,26 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen if (c.type !== CipherType.Login || c.login.password == null || c.login.password === '') { return; } - if (!this.passwordStrengthCache.has(c.login.password)) { - const result = this.passwordGenerationService.passwordStrength(c.login.password); - this.passwordStrengthCache.set(c.login.password, result.score); + const hasUsername = c.login.username != null && c.login.username.trim() !== ''; + const cacheKey = c.login.password + '_____' + (hasUsername ? c.login.username : ''); + if (!this.passwordStrengthCache.has(cacheKey)) { + let userInput: string[] = []; + if (hasUsername) { + const atPosition = c.login.username.indexOf('@'); + if (atPosition > -1) { + userInput = userInput.concat( + c.login.username.substr(0, atPosition).trim().toLowerCase().split(/[^A-Za-z0-9]/)) + .filter((i) => i.length >= 3); + } else { + userInput = c.login.username.trim().toLowerCase().split(/[^A-Za-z0-9]/) + .filter((i) => i.length >= 3); + } + } + const result = this.passwordGenerationService.passwordStrength(c.login.password, + userInput.length > 0 ? userInput : null); + this.passwordStrengthCache.set(cacheKey, result.score); } - const score = this.passwordStrengthCache.get(c.login.password); + const score = this.passwordStrengthCache.get(cacheKey); if (score != null && score <= 3) { this.passwordStrengthMap.set(c.id, this.scoreKey(score)); weakPasswordCiphers.push(c);