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

Protect: Handle unavailable scan status #27408

Merged

Conversation

dkmyta
Copy link
Contributor

@dkmyta dkmyta commented Nov 14, 2022

Fixes #
In a number of scenarios where we can determine with certainty that an appropriate scan level plan is present, but the scan module is not currently available (either due to a provisioning delay or an error), we are presented with an unavailable status that we do not yet have handling for.

Changes proposed in this Pull Request:

  • Adds a setScanIsUnavailable action
  • Adds a checkStatus action
  • Updates the refreshStatus action to use checkStatus where applicable
  • Updates the AdminPage component to react accordingly

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

Jetpack product discussion

  • 1201069996155224-as-1203341574761581

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

  • Checkout this branch
  • Manually set $status->status to unavailable by adding the following to line 69-70 in src/class-status.php (ensure jetpack watch plugins/protect is running):
self::$status->status = 'unavailable';
self::$status->last_checked = null;
  • Fire up Jurassic Tube and ensure you have a scan-level upgrade
  • Activate Protect and proceed to the admin page
  • Verify that you initially see the in-progress screen and after 10-15s the following error screen is displayed:

Screen Shot 2022-11-15 at 09 16 20

  • Open your browser Developer Tools and proceed to the Network tab
  • Refresh the page, and verify that an initial status?hard_refresh=true request is sent, followed by an additional three attempts while the in-progress screen is displayed before eventually resolving the error screen
  • Remove the lines added to src/class-status.php, ensure watch runs, and refresh the page
  • Ensure the expected content display and there are no regressions in app functionality

@dkmyta dkmyta changed the base branch from add/scan-in-protect to fix/protect-plan-check November 14, 2022 22:37
@github-actions github-actions bot added [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Status] In Progress labels Nov 14, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • 🔴 Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


🔴 Action required: Please add missing changelog entries for the following projects: projects/plugins/protect

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Guidelines: /docs/writing-a-good-changelog-entry.md


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Protect plugin:

  • Next scheduled release: December 6, 2022.
  • Scheduled code freeze: November 28, 2022.

@dkmyta dkmyta marked this pull request as ready for review November 15, 2022 21:46
@dkmyta dkmyta requested a review from a team November 15, 2022 21:46
@nateweller nateweller force-pushed the fix/protect-handle-unavailable-scan-status branch from 80cb8d1 to 01f9855 Compare November 15, 2022 21:51
@dkmyta dkmyta force-pushed the fix/protect-handle-unavailable-scan-status branch from 01f9855 to 80cb8d1 Compare November 15, 2022 21:57
Copy link
Contributor

@nateweller nateweller left a comment

Choose a reason for hiding this comment

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

Looks great, really awesome work 👍

Lets merge this after #27355, just so this code doesn't end up in the diff of that PR.

The lock files test is failing, but we'll fix all of that up in the main project branch.

Co-authored-by: Nate Weller <nate.weller@automattic.com>
Base automatically changed from fix/protect-plan-check to add/scan-in-protect November 16, 2022 05:42
@nateweller nateweller merged commit ce6be2f into add/scan-in-protect Nov 16, 2022
@nateweller nateweller deleted the fix/protect-handle-unavailable-scan-status branch November 16, 2022 05:43
@nateweller nateweller mentioned this pull request Nov 16, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants