-
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
[Actions] Removed double parsing when passing action url for validation #87928
Conversation
return false; | ||
} | ||
|
||
function isHostnameAllowedInUri(config: ActionsConfigType, uri: string): boolean { | ||
return pipe( | ||
tryCatch(() => new URL(uri)), | ||
map((url) => url.hostname), | ||
tryCatch(() => url.parse(uri)), |
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.
Updated to match how axios handles urls https://github.com/axios/axios/blob/59ab559386273a185be18857a12ab0305b753e50/lib/adapters/http.js#L91.
} catch (err) { | ||
return i18n.translate('xpack.actions.builtin.slack.slackConfigurationErrorNoHostname', { | ||
defaultMessage: 'error configuring slack action: unable to parse host name from webhookUrl', | ||
}); | ||
} | ||
|
||
try { | ||
configurationUtilities.ensureHostnameAllowed(url.hostname); | ||
configurationUtilities.ensureUriAllowed(configuredUrl); |
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 calling ensureUriAllowed
both here and in the teams connector to be consistent with how I updated the webhook action. Pagerduty, Jira, Resilient and Servicenow were already all using ensureUriAllowed
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
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.
LGTM!
@elasticmachine merge upstream |
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.
LGTM, made a nit comment about a potentially extraneous boolean check
Was there an issue associated with this? For some reason I'm thinking there was, something about the parse, re-gen, parse yielding a different URL because of escaping or something? I didn't see an issue referenced, maybe I missed it. If there was, we should add a test for that case.
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…on (elastic#87928) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]>
…on (elastic#87928) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]>
…on (elastic#87928) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]> # Conflicts: # x-pack/plugins/actions/server/builtin_action_types/slack.ts # x-pack/plugins/actions/server/builtin_action_types/teams.test.ts # x-pack/plugins/actions/server/builtin_action_types/teams.ts
…on (#87928) (#88728) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
…on (#87928) (#88729) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
…alidation (#87928) (#88730) * [Actions] Removed double parsing when passing action url for validation (#87928) * Removed double parsing when passing action url for validation * Fixing functional test * PR fixes * PR fixes Co-authored-by: Kibana Machine <[email protected]> # Conflicts: # x-pack/plugins/actions/server/builtin_action_types/slack.ts # x-pack/plugins/actions/server/builtin_action_types/teams.test.ts # x-pack/plugins/actions/server/builtin_action_types/teams.ts * Fixing bad merge * Fixing types check
Summary
When creating actions, webhook action URLs were being double parsed as URLs (parsed as URL, then
toString
, then parsed again as URL) while during validation. This updates validation to pass in the configured URL as is and allow the shared validation method to parse the URL and hostname.Checklist
Delete any items that are not applicable to this PR.