Skip to content

Commit

Permalink
[Security Solution] Fix source.ip and destination.ip draggables (#79399
Browse files Browse the repository at this point in the history
…) (#79489)
  • Loading branch information
patrykkopycinski authored Oct 5, 2020
1 parent 1494e56 commit 534ea86
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const Ip = React.memo<{
fieldName={fieldName}
fieldType={IP_FIELD_TYPE}
value={value}
truncate
/>
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
});
Expand Down Expand Up @@ -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'
);
});
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
*/
export const FieldNameContainer = styled.span`
border-radius: 4px;
display: flex;
padding: 0 4px 0 8px;
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 534ea86

Please sign in to comment.