Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-12345] Add cipher type settings for inline autofill menu #11260

Merged
merged 10 commits into from
Oct 15, 2024
Merged

Conversation

jprusik
Copy link
Contributor

@jprusik jprusik commented Sep 26, 2024

🎟️ Tracking

PM-12345

📔 Objective

Provide users a way to turn off the inline autofill menu for specific cipher types

Notes

  • The display of the new settings are gated behind the "inline-menu-positioning-improvements" feature flag
    • Logic consuming these user settings are downstream of that same feature flag

📸 Screenshots

Kapture.2024-09-26.at.15.57.18.mp4
Before After
before after
refresh-before refresh-after

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@jprusik jprusik self-assigned this Sep 26, 2024
@jprusik jprusik marked this pull request as ready for review September 26, 2024 19:58
@jprusik jprusik requested a review from a team as a code owner September 26, 2024 19:58
Copy link
Contributor

github-actions bot commented Sep 26, 2024

Logo
Checkmarx One – Scan Summary & Detailsa59f5ba3-47d3-4b55-af7d-9e0b99dd2a06

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html: 19 Attack Vector
MEDIUM Client_Privacy_Violation /libs/tools/send/send-ui/src/send-form/components/options/send-options.component.ts: 52 Attack Vector
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 82 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-browser.yml: 44 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 191 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 162 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-web.yml: 44 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 104 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 94 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-browser.yml: 408 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 141 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 515 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-browser.yml: 96 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 247 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /staged-rollout-desktop.yml: 29 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 248 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 499 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 222 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 342 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 181 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 48 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 267 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 187 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 297 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 194 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 297 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 405 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /retrieve-current-desktop-rollout.yml: 23 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 288 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-auto-bump.yml: 21 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 71 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /crowdin-pull.yml: 41 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 59 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 270 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 201 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 51 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 191 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 1339 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 44 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /brew-bump-desktop.yml: 26 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 44 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /crowdin-pull.yml: 35 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 245 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-web.yml: 57 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 507 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 523 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 891 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-browser.yml: 367 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 359 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 1293 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 196 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 668 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /release-web.yml: 41 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /version-bump.yml: 180 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 122 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 33.78378% with 49 lines in your changes missing coverage. Please review.

Project coverage is 33.16%. Comparing base (0377775) to head (f604aa1).
Report is 5 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...c/autofill/popup/settings/autofill-v1.component.ts 0.00% 18 Missing ⚠️
.../src/autofill/popup/settings/autofill.component.ts 0.00% 13 Missing ⚠️
...src/autofill/services/autofill-settings.service.ts 0.00% 11 Missing ⚠️
...wser/src/autofill/background/overlay.background.ts 0.00% 4 Missing ⚠️
...ofill/services/autofill-overlay-content.service.ts 82.35% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11260   +/-   ##
=======================================
  Coverage   33.16%   33.16%           
=======================================
  Files        2779     2779           
  Lines       86228    86291   +63     
  Branches    16421    16438   +17     
=======================================
+ Hits        28597    28619   +22     
- Misses      55365    55402   +37     
- Partials     2266     2270    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jprusik jprusik changed the title [PM-12345] Add type settings for inline autofill menu [PM-12345] Add cipher type settings for inline autofill menu Sep 26, 2024
@jprusik jprusik marked this pull request as draft September 26, 2024 20:22
@jprusik

This comment was marked as resolved.

@jprusik jprusik marked this pull request as ready for review September 27, 2024 15:20
danielleflinn
danielleflinn previously approved these changes Sep 27, 2024
Comment on lines +188 to +198
if (!this.inlineMenuVisibility) {
await this.getInlineMenuVisibility();
}

if (this.showInlineMenuCards == null) {
await this.getInlineMenuCardsVisibility();
}

if (this.showInlineMenuIdentities == null) {
await this.getInlineMenuIdentitiesVisibility();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ - We have a bit of an issue with how these settings are being referenced/stored.

If we cache these values, and a user changes the setting for showing inline menu cards/identities within their extension, we still retain the presentation of identities/cards on all fields until they refresh the page.

As a result of how we handle binding event listeners on each field, I think we're kind of forced to do a rebuild of the content script logic for each opened tab when the settings change. We do this for changes that happen to the inline menu visibility setting... and likely we need to do the same for these other settings.

Look at the implementation of AutofillService.handleInlineMenuVisibilityChange to see what we're doing when that setting is modified. Something similar needs to exist for the two now settings... either that, or we need to incorporate some extended logic to unset the listeners of identity or card fields separately (and reset the showAccountCreation element for login fields)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in 6463191

@jprusik jprusik marked this pull request as ready for review October 2, 2024 20:45
Comment on lines 3087 to 3092
tabs.forEach((tab) =>
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", {
settingType: cipherType,
newSettingValue,
}),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ - This effectively is undone/ignored by the following this.reloadAutofillScripts call.

Since we're triggering a reload of the content scripts after this, we are in effect trigger a re-init of the entirety of the autofill content script behavior. Updating the setting with a message is a throwaway action as a result of that re-init.

