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

Replace bleach with nh3 #3696

Merged
merged 12 commits into from
Mar 11, 2024
Merged

Replace bleach with nh3 #3696

merged 12 commits into from
Mar 11, 2024

Conversation

wes-otf
Copy link
Contributor

@wes-otf wes-otf commented Dec 15, 2023

Fixes #3693

Aims to fully replace bleach with nh3 due to bleach deprecation. Currently, django-nh3 is in it's infancy, but seems like it could be an almost drop in replacement for django-bleach, for I forked it and made some small additions that would allow it to work for our purposes and be smoothly migrated.

Initial smoke testing in Hypha seems to work exactly as bleach did but needs more extensive testing. Ideally I would smooth out some edges of my fork and put in a PR to django-nh3. Let me know any thoughts/questions!

@frjo
Copy link
Contributor

frjo commented Dec 16, 2023

Nice work getting a start on this. Ammonia say they are 20 times faster then Bleach, that should shave of a number of milli seconds for nearly every request.

Would be good to upstream the changes if they are generally useful.

I see you added code to pick up any BLEACH_* settings. Is this needed? We control the default settings in Hypha.

Other instances might have set their own values but the release notes and the docs can inform them of the need to update the settings.

I prefer to be explicit, remove every mention of BLEACH from the code so there is no confusion about what we are using. The settings are complex and confusing as it is :-).

@wes-otf
Copy link
Contributor Author

wes-otf commented Dec 18, 2023

Thanks for taking a look! I'm looking forward to seeing the stats once it's implemented, should be significant.

I see you added code to pick up any BLEACH_* settings. Is this needed? We control the default settings in Hypha.

I did this only really with the upstream in mind, I wasn't totally sure if other adopters would've wanted somewhat of a drop-in solution but realistically I think you're totally right in the fact that it only adds complexity and confusion so I'll strip that out.

Hoping to iron out some unit tests I have locally on my fork then going to be putting up a PR. Should be cool!

@wes-otf
Copy link
Contributor Author

wes-otf commented Dec 19, 2023

All unit tests (both in Hypha & in django-nh3) are passing and functionality looks good! Once/if this gets merged upstream, the only thing left is to swap out the custom github link in requirements.txt. My PR to django-nh3 can be found here: marksweb/django-nh3#16

@wes-otf
Copy link
Contributor Author

wes-otf commented Dec 19, 2023

Upstream is all merged, should be good to go!

@wes-otf wes-otf changed the title WIP: Replace bleach with nh3 Replace bleach with nh3 Dec 19, 2023
@wes-otf wes-otf marked this pull request as ready for review December 19, 2023 23:08
@frjo
Copy link
Contributor

frjo commented Dec 20, 2023

@wes-otf Excellent work on the upstream PR! I noticed a contribution from Torchbox/Wagtail people as well so they are looking at using nh3 as well.

This functionality is core to Hypha security since we filter on output, not on input. (It is a long term goal to change this.) Therefor I do not want to rush in to deploying this, especially since the django-nh3 package is so fresh.

What do you think?

@wes-otf
Copy link
Contributor Author

wes-otf commented Dec 20, 2023

@frjo I totally agree. Especially with the long term deprecation plan for bleach I don't see any reason to jump into this without some exhaustive user testing. Totally fine waiting to merge this in the new year.

@frjo frjo added Type: Maintenance Type: Minor Minor change, used in release drafter labels Jan 10, 2024
@wes-otf
Copy link
Contributor Author

wes-otf commented Feb 6, 2024

@frjo What are you thinking on the timeline for this? Once we get everything all set with the public stuff we could let the user testing group give this a go and ensure nothing weird changed.

@@ -57,7 +57,8 @@
"django_filters",
"django_select2",
"addressfield",
"django_bleach",
# "django_bleach",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line can be deleted.

@frjo
Copy link
Contributor

frjo commented Feb 7, 2024

@wes-otf There are some public pages that gets re-added by mistake in this PR.

My concern regarding timeline is that the django-nh3 package is very new. On the other hand it is a simple wrapper and this PR touch a lot of files and will likely get a lot of merge conflicts if we have it hanging around.

I suggest we make v5.4.0 with all the public go out first. Then we work to get this in to the next release.

@wes-otf
Copy link
Contributor Author

wes-otf commented Feb 7, 2024

Good catch! That was the result of a sloppy merge on my part. That timeline sounds good though - the continuous merge conflicts were also my worry so I think that'll work nice.

@frjo frjo added the Status: RTBC Internal Dev use only label Feb 15, 2024
@frjo
Copy link
Contributor

frjo commented Feb 22, 2024

@wes-otf Can you rebase this? Then we can put it on test and get it in before more rebases are needed.

hypha/apply/funds/differ.py Outdated Show resolved Hide resolved
@frjo frjo removed the Status: RTBC Internal Dev use only label Feb 22, 2024
@frjo frjo added the Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team label Feb 22, 2024
@frjo frjo added the Status: Needs testing Tickets that need testing/qa label Mar 4, 2024
@frjo frjo merged commit 90703c4 into main Mar 11, 2024
10 checks passed
@theskumar theskumar deleted the maintainance/replace-bleach-with-nh3 branch March 21, 2024 18:41
wes-otf added a commit that referenced this pull request May 7, 2024
Fixes #3693 

Aims to fully replace bleach with nh3 due to bleach deprecation.
Currently, [django-nh3](https://github.com/marksweb/django-nh3) is in
it's infancy, but seems like it could be an almost drop in replacement
for [django-bleach](https://github.com/marksweb/django-bleach), for I
[forked it](https://github.com/wes-otf/django-nh3) and made some small
additions that would allow it to work for our purposes and be smoothly
migrated.

Initial smoke testing in Hypha seems to work exactly as bleach did but
needs more extensive testing. Ideally I would smooth out some edges of
my fork and put in a PR to django-nh3. Let me know any
thoughts/questions!
wes-otf added a commit that referenced this pull request May 8, 2024
Fixes #3693 

Aims to fully replace bleach with nh3 due to bleach deprecation.
Currently, [django-nh3](https://github.com/marksweb/django-nh3) is in
it's infancy, but seems like it could be an almost drop in replacement
for [django-bleach](https://github.com/marksweb/django-bleach), for I
[forked it](https://github.com/wes-otf/django-nh3) and made some small
additions that would allow it to work for our purposes and be smoothly
migrated.

Initial smoke testing in Hypha seems to work exactly as bleach did but
needs more extensive testing. Ideally I would smooth out some edges of
my fork and put in a PR to django-nh3. Let me know any
thoughts/questions!
Vldln pushed a commit to equalitie/hypha that referenced this pull request May 28, 2024
Fixes HyphaApp#3693 

Aims to fully replace bleach with nh3 due to bleach deprecation.
Currently, [django-nh3](https://github.com/marksweb/django-nh3) is in
it's infancy, but seems like it could be an almost drop in replacement
for [django-bleach](https://github.com/marksweb/django-bleach), for I
[forked it](https://github.com/wes-otf/django-nh3) and made some small
additions that would allow it to work for our purposes and be smoothly
migrated.

Initial smoke testing in Hypha seems to work exactly as bleach did but
needs more extensive testing. Ideally I would smooth out some edges of
my fork and put in a PR to django-nh3. Let me know any
thoughts/questions!
@frjo frjo removed Status: Needs testing Tickets that need testing/qa Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Maintenance Type: Minor Minor change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace bleach due to depreciation
2 participants