[Security Solution][Exceptions] - Fix bug displaying filepath warning for non endpoint exception items (#151570)

## Summary

Addresses https://github.com/elastic/kibana/issues/145970

Fix bug displaying filepath warning for non endpoint exception items
This commit is contained in:
Yara Tercero 2023-02-22 10:56:59 -08:00 committed by GitHub
parent 250dcffcda
commit 7a03aeaed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View file

@ -523,6 +523,44 @@ describe('BuilderEntryItem', () => {
expect(wrapper.find('[data-test-subj="exceptionBuilderEntryFieldWildcard"]').text()).toEqual(
'1234*'
);
// doesnt show warning label for non endpoint exception items
expect(
wrapper.find('[data-test-subj="valuesAutocompleteWildcardLabel"] .euiFormHelpText')
).toHaveLength(0);
});
test('it does not render matches filepath warning message for rule default list item', () => {
wrapper = mount(
<BuilderEntryItem
autocompleteService={autocompleteStartMock}
entry={{
correspondingKeywordField: undefined,
entryIndex: 0,
field: getField('@tags'),
id: '123',
nested: undefined,
operator: matchesOperator,
parent: undefined,
value: '1234*',
}}
httpService={mockKibanaHttpService}
indexPattern={{
fields,
id: '1234',
title: 'logstash-*',
}}
listType="rule_default"
onChange={jest.fn()}
setErrorsExist={jest.fn()}
setWarningsExist={jest.fn()}
showLabel={false}
/>
);
// doesnt show warning label for non endpoint exception items
expect(
wrapper.find('[data-test-subj="valuesAutocompleteWildcardLabel"] .euiFormHelpText')
).toHaveLength(0);
});
test('it renders field values correctly when operator is "doesNotMatchOperator"', () => {

View file

@ -404,7 +404,7 @@ export const BuilderEntryItem: React.FC<EntryItemProps> = ({
case OperatorTypeEnum.WILDCARD:
const wildcardValue = typeof entry.value === 'string' ? entry.value : undefined;
let actualWarning: React.ReactNode | string | undefined;
if (listType !== 'detection') {
if (listType !== 'detection' && listType !== 'rule_default') {
let os: OperatingSystem = OperatingSystem.WINDOWS;
if (osTypes) {
[os] = osTypes as OperatingSystem[];