Skip to content

Commit 76a566c

Browse files
committed
Fix Host details page doesn't show 'show more' button for ip field (#238239)
## Summary Fix Host details page doesn't show the 'show more' button for the IP field. * It updates the host details endpoint to return multiple values for a field. * It updates the host ID renderer in the UI to support multiple values ### What is not included? * Refactor host details API; it really needs a refactor, but I am not doing it in this bug fix scope. * Network details. Network modal also only displays one value per field, but it is out of the scope. <img width="300" height="682" alt="Screenshot 2025-10-09 at 13 33 33" src="https://github.com/user-attachments/assets/05f942fd-4bc5-482a-bdf9-23c1d39d3a02" /> <img width="800" height="1002" alt="Screenshot 2025-10-09 at 11 05 09" src="https://github.com/user-attachments/assets/582e3a6b-868a-4114-ad97-94f0d4654507" /> <img width="800" height="1066" alt="Screenshot 2025-10-09 at 11 05 04" src="https://github.com/user-attachments/assets/4b0b69c5-290b-4dbf-b1df-899964a235c3" /> ### Checklist Reviewers should verify this PR satisfies this list as well. - [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 ### Identify risks
1 parent 4a5e0f2 commit 76a566c

8 files changed

Lines changed: 326 additions & 167 deletions

File tree

x-pack/solutions/security/plugins/security_solution/public/explore/network/components/details/__snapshots__/index.test.tsx.snap

Lines changed: 76 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/solutions/security/plugins/security_solution/public/explore/network/components/details/index.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,14 @@ describe('IP Overview Component', () => {
6565

6666
expect(container.children[0]).toMatchSnapshot();
6767
});
68+
69+
test('it renders host id', () => {
70+
const { container } = render(
71+
<TestProviders>
72+
<IpOverview {...mockProps} data={mockData.complete} />
73+
</TestProviders>
74+
);
75+
expect(container).toHaveTextContent('b19a781f683541a7a25ee345133aa399');
76+
});
6877
});
6978
});

x-pack/solutions/security/plugins/security_solution/public/overview/components/host_overview/__snapshots__/index.test.tsx.snap

Lines changed: 66 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/solutions/security/plugins/security_solution/public/overview/components/host_overview/index.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,13 @@ describe('Host Summary Component', () => {
106106
expect(getByTestId('host-risk-overview')).toHaveTextContent(risk);
107107
expect(getByTestId('host-risk-overview')).toHaveTextContent(riskScore.toString());
108108
});
109+
110+
test('it renders host id', () => {
111+
const { container } = render(
112+
<TestProviders>
113+
<HostOverview {...mockProps} data={mockData.Hosts.edges[0].node} />
114+
</TestProviders>
115+
);
116+
expect(container).toHaveTextContent('aa7ca589f1b8220002f2fc61c64cfbf1');
117+
});
109118
});

x-pack/solutions/security/plugins/security_solution/public/timelines/components/field_renderers/field_renderers.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
locationRenderer,
1616
whoisRenderer,
1717
reputationRenderer,
18+
hostIdRenderer,
1819
} from './field_renderers';
1920
import { mockData } from '../../../explore/network/components/details/mock';
2021
import type { AutonomousSystem } from '../../../../common/search_strategy';
@@ -135,6 +136,19 @@ describe('Field Renderers', () => {
135136
);
136137
expect(screen.getByText(getEmptyValue())).toBeInTheDocument();
137138
});
139+
140+
test('it renders multiple host ids', () => {
141+
render(
142+
<TestProviders>
143+
{hostIdRenderer({
144+
scopeId,
145+
host: { ...emptyIdHost, id: ['test1', 'test2'] },
146+
})}
147+
</TestProviders>
148+
);
149+
expect(screen.getByText('test1')).toBeInTheDocument();
150+
expect(screen.getByText('+1 More')).toBeInTheDocument();
151+
});
138152
});
139153

140154
describe('#hostNameRenderer', () => {

x-pack/solutions/security/plugins/security_solution/public/timelines/components/field_renderers/field_renderers.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { getEmptyTagValue } from '../../../common/components/empty_value';
2020
import { HostDetailsLink, ReputationLink, WhoIsLink } from '../../../common/components/links';
2121
import * as i18n from '../../../explore/network/components/details/translations';
2222
import type { SourcererScopeName } from '../../../sourcerer/store/model';
23+
import { DefaultFieldRenderer } from './default_renderer';
2324

2425
export const IpOverviewId = 'ip-overview';
2526

@@ -108,34 +109,33 @@ export const hostIdRenderer = ({
108109
ipFilter,
109110
noLink,
110111
scopeId,
111-
}: HostIdRendererTypes): React.ReactElement =>
112-
host.id && host.ip && (ipFilter == null || host.ip.includes(ipFilter)) ? (
112+
}: HostIdRendererTypes): React.ReactElement => {
113+
const hostName = host.name && host.name[0];
114+
return host.id && host.ip && (ipFilter == null || host.ip.includes(ipFilter)) ? (
113115
<>
114-
{host.name && host.name[0] != null ? (
115-
<DefaultDraggable
116-
id={`host-id-renderer-default-draggable-${IpOverviewId}-${
117-
contextID ? `${contextID}-` : ''
118-
}host-id`}
116+
{hostName != null ? (
117+
<DefaultFieldRenderer
118+
rowItems={host.id}
119+
attrName={'host.id'}
119120
isDraggable={isDraggable}
120-
field="host.id"
121-
value={host.id[0]}
122-
isAggregatable={true}
123-
fieldType={'keyword'}
121+
idPrefix={contextID ? `host-overview-${contextID}` : 'host-overview'}
124122
scopeId={scopeId}
125-
>
126-
{noLink ? (
127-
<>{host.id}</>
128-
) : (
129-
<HostDetailsLink hostName={host.name[0]}>{host.id}</HostDetailsLink>
130-
)}
131-
</DefaultDraggable>
123+
render={(id) =>
124+
noLink ? (
125+
<>{id}</>
126+
) : (
127+
<HostDetailsLink hostName={hostName}>{id}</HostDetailsLink>
128+
)
129+
}
130+
/>
132131
) : (
133132
<>{host.id}</>
134133
)}
135134
</>
136135
) : (
137136
getEmptyTagValue()
138137
);
138+
};
139139

140140
export const hostNameRenderer = (
141141
scopeId: SourcererScopeName,

0 commit comments

Comments
 (0)