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

Remove inline styles from job listings #15637

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

janbrasna
Copy link
Contributor

@janbrasna janbrasna commented Dec 3, 2024

One-line summary

This bleaches inline styles in Greenhouse API sync, to avoid unsafe-inline style CSP violations (and unblock moving that to enforced policies…)

Significant changes and points to review

Currently almost all the styles from the original listing data (align, color etc.) are removed already, leaving only either empty style="" behind, or a font-weight: 400 that is the default anyways. So it can be removed completely.

(It will have to go through data sync cron first to update in prod.)

Issue / Bugzilla link

Resolves #15633 (& refs #14840)

Testing

python manage.py sync_greenhouse

(in my case, in containerized env, it was actually make clean build run followed by make shell in another session with the management command run from there…)

http://localhost:8000/en-US/careers/position/gh/6135741/
http://localhost:8000/en-US/careers/position/gh/6393976/

@janbrasna janbrasna marked this pull request as ready for review December 3, 2024 20:10
@janbrasna janbrasna requested a review from a team as a code owner December 3, 2024 20:10
@@ -78,7 +73,6 @@ def __iter__(self):
cleaner = bleach.sanitizer.Cleaner(
tags=ALLOWED_TAGS,
attributes=ALLOWED_ATTRS,
css_sanitizer=CSSSanitizer(allowed_css_properties=ALLOWED_STYLES),
Copy link
Member

Choose a reason for hiding this comment

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

This is good. Did we want to consider removing class attributes as well? Since, the ones I saw reference classes that don't exist on bedrock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea they have the "gmail_default" there on the container… but it's at least to grab the content in DOM if needed, so I didn't bother to xcheck all the content it's not actually breaking anything… (will grep/sed again and check what classes are there at all)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the most common classes are: external-link, content-pay, pay-input, description, title, pay-range, divider, etc. … so I'd probably keep them in, in case they'd need to be targeted at some point?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for double-checking.

@robhudson robhudson merged commit cdd16b6 into mozilla:main Dec 4, 2024
5 checks passed
@janbrasna janbrasna deleted the fix/jobs-csp-inline branch December 4, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Greenhouse import should strip inline styles
2 participants