forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Endpoint] Fix Response Console
status
command f…
…or SentinelOne and error output for commands that hidden from `help` (elastic#180529) ## Summary Fixes: - Disable the `status` command for SentinelOne hosts (not supported) - For console commands that are hidden from Help, if a user attempts to still enter them in the console, the usage information should NOT be displayed following the error message.
- Loading branch information
1 parent
2b2d00d
commit a78c522
Showing
7 changed files
with
166 additions
and
36 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...s/security_solution/public/management/components/console/components/bad_argument.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { CommandDefinition, ConsoleProps } from '..'; | ||
import type { AppContextTestRender } from '../../../../common/mock/endpoint'; | ||
import type { ConsoleTestSetup } from '../mocks'; | ||
import { getConsoleTestSetup } from '../mocks'; | ||
|
||
describe('BadArgument component', () => { | ||
let render: (props?: Partial<ConsoleProps>) => ReturnType<AppContextTestRender['render']>; | ||
let renderResult: ReturnType<typeof render>; | ||
let command: CommandDefinition; | ||
let enterCommand: ConsoleTestSetup['enterCommand']; | ||
|
||
beforeEach(() => { | ||
const testSetup = getConsoleTestSetup(); | ||
let commands: CommandDefinition[]; | ||
|
||
({ commands, enterCommand } = testSetup); | ||
command = commands[0]; | ||
command.args = { | ||
foo: { | ||
about: 'foo', | ||
required: true, | ||
mustHaveValue: 'number-greater-than-zero', | ||
allowMultiples: false, | ||
}, | ||
}; | ||
|
||
render = (props = {}) => (renderResult = testSetup.renderConsole(props)); | ||
}); | ||
|
||
it('should display message and help output if command is not hidden from help', () => { | ||
render(); | ||
enterCommand('cmd1 --foo'); | ||
|
||
expect(renderResult.getByTestId('test-badArgument-message').textContent).toEqual( | ||
'Argument --foo must have a value' | ||
); | ||
expect(renderResult.getByTestId('test-badArgument-commandUsage')); | ||
}); | ||
|
||
it('should only display message (no help) if command is hidden from help', () => { | ||
command.helpHidden = true; | ||
render(); | ||
enterCommand('cmd1 --foo'); | ||
|
||
expect(renderResult.getByTestId('test-badArgument-message').textContent).toEqual( | ||
'Argument --foo must have a value' | ||
); | ||
expect(renderResult.queryByTestId('test-badArgument-commandUsage')).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...curity_solution/public/management/components/console/components/validation_error.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { CommandDefinition, ConsoleProps } from '..'; | ||
import type { AppContextTestRender } from '../../../../common/mock/endpoint'; | ||
import type { ConsoleTestSetup } from '../mocks'; | ||
import { getConsoleTestSetup } from '../mocks'; | ||
|
||
describe('ValidationError component', () => { | ||
let render: (props?: Partial<ConsoleProps>) => ReturnType<AppContextTestRender['render']>; | ||
let renderResult: ReturnType<typeof render>; | ||
let command: CommandDefinition; | ||
let enterCommand: ConsoleTestSetup['enterCommand']; | ||
|
||
beforeEach(() => { | ||
const testSetup = getConsoleTestSetup(); | ||
let commands: CommandDefinition[]; | ||
|
||
({ commands, enterCommand } = testSetup); | ||
command = commands[0]; | ||
command.validate = () => 'this command is not active'; | ||
|
||
render = (props = {}) => (renderResult = testSetup.renderConsole(props)); | ||
}); | ||
|
||
it('should display message and help output if command is not hidden from help', () => { | ||
render(); | ||
enterCommand('cmd1'); | ||
|
||
expect(renderResult.getByTestId('test-validationError-message').textContent).toEqual( | ||
'this command is not active' | ||
); | ||
expect(renderResult.getByTestId('test-validationError-commandUsage')); | ||
}); | ||
|
||
it('should only display message (no help) if command is hidden from help', () => { | ||
command.helpHidden = true; | ||
render(); | ||
enterCommand('cmd1'); | ||
|
||
expect(renderResult.getByTestId('test-validationError-message').textContent).toEqual( | ||
'this command is not active' | ||
); | ||
expect(renderResult.queryByTestId('test-validationError-commandUsage')).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters