Skip to content

Commit 74cf39c

Browse files
committed
tls: use primordials in common.js
Replace native array method (.push) with primordials (ArrayPrototypePush) in lib/internal/tls/common.js for consistency and security. This improves protection against prototype pollution and aligns with the primordials pattern used throughout the codebase.
1 parent 879b95e commit 74cf39c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/tls/common.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const {
25+
ArrayPrototypePush,
2526
JSONParse,
2627
} = primordials;
2728

@@ -141,10 +142,10 @@ function translatePeerCertificate(c) {
141142
// so this should never throw.
142143
val = JSONParse(val);
143144
}
144-
if (key in c.infoAccess)
145-
c.infoAccess[key].push(val);
146-
else
147-
c.infoAccess[key] = [val];
145+
if (key in c.infoAccess)
146+
ArrayPrototypePush(c.infoAccess[key], val);
147+
else
148+
c.infoAccess[key] = [val];
148149
});
149150
}
150151
return c;

0 commit comments

Comments
 (0)