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

fix: remove the exclusion of NonceVerification in phpcs and fix the issues #67

Merged
merged 4 commits into from
Mar 7, 2024

Conversation

MaferMazu
Copy link
Contributor

@MaferMazu MaferMazu commented Jan 19, 2024

Description

This PR:

  • Adds nonces in the forms of our plugin (settings, enrollment, product and order).
  • Removes the exclusion of the WordPress.Security.NonceVerification.Missing alert.
  • Changes the action save_post_shop_order to woocommerce_update_order.

Testing instructions

  • Check the tests are passing: To know if we are following the WordPress standards without avoiding alerts.
  • Check if the plugin works as expected in WordPress: Principally the workflows
    • Save and update the plugin settings (Reference image)
    • Create or edit a manual enrollment. (Reference)
    • Create or edit an Open edX course product (Reference)
    • Create or edit a WooCommerce Order with an Open edX course product and change the Enrollment associated.

The expected result is that the forms are saved correctly (if the nonce_verification fails, the save or update won't store the new information).

Credentials for the stage to test: https://share.1password.com/s#Pu505pb8w5wyFnHuHhvHBg4K1B5VIHk69kK0O-mCy9s

Additional information

  • This change favors publishing this plugin in the WordPress org and following the WordPress PHPCS standards.
  • I changed save_post_shop_order to woocommerce_update_order because the first one was preventing me from saving the order extra information.

More references related:

Checklist for Merge

  • Tested in a remote environment (I tested all the workflows mentioned and the full shopping workflow)
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jan 19, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Jan 19, 2024

Thanks for the pull request, @MaferMazu! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@MaferMazu MaferMazu force-pushed the mfmz/nonce-verification branch 5 times, most recently from f7c9558 to ae1bd3c Compare February 2, 2024 00:11
@MaferMazu MaferMazu force-pushed the mfmz/nonce-verification branch from ae1bd3c to 42d04ff Compare February 6, 2024 00:04
@MaferMazu MaferMazu force-pushed the mfmz/nonce-verification branch from 42d04ff to bd30514 Compare February 6, 2024 00:06
@MaferMazu MaferMazu marked this pull request as ready for review February 7, 2024 03:31
@MaferMazu
Copy link
Contributor Author

This is ready for review, @feanil and @felipemontoya. This PR solves the first issue from Wordpress.org related to the PHPCS and WordPress Standards, and the error logs they sent us are in the attached file.

If you have any questions or feedback, please don't hesitate to contact me.

Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

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

The PR seems very reasonable to me. Adding nonces for security of the form submissions looks good.

I don't have an environment to test this so we depend on the testing that you are doing locally or in the remote staging. How did that go?

phpcs.xml Show resolved Hide resolved
@MaferMazu
Copy link
Contributor Author

MaferMazu commented Feb 12, 2024

@felipemontoya, I tested locally and in our stage. You can test it by entering the stage with these credentials and checking if the forms correctly store the info you change (If the nonce doesn't work, they don't store the info), and check if you are receiving the nonce variable (In inspect searching the nonce variable related to that form).

View Nonce related How to test
Product (edit an Open edX course product field) openedx_commerce_custom_product_nonce Create or edit an Open edX course product (Reference)
Order (Enrollment request related to the order) openedx_commerce_order_item_nonce Create or edit a WooCommerce Order with an Open edX course product and change the Enrollment associated.
Enrollment Request Form openedx_commerce_enrollment_form_nonce Create or edit a manual enrollment. (Reference)
Plugin settings openedx_commerce_new_token_nonce Save and update the plugin settings (Reference image)

Example:
image
image

Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

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

Sorry to take so long. I tested the code in the staging server and it's working correctly.
We can go ahead with merging this to move forward with the wordpress plugin index publication

@felipemontoya
Copy link
Member

@MaferMazu I came back to this and notice my review is not approving. Maybe we need a green check from @feanil to be able to merge.

@feanil
Copy link
Contributor

feanil commented Mar 7, 2024

@felipemontoya thanks, just approved but also maybe it makes sense for you to be a CC on this repo? do you want to post for some rights expansion?

@MaferMazu MaferMazu merged commit 645a92d into openedx:main Mar 7, 2024
5 checks passed
@openedx-webhooks
Copy link

@MaferMazu 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants