Skip to content

Commit 3d33238

Browse files
committed
Update to resolve prototype pollution issue.
1 parent 789a454 commit 3d33238

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

shared/AppInsightsCore/src/core/SdkStatsNotificationCbk.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33
"use strict";
44

5-
import { ITimerHandler, objHasOwn, scheduleTimeout } from "@nevware21/ts-utils";
5+
import { ITimerHandler, objCreate, objHasOwn, scheduleTimeout } from "@nevware21/ts-utils";
66
import { INotificationListener } from "../interfaces/ai/INotificationListener";
77
import { ITelemetryItem } from "../interfaces/ai/ITelemetryItem";
88

@@ -80,9 +80,9 @@ export interface ISdkStatsNotifCbk extends INotificationListener {
8080
*/
8181
/*#__NO_SIDE_EFFECTS__*/
8282
export function createSdkStatsNotifCbk(cfg: ISdkStatsConfig): ISdkStatsNotifCbk {
83-
var _successCounts: { [telType: string]: number } = {};
84-
var _droppedCounts: { [code: string]: { [telType: string]: number } } = {};
85-
var _retryCounts: { [code: string]: { [telType: string]: number } } = {};
83+
var _successCounts: { [telType: string]: number } = objCreate(null);
84+
var _droppedCounts: { [code: string]: { [telType: string]: number } } = objCreate(null);
85+
var _retryCounts: { [code: string]: { [telType: string]: number } } = objCreate(null);
8686
var _timer: ITimerHandler;
8787
var _interval = cfg.int || FLUSH_INTERVAL;
8888

@@ -117,7 +117,7 @@ export function createSdkStatsNotifCbk(cfg: ISdkStatsConfig): ISdkStatsNotifCbk
117117
if (objHasOwn(_droppedCounts, code)) {
118118
bucket = _droppedCounts[code];
119119
} else {
120-
bucket = {};
120+
bucket = objCreate(null);
121121
_droppedCounts[code] = bucket;
122122
}
123123
for (var i = 0; i < items.length; i++) {
@@ -134,7 +134,7 @@ export function createSdkStatsNotifCbk(cfg: ISdkStatsConfig): ISdkStatsNotifCbk
134134
if (objHasOwn(_retryCounts, code)) {
135135
bucket = _retryCounts[code];
136136
} else {
137-
bucket = {};
137+
bucket = objCreate(null);
138138
_retryCounts[code] = bucket;
139139
}
140140
for (var i = 0; i < items.length; i++) {
@@ -233,9 +233,9 @@ export function createSdkStatsNotifCbk(cfg: ISdkStatsConfig): ISdkStatsNotifCbk
233233
}
234234

235235
// Reset accumulators
236-
_successCounts = {};
237-
_droppedCounts = {};
238-
_retryCounts = {};
236+
_successCounts = objCreate(null);
237+
_droppedCounts = objCreate(null);
238+
_retryCounts = objCreate(null);
239239
}
240240

241241
return {

0 commit comments

Comments
 (0)