The reason why I originally set up the updateAutofillInlineMenuVisibility message was to avoid doing this expensive re-load of the scripts. In the current implementation, the inline menu visibility setting is referenced when the menu is opened... the update to that reference should only occur when we need to identify if we want to open the whole menu or just the button on focus.

If the setting is going from and disabled to enabled state (or vice versa), we are forced to trigger a re-injection of the scripts since we load different scripts depending on the visibility setting... otherwise we can just update that content script ref.

Now that said, I think the right call here is to remove the updateAutofillInlineMenuVisibility message when changing the identity or credit card inline menu settings and just trigger a reload of the script in either regard. The reason we'd want to do that is to ensure we reset the listeners present on all fields. We could implement the reset ourselves in a more optimal manner... but given that these settings aren't likely to be changed often, I think it's fine for us to reload the scripts entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tabs.forEach((tab) =>
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", {
settingType: cipherType,
newSettingValue,
}),
);

Suggestion, remove this entirely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 3072 to 3084
// If the setting change is for the behavior of overall inline menu display
if (cipherType == null) {
const inlineMenuPreviouslyDisabled = oldSettingValue === AutofillOverlayVisibility.Off;
const inlineMenuCurrentlyDisabled = newSettingValue === AutofillOverlayVisibility.Off;

if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) {
tabs.forEach((tab) =>
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", {
newSettingValue,
}),
);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If the setting change is for the behavior of overall inline menu display
if (cipherType == null) {
const inlineMenuPreviouslyDisabled = oldSettingValue === AutofillOverlayVisibility.Off;
const inlineMenuCurrentlyDisabled = newSettingValue === AutofillOverlayVisibility.Off;
if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) {
tabs.forEach((tab) =>
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", {
newSettingValue,
}),
);
return;
}
const inlineMenuPreviouslyDisabled = previousSetting === AutofillOverlayVisibility.Off;
const inlineMenuCurrentlyDisabled = currentSetting === AutofillOverlayVisibility.Off;
if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) {
const tabs = await BrowserApi.tabsQuery({});
tabs.forEach((tab) =>
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", {
inlineMenuVisibility: currentSetting,
}),
);
return;

Suggestion - revert this logic, only triggering an update when the actual inline menu visibility is modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private async handleInlineMenuVisibilitySettingsChange(
oldSettingValue: InlineMenuVisibilitySetting | boolean,
newSettingValue: InlineMenuVisibilitySetting | boolean,
cipherType?: CipherType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cipherType?: CipherType,

Suggestion - Remove this, it likely isn't necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.handleInlineMenuVisibilitySettingsChange(
previousSetting,
currentSetting,
CipherType.Identity,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CipherType.Identity,

Suggestion - Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.handleInlineMenuVisibilitySettingsChange(
previousSetting,
currentSetting,
CipherType.Card,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CipherType.Card,

Suggestion - Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 1366 to 1388
const settingNewValue = data?.newSettingValue;

if (settingNewValue == null) {
return;
}

const settingType = data?.settingType;

// Setting value update is for overall inline menu visibility
if (settingType == null && !isNaN(settingNewValue as InlineMenuVisibilitySetting)) {
this.inlineMenuVisibility = settingNewValue as InlineMenuVisibilitySetting;

return;
}

if (typeof settingType === "boolean") {
if (settingType === CipherType.Card) {
this.showInlineMenuCards = settingNewValue as boolean;
}

if (settingType === CipherType.Identity) {
this.showInlineMenuIdentities = settingNewValue as boolean;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const settingNewValue = data?.newSettingValue;
if (settingNewValue == null) {
return;
}
const settingType = data?.settingType;
// Setting value update is for overall inline menu visibility
if (settingType == null && !isNaN(settingNewValue as InlineMenuVisibilitySetting)) {
this.inlineMenuVisibility = settingNewValue as InlineMenuVisibilitySetting;
return;
}
if (typeof settingType === "boolean") {
if (settingType === CipherType.Card) {
this.showInlineMenuCards = settingNewValue as boolean;
}
if (settingType === CipherType.Identity) {
this.showInlineMenuIdentities = settingNewValue as boolean;
}
if (!isNaN(data?.inlineMenuVisibility)) {
this.inlineMenuVisibility = data.inlineMenuVisibility;

Suggestion - Revert this, in effect the script reload that is happening when the inline menu cards and inline menu identities setting is changed will handle the expected change to happen on the content script side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 27 to 28
settingType?: CipherType;
newSettingValue?: InlineMenuVisibilitySetting | boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settingType?: CipherType;
newSettingValue?: InlineMenuVisibilitySetting | boolean;
inlineMenuVisibility?: InlineMenuVisibilitySetting;

Suggestion - Revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jprusik
Copy link
Contributor Author

jprusik commented Oct 3, 2024

cagonzalezcs
cagonzalezcs previously approved these changes Oct 3, 2024
@jprusik jprusik removed the needs-qa Marks a PR as requiring QA approval label Oct 15, 2024
@jprusik jprusik merged commit 1c2cb44 into main Oct 15, 2024
67 of 69 checks passed
@jprusik jprusik deleted the pm-12345 branch October 15, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants