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

Sanitise HTML in long description of enterprise [read-only] #12470

Merged
merged 3 commits into from
May 15, 2024

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented May 14, 2024

ℹ️ Please use project Discover Regenerative (Macdoch pt 2): 3. Open Source Tech Evolution to track work on this issue.

What? Why?

We weren't sanitising the HTML of long enterprise descriptions at all. So here's a remedy that sanitises the field before it's reaching the database. All consumers, including API users should now get sanitised HTML.

There are more attributes like this listed in the issue. But I wanted to get this through faster and get a review first before I apply the same approach to the other three fields.

What should we test?

  • Visit Admin, Enterprise settings, About and edit the long description with the editor.
  • Everything you do with the editor should save and show in the frontend.
  • I don't know an easy way to simulate the attacker scenario. But I think that my approach with those unit tests is pretty safe.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

This happens only on assignment. We still need to migrate existing data.
We will add a migration to sanitise all existing descriptions but before
we do that destructive action, it's good to test this in a read-only
fashion first.
They do appear in long_description on au_prod.
@mkllnk mkllnk added the user facing changes Thes pull requests affect the user experience label May 14, 2024
@mkllnk mkllnk self-assigned this May 14, 2024
@mkllnk mkllnk marked this pull request as ready for review May 14, 2024 03:33
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

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

Great!

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Nice one !

@filipefurtad0 filipefurtad0 self-assigned this May 15, 2024
@filipefurtad0 filipefurtad0 added the pr-staged-fr staging.coopcircuits.fr label May 15, 2024
@filipefurtad0
Copy link
Contributor

Hey @mkllnk ,
I can confirm this works as before:

image

(I'm also not sure how to simulate such attacks - that's would be a very useful skill, in testing.)

Merging!

@filipefurtad0 filipefurtad0 merged commit a854775 into openfoodfoundation:master May 15, 2024
54 checks passed
@dacook
Copy link
Member

dacook commented May 15, 2024

Unless there's a vulnerability in the text editor, I think the only way is to manually submit a value with a tool like Postman. You could use some of the html examples in the specs provided by this PR.
But of course, those specs pass so we can be pretty confident already. At least that's why I didn't suggest further testing :)

@mkllnk mkllnk deleted the description-html-test branch May 16, 2024 00:01
@sigmundpetersen sigmundpetersen removed the pr-staged-fr staging.coopcircuits.fr label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants