-
Notifications
You must be signed in to change notification settings - Fork 90
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
Display test context code without rendering HTML #34
Comments
Can you show me an example of the context you are passing, how it is rendering and what you expect the output to be? Also I wouldn't think there's a ton of risk with XSS here since the reports are static files. Do you have an example of how you think the report could be used for XSS attacks? |
I'm actually passing in a raw HTTP response body in the context. This would contain HTTP headers as well as the actual HTML content, so I was kinda surprised that the HTML was actually rendering. This wouldn't be a problem, except when you have intentionally malformed HTML tags, which might cut off the rest of the content, or if you intended to have HTML tags appear as code in your context. This is an example of how I would expect it to render (except the syntax highlighting, but that's another issue): Instead, this is what I'm getting: Notice the "malformed" script tag in the HTTP request context (actually URL encoded), which caused the rest of the contents of the context I am actually using Mocha to write XSS test cases, which might explain how I find that doing Hence, I just wanted to check what was your rationale for using I think that a further enhancement to contexts in general would be to allow a third, explicit context type parameter, rather than guessing whether it is meant to be code or meant to be a string. It's a little ugly for sentences to have way-off syntax highlighting applied to it, and could be better displayed with Furthermore, we can bring it one step further to allow the user to pass in the exact syntax highlighter to use (like how GitHub-flavoured Markdown allows you to set the language of a code block), though it's highly likely most users will only require JS syntax highlighting. For completion's sake, this is the exact HTML that is being rendered in Google Chrome (which probably automatically added a closing <code>GET http:<span class="hljs-comment">//REDACTED/dvwa/vulnerabilities/xss_r/?name=</span><script><span class="hljs-comment">alErt%281%29<%2FscrIpt> HTTP/1.1</span>
HOST: REDACTED
Connection: keep-alive
Accept: *<span class="hljs-comment">/*
</span></script></code> |
@irvinlim Thanks for the detailed response! This is a good find and looking back I'm not entirely sure why I decided to use Regarding the context enhancements, I think this need a little more thought. While I agree that the current implementation is a bit limited, I hesitate to start adding options. I wanted the API for adding context to be very simple and straightforward and to just work without configuration required. I agree it would be nice to have better syntax highlighting but this would come at a cost. Each additional language increases the overall bundle size. Plus, where do we draw the line on what languages are included? Currently the report includes |
Great! I will be submitting a PR to remove the use of Agreed with your views on syntax highlighting. It might help if there was a way for me to disable syntax highlighting for a particular context, rather than enable syntax highlighting for additional languages when requested. This way, it would solve both problems of both HTML and plaintext from being highlighted incorrectly. I agree there isn't a simple way about this, we can leave that for a later time to solve. |
Don't worry about creating the For syntax highlighting, addContext(this, 'something', { highlight: false }; This would probably be the simplest case and allow for future options like an explicit |
Alright! Just submitted a PR for the If you are keen, I could implement your suggestion for the options argument sometime next week. I'll look forward to seeing the changes published on NPM since I'll be using this at work! |
Is it possible for the test context content to display without rendering as HTML? I noticed that in
code-snippet.jsx
, theCodeSnippet
component usesdangerouslySetInnerHTML
.Is there a reason for this? I am displaying HTML code in the test context and I believe it shouldn't be rendering (since it's a
CodeSnippet
after all). Plus, this might open up XSS risks (I'm personally using this to generate dynamic test reports).I would be happy to create a PR to fix this if neeeded.
The text was updated successfully, but these errors were encountered: