Skip to content

[BB-6041] Convert password compliance warning to html - #30130

Merged
mariajgrimaldi merged 3 commits into
openedx:masterfrom
open-craft:pooja/convert-warning-back-to-html
May 9, 2022
Merged

[BB-6041] Convert password compliance warning to html#30130
mariajgrimaldi merged 3 commits into
openedx:masterfrom
open-craft:pooja/convert-warning-back-to-html

Conversation

@pkulkark

Copy link
Copy Markdown
Contributor

Description

This PR converts the password compliance warning message back to HTML. It was converted to string as part of additional security but that resulted in HTML attributes not being applied while displaying the warning message.

Jira tickets: BB-6041

Screenshots:

Before fix:
esme-password-warning

After fix:
esme-stage-warning-after-fix

Testing instructions

  1. Checkout this branch and setup a minimum password length validator, enable compliance on login and set a deadline.
  2. Register or login with a password that doesn't meet the password requirement.
  3. Verify the warning message shown is formatted correctly.

Reviewers:

TBD

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Mar 26, 2022
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @pkulkark! I've created OSPR-6546 to keep track of it in JIRA, where we prioritize reviews. 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.

@DubeySandeep DubeySandeep left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pkulkark Thanks for the PR, I took a quick pass on the code changes and left a comment/question, PTAL!

except password_policy_compliance.NonCompliantPasswordException as e:
# Prevent the login attempt.
raise ValidationError(str(e)) # lint-amnesty, pylint: disable=raise-missing-from
raise ValidationError(HTML(str(e))) # lint-amnesty, pylint: disable=raise-missing-from

@DubeySandeep DubeySandeep Mar 26, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(not sure!) Instead of converting the string to HTML should just use the e which is already an HTML object? (ref)

Also, it makes sense for the NonCompliantPasswordWarning exception to handle the format/structure of the message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@DubeySandeep The str was added as part of a XSS security fix (as far as I can remember), so I'm hesitant to remove it. Keeping it would add an extra layer of security and doesn't really affect the performance much.

@DubeySandeep DubeySandeep Mar 27, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, but earlier it was str(HTML(str)) and now it's HTML(str(HTML(str))), I think this will again raise the XSS issue (in case it existed before)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The existing str(HTML) should take care of escaping problematic HTML tags. So it won't be converted back next time. The same has been done at https://github.com/openedx/edx-platform/blob/557f58c341710d2d03c2a491e6141276d15823b1/openedx/core/djangoapps/user_authn/views/login.py#L200.

@mariajgrimaldi

mariajgrimaldi commented Mar 29, 2022

Copy link
Copy Markdown
Member

Hi there @natabene, can you assign this to me? I can't modify the OSPR Jira dashboard.

@DubeySandeep DubeySandeep left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code changes in the PR LGTM!

@natabene

Copy link
Copy Markdown
Contributor

@pkulkark Thank you for your contribution. @mariajgrimaldi Thanks for volunteering! @wajeeha-khalid Do you mind if @mariajgrimaldi reviews and merges this?

@wajeeha-khalid

wajeeha-khalid commented Apr 21, 2022

Copy link
Copy Markdown
Contributor

sorry for delay; I had been out vacationing and saw this only now.

@waheedahmed can you please review this to confirm this aligns with our understanding of compliance and security for interjection of tags.

@waheedahmed waheedahmed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me 👍

@natabene

Copy link
Copy Markdown
Contributor

@mariajgrimaldi We got green light from the owning team, so this is all yours now.

@mariajgrimaldi

Copy link
Copy Markdown
Member

Hi @natabene! Thanks for letting me know.

I've followed your testing instructions, and everything is working as expected, @pkulkark 🥳. Some tests are not running though (they seem duplicated), can you rebase and trigger them again?

@pkulkark

Copy link
Copy Markdown
Contributor Author

Thanks @mariajgrimaldi. I've rebased to latest master.

@mariajgrimaldi
mariajgrimaldi merged commit aacfb39 into openedx:master May 9, 2022
@openedx-webhooks

Copy link
Copy Markdown

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

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged open-source-contribution PR author is not from Axim or 2U

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants