Skip to content

Commit

Permalink
Fixed 'Cannot access signalIdMap before initialization name' in reduc…
Browse files Browse the repository at this point in the history
…e by instatiating map prior to reduce
  • Loading branch information
donaherc committed Mar 2, 2022
1 parent f1b6f03 commit b223ddd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export function sendAlertTelemetryEvents(
let selectedEvents = selectEvents(filteredEvents);
if (selectedEvents.length > 0) {
// Create map of ancenstor_id -> alert_id
let signalIdMap = new Map<CreatedSignalId, AlertId>();
/* eslint-disable no-param-reassign */
const signalIdMap = createdEvents.reduce((signalMap, obj) => {
signalIdMap = createdEvents.reduce((signalMap, obj) => {
const ancestorId = obj['kibana.alert.original_event.id']?.toString();
const alertId = obj._id?.toString();
if (ancestorId !== null && ancestorId !== undefined && alertId !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const allowlistProcessFields: AllowlistFields = {

// Allow list for event-related fields, which can also be nested under events[]
const allowlistBaseEventFields: AllowlistFields = {
signal_id: true,
dll: {
name: true,
path: true,
Expand Down Expand Up @@ -109,6 +108,7 @@ const allowlistBaseEventFields: AllowlistFields = {
export const allowlistEventFields: AllowlistFields = {
_id: true,
'@timestamp': true,
signal_id: true,
agent: true,
Endpoint: true,
/* eslint-disable @typescript-eslint/naming-convention */
Expand Down

0 comments on commit b223ddd

Please sign in to comment.