[PM-12775] Autofill should not occur within 2FA fields
This commit is contained in:
parent
08e9a69083
commit
9637dcfcf8
|
@ -55,6 +55,7 @@ export class AutoFillConstants {
|
|||
|
||||
static readonly PasswordFieldExcludeList: string[] = [
|
||||
...AutoFillConstants.FieldIgnoreList,
|
||||
"hint",
|
||||
"onetimepassword",
|
||||
];
|
||||
|
||||
|
|
|
@ -2260,29 +2260,23 @@ describe("AutofillService", () => {
|
|||
options,
|
||||
);
|
||||
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenCalledTimes(4);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenCalledWith(
|
||||
usernameField,
|
||||
AutoFillConstants.UsernameFieldNames,
|
||||
);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenCalledWith(
|
||||
emailField,
|
||||
AutoFillConstants.UsernameFieldNames,
|
||||
);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenCalledWith(
|
||||
telephoneField,
|
||||
AutoFillConstants.UsernameFieldNames,
|
||||
);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenNthCalledWith(
|
||||
4,
|
||||
expect(AutofillService.fieldIsFuzzyMatch).toHaveBeenCalledWith(
|
||||
totpField,
|
||||
AutoFillConstants.UsernameFieldNames,
|
||||
);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).not.toHaveBeenNthCalledWith(
|
||||
5,
|
||||
expect(AutofillService.fieldIsFuzzyMatch).not.toHaveBeenCalledWith(
|
||||
nonViewableField,
|
||||
AutoFillConstants.UsernameFieldNames,
|
||||
);
|
||||
|
@ -2328,6 +2322,7 @@ describe("AutofillService", () => {
|
|||
|
||||
it("will not attempt to fuzzy match a totp field if totp autofill is not allowed", async () => {
|
||||
options.allowTotpAutofill = false;
|
||||
jest.spyOn(autofillService as any, "findMatchingFieldIndex");
|
||||
|
||||
await autofillService["generateLoginFillScript"](
|
||||
fillScript,
|
||||
|
@ -2336,7 +2331,7 @@ describe("AutofillService", () => {
|
|||
options,
|
||||
);
|
||||
|
||||
expect(AutofillService.fieldIsFuzzyMatch).not.toHaveBeenCalledWith(
|
||||
expect(autofillService["findMatchingFieldIndex"]).not.toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
AutoFillConstants.TotpFieldNames,
|
||||
);
|
||||
|
@ -2386,7 +2381,6 @@ describe("AutofillService", () => {
|
|||
false,
|
||||
false,
|
||||
);
|
||||
expect(AutofillService.fieldIsFuzzyMatch).not.toHaveBeenCalled();
|
||||
expect(AutofillService.fillByOpid).toHaveBeenCalledTimes(2);
|
||||
expect(AutofillService.fillByOpid).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
|
|
|
@ -2556,6 +2556,11 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
// We want to avoid treating TOTP fields as password fields
|
||||
if (AutofillService.fieldIsFuzzyMatch(f, AutoFillConstants.TotpFieldNames)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isLikePassword = () => {
|
||||
if (f.type !== "text") {
|
||||
return false;
|
||||
|
|
|
@ -30,7 +30,6 @@ export class InlineMenuFieldQualificationService
|
|||
this.webAuthnAutocompleteValue,
|
||||
]);
|
||||
private fieldIgnoreListString = AutoFillConstants.FieldIgnoreList.join(",");
|
||||
private passwordFieldExcludeListString = AutoFillConstants.PasswordFieldExcludeList.join(",");
|
||||
private currentPasswordAutocompleteValue = "current-password";
|
||||
private newPasswordAutoCompleteValue = "new-password";
|
||||
private autofillFieldKeywordsMap: AutofillKeywordsMap = new WeakMap();
|
||||
|
@ -927,7 +926,7 @@ export class InlineMenuFieldQualificationService
|
|||
return false;
|
||||
}
|
||||
|
||||
return !(this.passwordFieldExcludeListString.indexOf(cleanedValue) > -1);
|
||||
return !AutoFillConstants.PasswordFieldExcludeList.some((i) => cleanedValue.indexOf(i) > -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue