-
Notifications
You must be signed in to change notification settings - Fork 68
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
Make the Chart Name field html 'clean'. #239
Conversation
The chart name field could have been used to inject html into the page. This pull request addresses this issue. Notes: The 'New Chart' dialog already htmlEncoded the chart name so any charts that we created using this mechanism using the old code will be displayed exactly the same (except of course the display bug in the chart menu is fixed). The code change on the server will prevent any existing saved charts with embedded html from being executed. These charts will obviously have the name appear different in this new code, by design!
Note that this is my attempt to fix the issue described in #233 |
eff6de1
to
0207e86
Compare
You may ask why I didn't use ENT_HTML5 | ENT_QUOTES as the flags to |
In this case, would it make sense to also apply a patch to 7.1 (which supports PHP 5.4) to use ENT_HTML5 | ENT_QUOTES? |
I see that you've updated |
Not strictly related to 'Chart Name' but per our discussion yesterday, were you able to test whether or not the Report Manager can properly handle a Chart Title with html content? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there may be additional changes in MetricExplorer.js:createQueryHandler required.
@@ -120,6 +120,7 @@ public function getQueries(Request $request, Application $app) | |||
|
|||
foreach ($data as &$query) { | |||
$this->removeRoleFromQuery($user, $query); | |||
$query['name'] = htmlspecialchars($query['name'], ENT_COMPAT, 'UTF-8', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question, was there a problem when including the default ENT_HTML401 flag?
@@ -171,6 +172,7 @@ public function getQueryById(Request $request, Application $app, $id) | |||
|
|||
if (isset($query)) { | |||
$payload['data'] = $query; | |||
$payload['data']['name'] = htmlspecialchars($query['name'], ENT_COMPAT, 'UTF-8', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the one above re: ENT_HTML401.
Well that review makes no sense ( structure wise )... My additional comments to follow |
Have you tested whether or not a long ( > 73 characters ) name w/ embedded html has it's entry in the 'Load Chart' grid display it's tooltip as expected? |
If you could at least run the automated UI tests, that should at least cover some of the questions asked by @ryanrath specifically the long title (https://github.com/ubccr/xdmod/blob/xdmod7.1/open_xdmod/modules/xdmod/automated_tests/test/specs/xdmod/metricExplorer.js#L412-L423) |
@plessbd This test would need to be updated to include some raw html. The fragment that I've been using is |
Full disclosure, the reason for my comments is that I actually worked on answering these questions yesterday and held off on submitting the PR because I had to run before I could add new tests. I wanted to make sure that everything was in place before submitting. Honestly, In the grand scheme of things don't care who puts the PR in so long as the identified issues are resolved. |
Re the flags: The ENT_HTML5 flag doesn't make any difference if you are not using ENT_QUOTES and I think we don't need to use ENT_QUOTES for this use case. We may, however need to use it in other places, and, if so, we will need to make sure the single quote character is converted appropriately for display in text boxes (the Ext.util.Format.htmlDecode does not support either the single quote html5 or single quote html4.01 encoding). |
No need to update createQuery and updateQueryById since we always ensure correct conversion on output. See e.e. https://security.stackexchange.com/questions/95325/input-sanitization-vs-output-sanitization |
Yes |
It is not needed as it is the default. In any case it does nothing unless you are using ENT_QUOTES which we are not. |
Maybe you can help me out as I'm sure I'm just missing something. But when I use this branch as the basis for a docker rpm build ( like shippable ), login as 'admin', navigate to Metric Explorer, Create a new chart with a title of |
Are you sure you installed this code? When I try that on my system I do not get the alert. I'm using chrome OSX. What browser are you using? |
Chrome / Linux |
Did you make sure to clear the browser cache? |
Can you put a breakpoint in line 4972 and dump the contents of metaData.attr |
Ahhh, now I see the discrepancy. Line 4972, you have Ext.util.Format.htmlEncode(name) but I don't see that in the changeset. |
|
Sorry about that. I made all of the changes in the installed location and then manually copied them back into the source tree. I should have double checked that I caught all of the changes. |
No worries :) Just glad we figured it out. If you'd like I can toss the set of manual tests I came up with here so that we can refer to them when creating the automated tests ( if they + yours are sufficient of course). ( I also have all the changes to take care of Chart Title but I can just do that in a different PR ). |
Sound like a good plan. I'm in the process of writing some auto tests now. |
Here's what I had ( granted I was also testing the Title so Test 1.5 can be left out I think ) Manual Testing was performed, they were as follows: Test 1
Test 1.5:
Test 2: depends on Test 1
Test 3: Depends on Test 2
Test 4:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The chart name field could have been used to inject html into the page. This
pull request addresses this issue.
Notes:
The 'New Chart' dialog already htmlEncoded the chart name so any charts that we created
using this mechanism using the old code will be displayed exactly the same (except of course the
display bug in the chart menu is fixed).
The code change on the server will prevent any existing saved charts with embedded html
from being executed. These charts will obviously have the name appear different in this
new code, by design!
Testing details
1a) Create a chart name with injected img and script tags using old code
2a) update to new code and confirm that the injected script is not run and the raw html gets displayed instead.
1b) Try to use the Name text box to enter html code. Confirm that the text entered is displayed verbatim in