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

Site Settings: Add Jetpack Firewall Toggle to Security Settings Screen #91966

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

nateweller
Copy link
Contributor

@nateweller nateweller commented Jun 19, 2024

Related to https://github.com/Automattic/jetpack-scan-team/issues/1228

Depends on https://github.com/Automattic/jetpack-scan-team/issues/1321

Proposed Changes

  • Adds a "Web Application Firewall (WAF)" setting card to /settings/security/[site].
  • If the user does not have access to automatic rules, an upgrade prompt is displayed.
  • Merges the Brute Force Protection and IP Allow List settings into the new Firewall card.

Why are these changes being made?

  • See peb6dq-2v0-p2

Testing Instructions

  • Check out this PR in your local Jetpack repo: WAF: Options Improvements jetpack#38580
  • Boot up your local monorepo site with jetpack docker up -d and jetpack docker jt-up
  • Visit your site's wp-admin and ensure Jetpack is connected
  • Test this PR using the Calypso live link below, and your local test site running through Jurassic Tube.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

Screenshots

Screenshot 2024-07-23 at 6 01 43 PM Screenshot 2024-07-23 at 6 03 52 PM

@matticbot
Copy link
Contributor

matticbot commented Jun 19, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~1738 bytes added 📈 [gzipped])

name                             parsed_size           gzip_size
settings-security                    +6943 B  (+1.5%)    +1543 B  (+1.1%)
write-flow                             +12 B  (+0.0%)      +16 B  (+0.0%)
videopress-flow                        +12 B  (+0.0%)      +16 B  (+0.0%)
themes                                 +12 B  (+0.0%)      +12 B  (+0.0%)
theme                                  +12 B  (+0.0%)      +20 B  (+0.0%)
staging-site                           +12 B  (+0.0%)      +12 B  (+0.0%)
settings-podcast                       +12 B  (+0.0%)      +21 B  (+0.0%)
settings-performance                   +12 B  (+0.0%)      +15 B  (+0.0%)
settings                               +12 B  (+0.0%)      +19 B  (+0.0%)
posts-custom                           +12 B  (+0.0%)      +16 B  (+0.0%)
posts                                  +12 B  (+0.0%)      +16 B  (+0.0%)
plugins                                +12 B  (+0.0%)      +12 B  (+0.0%)
media                                  +12 B  (+0.0%)      +16 B  (+0.0%)
marketing                              +12 B  (+0.0%)      +19 B  (+0.0%)
link-in-bio-tld-flow                   +12 B  (+0.0%)      +16 B  (+0.0%)
jetpack-cloud-plugin-management        +12 B  (+0.0%)      +12 B  (+0.0%)
hosting                                +12 B  (+0.0%)      +12 B  (+0.0%)
earn                                   +12 B  (+0.0%)      +21 B  (+0.0%)
domains                                +12 B  (+0.0%)      +21 B  (+0.0%)
build-flow                             +12 B  (+0.0%)      +16 B  (+0.0%)
activity                               +12 B  (+0.0%)      +15 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~133 bytes added 📈 [gzipped])

name                                                     parsed_size           gzip_size
async-load-design-blocks                                       +12 B  (+0.0%)      +16 B  (+0.0%)
async-load-calypso-reader-sidebar                              +12 B  (+0.0%)      +17 B  (+0.0%)
async-load-calypso-post-editor-editor-media-modal              +12 B  (+0.0%)      +15 B  (+0.0%)
async-load-calypso-my-sites-stats-summary                      +12 B  (+0.0%)      +18 B  (+0.1%)
async-load-calypso-my-sites-current-site-notice                +12 B  (+0.0%)      +13 B  (+0.1%)
async-load-calypso-components-web-preview-component            +12 B  (+0.0%)      +16 B  (+0.0%)
async-load-calypso-blocks-jitm-templates-sidebar-banner        +12 B  (+0.0%)      +19 B  (+0.1%)
async-load-calypso-blocks-jitm-templates-notice                +12 B  (+0.0%)      +16 B  (+0.1%)
async-load-calypso-blocks-jitm-templates-default               +12 B  (+0.0%)      +19 B  (+0.1%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@nateweller nateweller force-pushed the add/jetpack-firewall-settings branch 6 times, most recently from c8e64a8 to 432b9dd Compare July 26, 2024 20:22
@nateweller nateweller force-pushed the add/jetpack-firewall-settings branch from 432b9dd to 6023197 Compare July 28, 2024 22:00
@nateweller nateweller requested a review from a team July 28, 2024 22:06
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 28, 2024
@nateweller nateweller marked this pull request as ready for review July 28, 2024 22:07
Copy link
Contributor

@dkmyta dkmyta left a comment

Choose a reason for hiding this comment

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

Looks and works great, with the exception the Akismet UI glitch hijacking the save, returning an error notice and not immediately reflecting the new toggle state as we discussed.

Settings updates are working and are reflected in both the Jetpack and/or Protect UIs appropriately and vice-versa. Upgrading and downgrading performs as expected and the UIs are updated accordingly.

One thing I did notice as a potential discussion point, when viewing these settings for an unsupported site, the toggles are just disabled rather than hidden as they are in the other UIs. I realize this is a difficult scenario because the BFP and Allow list settings are baked into the WAF card, but I think it may raise the question "why can I not enable these?". If hiding them is not a valid solution, perhaps we should add a notice of some sort for clarification? Thoughts?

@nateweller
Copy link
Contributor Author

nateweller commented Jul 29, 2024

One thing I did notice as a potential discussion point, when viewing these settings for an unsupported site, the toggles are just disabled rather than hidden as they are in the other UIs. I realize this is a difficult scenario because the BFP and Allow list settings are baked into the WAF card, but I think it may raise the question "why can I not enable these?". If hiding them is not a valid solution, perhaps we should add a notice of some sort for clarification? Thoughts?

I'm not sure exactly where this is happening yet, each toggle should be conditionally rendered based on the value of wafModuleSupported() method in firewall.jsx:

! this.props.isAtomic && ! this.props.isVip

When a toggle is rendered but disabled, the logic is more complex:

! this.props.isAtomic && ! this.props.isVip || isRequestingSettings || isSavingSettings || moduleDetailsNotLoaded || ( siteInDevMode && moduleUnavailableInDevMode )

Do you know what your state would have looked like roughly, when the toggles are disabled but still being rendered on the page?

Toggles should be disabled briefly while loading, and the automatic rules toggle should be disabled when the user has no active plan but older automatic rules available. Otherwise if something isn't available, it should be hidden - but that may not be the case if this can be reproduced.

@dkmyta
Copy link
Contributor

dkmyta commented Jul 29, 2024

Do you know what your state would have looked like roughly, when the toggles are disabled but still being rendered on the page?

Using a Pressable site, the toggles display as follows for the Security Settings page:
Screen Shot on 2024-07-29 at 13-03-05

I would've expected a Pressable site to fall within the this.props.isAtomic category, but for some reason is not currently recognized by that check.

@nateweller nateweller requested a review from dkmyta July 30, 2024 00:12
Copy link
Contributor

@dkmyta dkmyta left a comment

Choose a reason for hiding this comment

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

Works great if Akismet is activated, but that is a separate/existing issue that will hopefully be resolved external to this.

Every scenario I could think of testing is now accounted for with one minor exception to provide for perfect parity. When in an unsupported environment we now only display the BFP and Allow list toggles, in Jetpack/Protect we disable the Allow list if BFP is disabled as it has no usage outside of that scenario.
Screen Shot on 2024-07-30 at 08-57-43

In Calypso we still allow it to be toggled and entries added.
Screen Shot on 2024-07-30 at 08-57-32

If we pursue this change, I think we may need to also ensure this is the case in the backward compatible version if that is at all handled uniquely.

@nateweller
Copy link
Contributor Author

@dkmyta What do you think about leaving the IP allow list available when the firewall/login protection features are turned off? My thinking being that you may want to allow list your own address prior to turning back on one of the features.

Perhaps we can sync up on how to present different WAF settings (i.e. show lists vs disable them when toggled off, disable or hide allow list when other features off, etc) with design during our meetup?

My proposal then being, let's merge this and follow up more broadly 😅

@dkmyta dkmyta self-requested a review July 31, 2024 18:06
@nateweller nateweller merged commit 8b68a70 into trunk Aug 6, 2024
13 checks passed
@nateweller nateweller deleted the add/jetpack-firewall-settings branch August 6, 2024 20:14
@github-actions github-actions bot removed [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Aug 6, 2024
@a8ci18n
Copy link

a8ci18n commented Aug 6, 2024

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/16462881

Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @nateweller for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Aug 14, 2024

Translation for this Pull Request has now been finished.

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.

4 participants