mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[8.8] [Security Solution] Fix timeline bug receiving dataProvider value as number (#159723) (#159775)
# Backport This will backport the following commits from `main` to `8.8`: - [[Security Solution] Fix timeline bug receiving dataProvider value as number (#159723)](https://github.com/elastic/kibana/pull/159723) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sergi Massaneda","email":"sergi.massaneda@elastic.co"},"sourceCommit":{"committedDate":"2023-06-15T08:39:45Z","message":"[Security Solution] Fix timeline bug receiving dataProvider value as number (#159723)\n\n## Summary\r\n\r\nissue: https://github.com/elastic/kibana/issues/159720\r\nTimeline save request fails when the dataProvider value stored is a\r\nNumber type.\r\n\r\nAdding the dataProvider through timeline page itself does not cause the\r\nbug. it sets a string value even if the field type is `number`.\r\n\r\nThe bug only happens when using \"add to timeline\" CellAction on a field\r\nwith type `number`\r\n\r\n### Solution\r\n\r\nCast the dataProvider values to a `string` before adding them to the\r\ntimeline.","sha":"b9d6beb070ba60a533857616150c453cc7714237","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat Hunting","Team:Threat Hunting:Investigations","Team:Threat Hunting:Explore","v8.9.0","v8.8.2"],"number":159723,"url":"https://github.com/elastic/kibana/pull/159723","mergeCommit":{"message":"[Security Solution] Fix timeline bug receiving dataProvider value as number (#159723)\n\n## Summary\r\n\r\nissue: https://github.com/elastic/kibana/issues/159720\r\nTimeline save request fails when the dataProvider value stored is a\r\nNumber type.\r\n\r\nAdding the dataProvider through timeline page itself does not cause the\r\nbug. it sets a string value even if the field type is `number`.\r\n\r\nThe bug only happens when using \"add to timeline\" CellAction on a field\r\nwith type `number`\r\n\r\n### Solution\r\n\r\nCast the dataProvider values to a `string` before adding them to the\r\ntimeline.","sha":"b9d6beb070ba60a533857616150c453cc7714237"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159723","number":159723,"mergeCommit":{"message":"[Security Solution] Fix timeline bug receiving dataProvider value as number (#159723)\n\n## Summary\r\n\r\nissue: https://github.com/elastic/kibana/issues/159720\r\nTimeline save request fails when the dataProvider value stored is a\r\nNumber type.\r\n\r\nAdding the dataProvider through timeline page itself does not cause the\r\nbug. it sets a string value even if the field type is `number`.\r\n\r\nThe bug only happens when using \"add to timeline\" CellAction on a field\r\nwith type `number`\r\n\r\n### Solution\r\n\r\nCast the dataProvider values to a `string` before adding them to the\r\ntimeline.","sha":"b9d6beb070ba60a533857616150c453cc7714237"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
This commit is contained in:
parent
fae57b0ea3
commit
858100d843
2 changed files with 25 additions and 1 deletions
|
@ -87,6 +87,29 @@ describe('createAddToTimelineCellAction', () => {
|
|||
expect(mockWarningToast).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should execute with number value', async () => {
|
||||
await addToTimelineAction.execute({
|
||||
field: { name: 'process.parent.pid', value: 12345, type: 'number' },
|
||||
} as unknown as CellActionExecutionContext); // TODO: remove `as unknown` when number value type is supported
|
||||
expect(mockDispatch).toHaveBeenCalledWith(
|
||||
set(
|
||||
'payload.providers[0]',
|
||||
{
|
||||
...defaultDataProvider,
|
||||
id: 'event-field-default-timeline-1-process_parent_pid-0-12345',
|
||||
name: 'process.parent.pid',
|
||||
queryMatch: {
|
||||
field: 'process.parent.pid',
|
||||
value: '12345',
|
||||
operator: ':',
|
||||
},
|
||||
},
|
||||
defaultDataProviderAction
|
||||
)
|
||||
);
|
||||
expect(mockWarningToast).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should execute with null value', async () => {
|
||||
await addToTimelineAction.execute({
|
||||
field: { name: 'user.name', value: null, type: 'text' },
|
||||
|
|
|
@ -79,8 +79,9 @@ export const createDataProviders = ({
|
|||
|
||||
const arrayValues = Array.isArray(values) ? (values.length > 0 ? values : [null]) : [values];
|
||||
|
||||
return arrayValues.reduce<DataProvider[]>((dataProviders, value, index) => {
|
||||
return arrayValues.reduce<DataProvider[]>((dataProviders, rawValue, index) => {
|
||||
let id: string = '';
|
||||
const value = rawValue != null ? rawValue.toString() : rawValue;
|
||||
const appendedUniqueId = `${contextId}${eventId ? `-${eventId}` : ''}-${field}-${index}${
|
||||
value ? `-${value}` : ''
|
||||
}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue