[Security Solution] Fix source.ip and destination.ip draggables (#79399)

This commit is contained in:
Patryk Kopyciński 2020-10-05 17:42:48 +02:00 committed by GitHub
parent 53f22dcf36
commit 88ddde817c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 12 deletions

View file

@ -53,7 +53,7 @@ export const getDefaultWhenTooltipIsUnspecified = ({
/**
* Renders the content of the draggable, wrapped in a tooltip
*/
const Content = React.memo<{
export const Content = React.memo<{
children?: React.ReactNode;
field: string;
tooltipContent?: React.ReactNode;

View file

@ -7,6 +7,7 @@ exports[`Port renders correctly against snapshot 1`] = `
eventId="abcd"
fieldName="destination.ip"
fieldType="ip"
truncate={true}
value="10.1.2.3"
/>
`;

View file

@ -43,7 +43,7 @@ describe('Port', () => {
);
expect(
wrapper.find('[data-test-subj="draggable-content-destination.ip"]').find('a').first().props()
wrapper.find('[data-test-subj="draggable-truncatable-content"]').find('a').first().props()
.href
).toEqual('/ip/10.1.2.3/source');
});

View file

@ -30,6 +30,7 @@ export const Ip = React.memo<{
fieldName={fieldName}
fieldType={IP_FIELD_TYPE}
value={value}
truncate
/>
));

View file

@ -772,7 +772,7 @@ describe('SourceDestinationIp', () => {
</TestProviders>
);
expect(wrapper.find('[data-test-subj="draggable-content-source.ip"]').first().text()).toEqual(
expect(wrapper.find('[data-test-subj="draggable-truncatable-content"]').first().text()).toEqual(
'192.168.1.2'
);
});
@ -823,7 +823,7 @@ describe('SourceDestinationIp', () => {
</TestProviders>
);
expect(wrapper.find('[data-test-subj="draggable-content-source.ip"]').first().text()).toEqual(
expect(wrapper.find('[data-test-subj="draggable-truncatable-content"]').first().text()).toEqual(
'192.168.1.2'
);
});
@ -874,9 +874,9 @@ describe('SourceDestinationIp', () => {
</TestProviders>
);
expect(
wrapper.find('[data-test-subj="draggable-content-destination.ip"]').first().text()
).toEqual('10.1.2.3');
expect(wrapper.find('[data-test-subj="draggable-truncatable-content"]').first().text()).toEqual(
'10.1.2.3'
);
});
test('it renders the expected destination IP when type is `destination`, but the length of the destinationIp and destinationPort port arrays is different', () => {
@ -925,9 +925,9 @@ describe('SourceDestinationIp', () => {
</TestProviders>
);
expect(
wrapper.find('[data-test-subj="draggable-content-destination.ip"]').first().text()
).toEqual('10.1.2.3');
expect(wrapper.find('[data-test-subj="draggable-truncatable-content"]').first().text()).toEqual(
'10.1.2.3'
);
});
test('it renders the expected source port when type is `source`, and both sourceIp and sourcePort are populated', () => {

View file

@ -21,6 +21,7 @@ import {
*/
export const FieldNameContainer = styled.span`
border-radius: 4px;
display: flex;
padding: 0 4px 0 8px;
position: relative;

View file

@ -12,6 +12,7 @@ import {
DraggableWrapper,
} from '../../../common/components/drag_and_drop/draggable_wrapper';
import { escapeDataProviderId } from '../../../common/components/drag_and_drop/helpers';
import { Content } from '../../../common/components/draggables';
import { getOrEmptyTagFromValue } from '../../../common/components/empty_value';
import { NetworkDetailsLink } from '../../../common/components/links';
import { parseQueryValue } from '../../../timelines/components/timeline/body/renderers/parse_query_value';
@ -148,9 +149,11 @@ const AddressLinksItemComponent: React.FC<AddressLinksItemProps> = ({
<Provider dataProvider={dataProviderProp} />
</DragEffects>
) : (
<NetworkDetailsLink data-test-subj="network-details" ip={address} />
<Content field={fieldName} tooltipContent={address}>
<NetworkDetailsLink data-test-subj="network-details" ip={address} />
</Content>
),
[address, dataProviderProp]
[address, dataProviderProp, fieldName]
);
return (

View file

@ -54,6 +54,7 @@ const FormattedFieldValueComponent: React.FC<{
contextId={contextId}
fieldName={fieldName}
value={!isNumber(value) ? value : String(value)}
truncate={truncate}
/>
);
} else if (fieldType === DATE_FIELD_TYPE) {