Skip to content

Commit

Permalink
[Security Solution][ResponseOps] fixes context.results_link in action…
Browse files Browse the repository at this point in the history
…s params (#159966)

## Summary

- fixes #159586


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)



### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
vitaliidm authored Jun 20, 2023
1 parent ea0935f commit a653a3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,24 @@ describe('Execution Handler', () => {
`);
});

it('populates the rule.url in the action params when the base url contains pathname', async () => {
const execParams = {
...defaultExecutionParams,
rule: ruleWithUrl,
taskRunnerContext: {
...defaultExecutionParams.taskRunnerContext,
kibanaBaseUrl: 'http://localhost:12345/kbn',
},
};

const executionHandler = new ExecutionHandler(generateExecutionParams(execParams));
await executionHandler.run(generateAlert({ id: 1 }));

expect(injectActionParamsMock.mock.calls[0][0].actionParams).toEqual({
val: 'rule url: http://localhost:12345/kbn/s/test1/app/management/insightsAndAlerting/triggersActions/rule/1',
});
});

it('populates the rule.url with start and stop time when available', async () => {
clock.reset();
clock.tick(90000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,12 @@ export class ExecutionHandler<
: `${triggersActionsRoute}${getRuleDetailsRoute(this.rule.id)}`;

try {
const basePathname = new URL(this.taskRunnerContext.kibanaBaseUrl).pathname;
const basePathnamePrefix = basePathname !== '/' ? `${basePathname}` : '';
const spaceIdSegment = spaceId !== 'default' ? `/s/${spaceId}` : '';

const ruleUrl = new URL(
`${spaceId !== 'default' ? `/s/${spaceId}` : ''}${relativePath}`,
[basePathnamePrefix, spaceIdSegment, relativePath].join(''),
this.taskRunnerContext.kibanaBaseUrl
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ export const createSecurityRuleTypeWrapper: CreateSecurityRuleTypeWrapper =
from: fromInMs,
to: toInMs,
id: rule.id,
kibanaSiemAppUrl: (rule.params?.meta as { kibana_siem_app_url?: string } | undefined)
?.kibana_siem_app_url,
});
},
async executor(options) {
Expand Down

0 comments on commit a653a3e

Please sign in to comment.