-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Respect external URL allow list in TSVB #114093
Respect external URL allow list in TSVB #114093
Conversation
@KOTungseth could you please validate the modal message? |
Pinging @elastic/kibana-vis-editors (Team:VisEditors) |
@elasticmachine merge upstream |
src/plugins/vis_types/timeseries/public/application/components/vis_types/top_n/vis.js
Show resolved
Hide resolved
@elastic/kibana-docs can we have a review on the modal message? ❤️ |
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.
This seems to work fine but when I have set up an external url policy for an internal link this doesn't work.
For example
This is a very common use case, users are creating drilldowns to navigate to a dashboard. If I set up an external url policy this is not allowed. I think that it should be allowed as it is an internal url.
Another thing that it seems a bit odd to me is that if I have blackisted a url (let's say the google.com), when I click on TSVB table or topN the modal appears. This is correct. But when I right click to open in new tab is allowed. This should not be allowed in right click too.
I'm wondering if we can write this without the word "denied" so it doesn't sound so scary and remove the reference to the ExternalURL service. It would be better to put the URL at the end as it can be long. Here is a suggestion: Access to this URL is not yet enabled or put "external" in the title: Access to this external URL is not yet enabled |
@elasticmachine merge upstream |
@elastic/kibana-core we need your help! We are trying to use the externalUrlService to validate URLs against an explicit allow/deny list in kibana.yml. These urls are used as drilldowns in TSVB. One very common case for the users (it also exists in the documentation) is to add as a drilldown an internal url to navigate to a dashboard. For example: Note: This doesn't happen when we are testing it via the functional test server, so we guess that it has to do with the 3 letters prefix (localhost:5601/xyz). Maybe it is fine as it is, and it happens only locally but can you check it and let us know? |
Do we even have to call the api for these urls? Or could we detect relative urls and allow them all the time? Also, is this a problem for vega as well? |
@flash1293 yes it is also denied by vega |
Got it, thanks. We definitely need some mechanism to check between internal and external urls - the question is should the core service handle this or something on the consumer side? I guess it would have to be something like this:
Edit: Just checked the code and it seems like there is some logic in there already along those lines:
I guess it doesn't cover the cases with relative paths and just hashes from above? cc @legrego as it seems like you wrote that code originally. |
@legrego was actually the one that implemented this service, so he may be more suited to answer, but: From a quick look at the code, when we're checking if the url is an kibana/src/core/public/http/external_url_service.ts Lines 58 to 68 in 4584a8b
Could it be that you're missing a |
@pgayvallet yes I think that we are just passing the url as it is added by the user. We are not prepending anything (@dziyanadzeraviankina correct me if I am wrong) So maybe for the validation to work correctly we could identify if this is an internal link and create the validation url as it is proposed by Pierre @flash1293 wdyt? |
This is not the case we are looking at here - We can definitely resolve this case on the caller side, but it seems like the wrong place to do it as all consumers would have this issue and the core service is already checking for internal urls, it's just missing this case. |
Yes I totally agree with you. I just had in mind the vega PR that is going to be released in 7.16 with this behavior. Not sure if it is used a lot though, but still. |
Yeah, we should definitely fix this bug in 7.16. I'm not sure about the
Is wrongly assuming Let's wait for Larry to chime in. |
Now, the url validation service does not support them atm, at it would require to either have it access
++ |
Looks like it's already coupled to
|
Damn, it's not even that early in the morning anymore, so I don't have any excuses. You're right, we're already depending on |
I'm with you here, but this is a real example, people use it and it worked before - we fixed bugs around this in other places doing URL handling. |
Sorry, but before what? We did not touch the url validation service since its initial implementation |
Sorry, I meant these urls used to work before the url validation service was introduced to Vega and TSVB. |
@stratoula made me aware we are actually using relative paths in the documentation: |
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.
Changes LGTM. This works fine for topN and table.
The only thing missing is that if you have defined an external url policy, the relative paths do not work. This is a quite common case as it is also mentioned in our docs.
We discussed it offline and we think that this is something that should be fixed (as it will also fail in vega), but as it is not introduced by this PR and we think that is a case that should be handled from the external url service, I am approving it. cc @flash1293
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
Sounds good - however we decide to run this, we will have to do the same thing for Vega and TSVB. |
It seems like the “resolve” helper https://www.npmjs.com/package/url#urlresolvefrom-to is exactly what we need - resolve the provided url in the current context to get a fully qualified url, then check the allow list against that.
|
The intent of the validation service is to work with either internal or external URLs. Internal URLs can be either fully or partially qualified (i.e. If it's a partially qualified location, then it must start with the configured When this was first written, we didn't have a way to determine what the public facing URL for Kibana, so we resorted to using |
<a | ||
href={sanitizeUrl(url)} | ||
onClick={handleDrilldownUrlClick} | ||
onContextMenu={handleDrilldownUrlClick} |
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 am not a fan of this kind of code, especially when in a similar place for top n it is handled differently ... but ok ... I will not block this pr for this reason
rowDisplay = <a href={sanitizeUrl(url)}>{rowDisplay}</a>; | ||
const handleDrilldownUrlClick = this.createDrilldownUrlClickHandler(url); | ||
rowDisplay = ( | ||
<a |
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.
Just wondering if we should use EuiLink
in such cases?
* Respect external URL allow list in TSVB * Remove showExternalUrlErrorModal and onContextMenu handler for table * Update modal message Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Respect external URL allow list in TSVB * Remove showExternalUrlErrorModal and onContextMenu handler for table * Update modal message Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Closes #113094
Summary
Add
ExternalUrl
service validation toTop N
andTable
url drilldowns.In case of access denied modal with error message is shown.
Checklist
Delete any items that are not applicable to this PR.
For maintainers