Skip to content

Commit

Permalink
[SIEM][NP] Fixes bug in ML signals promotion (elastic#64720)
Browse files Browse the repository at this point in the history
* Add set-value as an explicit dependency

This is a more robust solution than lodash's set().

* Replace lodash.set() with set-value's equivalent

* Rebuild renovate config

We added set-value to our dependencies.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
rylnd and elasticmachine committed Apr 29, 2020
1 parent 874eefe commit d928556
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"@types/recompose": "^0.30.6",
"@types/reduce-reducers": "^1.0.0",
"@types/redux-actions": "^2.6.1",
"@types/set-value": "^2.0.0",
"@types/sinon": "^7.0.13",
"@types/styled-components": "^4.4.2",
"@types/supertest": "^2.0.5",
Expand Down Expand Up @@ -345,6 +346,7 @@
"rison-node": "0.3.1",
"rxjs": "^6.5.3",
"semver": "5.7.0",
"set-value": "^3.0.2",
"squel": "^5.13.0",
"stats-lite": "^2.2.0",
"style-it": "^2.1.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { flow, set, omit } from 'lodash/fp';
import { flow, omit } from 'lodash/fp';
import set from 'set-value';
import { SearchResponse } from 'elasticsearch';

import { Logger } from '../../../../../../../src/core/server';
Expand Down Expand Up @@ -55,8 +56,11 @@ export const transformAnomalyFieldsToEcs = (anomaly: Anomaly): EcsAnomaly => {
}

const omitDottedFields = omit(errantFields.map(field => field.name));
const setNestedFields = errantFields.map(field => set(field.name, field.value));
const setTimestamp = set('@timestamp', new Date(timestamp).toISOString());
const setNestedFields = errantFields.map(field => (_anomaly: Anomaly) =>
set(_anomaly, field.name, field.value)
);
const setTimestamp = (_anomaly: Anomaly) =>
set(_anomaly, '@timestamp', new Date(timestamp).toISOString());

return flow(omitDottedFields, setNestedFields, setTimestamp)(anomaly);
};
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4744,6 +4744,11 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
integrity sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==

"@types/set-value@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/set-value/-/set-value-2.0.0.tgz#63d386b103926dcf49b50e16e0f6dd49983046be"
integrity sha512-k8dCJEC80F/mbsIOZ5Hj3YSzTVVVBwMdtP/M9Rtc2TM4F5etVd+2UG8QUiAUfbXm4fABedL2tBZnrBheY7UwpA==

"@types/shot@*":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/shot/-/shot-4.0.0.tgz#7545500c489b65c69b5bc5446ba4fef3bd26af92"
Expand Down Expand Up @@ -26770,6 +26775,13 @@ set-value@^2.0.0, set-value@^2.0.1:
is-plain-object "^2.0.3"
split-string "^3.0.1"

set-value@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/set-value/-/set-value-3.0.2.tgz#74e8ecd023c33d0f77199d415409a40f21e61b90"
integrity sha512-npjkVoz+ank0zjlV9F47Fdbjfj/PfXyVhZvGALWsyIYU/qrMzpi6avjKW3/7KeSU2Df3I46BrN1xOI1+6vW0hA==
dependencies:
is-plain-object "^2.0.4"

setimmediate@^1.0.4, setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
Expand Down

0 comments on commit d928556

Please sign in to comment.