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

Add rel=”noopener” to target="_blank" links to appease CodeQL. #4463

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

martinemde
Copy link
Member

In #4462, CodeQL is making noise about target="_blank" links without rel="noopener". I added it here to quiet CodeQL in future PRs. I doubt that any self respecting client is actually breaking this rule, but might as well.

It has also been suggested, and we do this in a few places, to add noreferrer as in rel="noopener noreferrer". I don't think it's necessary as long as CodeQL is fine with it.

For email, I suggest that we remove the target attribute entirely and allow the email client to do its thing.

What do you think? Should we...

  1. Remove target="_blank" from emails and let the client do it's thing.
  2. Leave it and add the rel="noopener" so CodeQL will work.

@martinemde
Copy link
Member Author

martinemde commented Feb 18, 2024

CodeQL explicitly says "or" but it's requiring "and".

HTML links that open in a new tab or window allow the target page to access the DOM of the origin page using window.opener unless link type noopener or noreferrer is specified. This is a potential security risk.

Copy link

codecov bot commented Feb 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (89b2171) 97.13% compared to head (195f0bc) 97.13%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4463   +/-   ##
=======================================
  Coverage   97.13%   97.13%           
=======================================
  Files         385      385           
  Lines        8200     8200           
=======================================
  Hits         7965     7965           
  Misses        235      235           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martinemde
Copy link
Member Author

It only trips up on links with href="<%= %>". This seems like a codeql bug.

@martinemde
Copy link
Member Author

martinemde commented Feb 18, 2024

oh no, I ended up with fancy quotes in here somehow. Very strange. This was the cause of CodeQL not understanding the rel attribute

@martinemde martinemde force-pushed the martinemde/rel-noopener branch from 6357c86 to 215e908 Compare February 18, 2024 17:52
@martinemde martinemde force-pushed the martinemde/rel-noopener branch from 215e908 to 195f0bc Compare February 18, 2024 17:52
@martinemde martinemde requested a review from segiddins February 18, 2024 22:45
@martinemde martinemde merged commit bf6c767 into master Feb 19, 2024
17 checks passed
@martinemde martinemde deleted the martinemde/rel-noopener branch February 19, 2024 01:08
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.

2 participants