Skip to content

Commit 00b718b

Browse files
committed
added proto to all the codebase
1 parent 94e8626 commit 00b718b

File tree

200 files changed

+1596
-1562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+1596
-1562
lines changed

lib/_http_agent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,5 +551,5 @@ function asyncResetHandle(socket) {
551551

552552
module.exports = {
553553
Agent,
554-
globalAgent: new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 }),
554+
globalAgent: new Agent({ __proto__: null, keepAlive: true, scheduling: 'lifo', timeout: 5000 }),
555555
};

lib/_http_client.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function ClientRequest(input, options, cb) {
146146
cb = options;
147147
options = input || kEmptyObject;
148148
} else {
149-
options = ObjectAssign(input || {}, options);
149+
options = ObjectAssign(input || { __proto__: null }, options);
150150
}
151151

152152
let agent = options.agent;
@@ -328,7 +328,7 @@ function ClientRequest(input, options, cb) {
328328

329329
let optsWithoutSignal = options;
330330
if (optsWithoutSignal.signal) {
331-
optsWithoutSignal = ObjectAssign({}, options);
331+
optsWithoutSignal = ObjectAssign({ __proto__: null }, options);
332332
delete optsWithoutSignal.signal;
333333
}
334334

@@ -370,20 +370,20 @@ ClientRequest.prototype._finish = function _finish() {
370370
FunctionPrototypeCall(OutgoingMessage.prototype._finish, this);
371371
if (hasObserver('http')) {
372372
startPerf(this, kClientRequestStatistics, {
373-
type: 'http',
373+
__proto__: null, type: 'http',
374374
name: 'HttpClient',
375375
detail: {
376-
req: {
377-
method: this.method,
376+
__proto__: null, req: {
377+
__proto__: null, method: this.method,
378378
url: `${this.protocol}//${this.host}${this.path}`,
379-
headers: typeof this.getHeaders === 'function' ? this.getHeaders() : {},
379+
headers: typeof this.getHeaders === 'function' ? this.getHeaders() : { __proto__: null },
380380
},
381381
},
382382
});
383383
}
384384
if (onClientRequestStartChannel.hasSubscribers) {
385385
onClientRequestStartChannel.publish({
386-
request: this,
386+
__proto__: null, request: this,
387387
});
388388
}
389389
if (isTraceHTTPEnabled()) {
@@ -637,7 +637,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
637637
}
638638
// Send information events to all 1xx responses except 101 Upgrade.
639639
req.emit('information', {
640-
statusCode: res.statusCode,
640+
__proto__: null, statusCode: res.statusCode,
641641
statusMessage: res.statusMessage,
642642
httpVersion: res.httpVersion,
643643
httpVersionMajor: res.httpVersionMajor,
@@ -658,9 +658,9 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
658658

659659
if (req[kClientRequestStatistics] && hasObserver('http')) {
660660
stopPerf(req, kClientRequestStatistics, {
661-
detail: {
662-
res: {
663-
statusCode: res.statusCode,
661+
__proto__: null, detail: {
662+
__proto__: null, res: {
663+
__proto__: null, statusCode: res.statusCode,
664664
statusMessage: res.statusMessage,
665665
headers: res.headers,
666666
},
@@ -669,13 +669,13 @@ function parserOnIncomingClient(res, shouldKeepAlive) {
669669
}
670670
if (onClientResponseFinishChannel.hasSubscribers) {
671671
onClientResponseFinishChannel.publish({
672-
request: req,
672+
__proto__: null, request: req,
673673
response: res,
674674
});
675675
}
676676
if (isTraceHTTPEnabled() && typeof req._traceEventId === 'number') {
677677
traceEnd(HTTP_CLIENT_TRACE_EVENT_NAME, req._traceEventId, {
678-
path: req.path,
678+
__proto__: null, path: req.path,
679679
statusCode: res.statusCode,
680680
});
681681
}

lib/_http_incoming.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function IncomingMessage(socket) {
5555

5656
if (socket) {
5757
streamOptions = {
58-
highWaterMark: socket.readableHighWaterMark,
58+
__proto__: null, highWaterMark: socket.readableHighWaterMark,
5959
};
6060
}
6161

@@ -111,7 +111,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
111111
__proto__: null,
112112
get: function() {
113113
if (!this[kHeaders]) {
114-
this[kHeaders] = {};
114+
this[kHeaders] = { __proto__: null };
115115

116116
const src = this.rawHeaders;
117117
const dst = this[kHeaders];
@@ -131,7 +131,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
131131
__proto__: null,
132132
get: function() {
133133
if (!this[kHeadersDistinct]) {
134-
this[kHeadersDistinct] = {};
134+
this[kHeadersDistinct] = { __proto__: null };
135135

136136
const src = this.rawHeaders;
137137
const dst = this[kHeadersDistinct];
@@ -151,7 +151,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
151151
__proto__: null,
152152
get: function() {
153153
if (!this[kTrailers]) {
154-
this[kTrailers] = {};
154+
this[kTrailers] = { __proto__: null };
155155

156156
const src = this.rawTrailers;
157157
const dst = this[kTrailers];
@@ -171,7 +171,7 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
171171
__proto__: null,
172172
get: function() {
173173
if (!this[kTrailersDistinct]) {
174-
this[kTrailersDistinct] = {};
174+
this[kTrailersDistinct] = { __proto__: null };
175175

176176
const src = this.rawTrailers;
177177
const dst = this[kTrailersDistinct];

lib/_http_outgoing.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() {
284284
}
285285

286286
const headersMap = this[kOutHeaders];
287-
const headers = {};
287+
const headers = { __proto__: null };
288288

289289
if (headersMap !== null) {
290290
const keys = ObjectKeys(headersMap);
@@ -368,7 +368,7 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback, byteL
368368
} else {
369369
const header = this._header;
370370
this.outputData.unshift({
371-
data: header,
371+
__proto__: null, data: header,
372372
encoding: 'latin1',
373373
callback: null,
374374
});
@@ -403,7 +403,7 @@ function _writeRaw(data, encoding, callback, size) {
403403
return conn.write(data, encoding, callback);
404404
}
405405
// Buffer, as long as we're not destroyed.
406-
this.outputData.push({ data, encoding, callback });
406+
this.outputData.push({ __proto__: null, data, encoding, callback });
407407
this.outputSize += data.length;
408408
this._onPendingData(data.length);
409409
return this.outputSize < this[kHighWaterMark];
@@ -415,7 +415,7 @@ function _storeHeader(firstLine, headers) {
415415
// firstLine in the case of request is: 'GET /index.html HTTP/1.1\r\n'
416416
// in the case of response it is: 'HTTP/1.1 200 OK\r\n'
417417
const state = {
418-
connection: false,
418+
__proto__: null, connection: false,
419419
contLen: false,
420420
te: false,
421421
date: false,

lib/_http_server.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const {
108108
} = require('internal/perf/observe');
109109

110110
const STATUS_CODES = {
111-
100: 'Continue', // RFC 7231 6.2.1
111+
__proto__: null, 100: 'Continue', // RFC 7231 6.2.1
112112
101: 'Switching Protocols', // RFC 7231 6.2.2
113113
102: 'Processing', // RFC 2518 10.1 (obsoleted by RFC 4918)
114114
103: 'Early Hints', // RFC 8297 2
@@ -207,11 +207,11 @@ function ServerResponse(req, options) {
207207

208208
if (hasObserver('http')) {
209209
startPerf(this, kServerResponseStatistics, {
210-
type: 'http',
210+
__proto__: null, type: 'http',
211211
name: 'HttpRequest',
212212
detail: {
213-
req: {
214-
method: req.method,
213+
__proto__: null, req: {
214+
__proto__: null, method: req.method,
215215
url: req.url,
216216
headers: req.headers,
217217
},
@@ -229,19 +229,19 @@ ObjectSetPrototypeOf(ServerResponse, OutgoingMessage);
229229
ServerResponse.prototype._finish = function _finish() {
230230
if (this[kServerResponseStatistics] && hasObserver('http')) {
231231
stopPerf(this, kServerResponseStatistics, {
232-
detail: {
233-
res: {
234-
statusCode: this.statusCode,
232+
__proto__: null, detail: {
233+
__proto__: null, res: {
234+
__proto__: null, statusCode: this.statusCode,
235235
statusMessage: this.statusMessage,
236-
headers: typeof this.getHeaders === 'function' ? this.getHeaders() : {},
236+
headers: typeof this.getHeaders === 'function' ? this.getHeaders() : { __proto__: null },
237237
},
238238
},
239239
});
240240
}
241241
OutgoingMessage.prototype._finish.call(this);
242242
if (isTraceHTTPEnabled() && typeof this._traceEventId === 'number') {
243243
const data = {
244-
url: this.req?.url,
244+
__proto__: null, url: this.req?.url,
245245
statusCode: this.statusCode,
246246
};
247247
traceEnd(HTTP_SERVER_TRACE_EVENT_NAME, this._traceEventId, data);
@@ -527,7 +527,7 @@ function Server(options, requestListener) {
527527
storeHTTPOptions.call(this, options);
528528
net.Server.call(
529529
this,
530-
{ allowHalfOpen: true, noDelay: options.noDelay ?? true,
530+
{ __proto__: null, allowHalfOpen: true, noDelay: options.noDelay ?? true,
531531
keepAlive: options.keepAlive,
532532
keepAliveInitialDelay: options.keepAliveInitialDelay,
533533
highWaterMark: options.highWaterMark });
@@ -667,7 +667,7 @@ function connectionListenerInternal(server, socket) {
667667
}
668668

669669
const state = {
670-
onData: null,
670+
__proto__: null, onData: null,
671671
onEnd: null,
672672
onClose: null,
673673
onDrain: null,
@@ -954,7 +954,7 @@ function clearIncoming(req) {
954954
function resOnFinish(req, res, socket, state, server) {
955955
if (onResponseFinishChannel.hasSubscribers) {
956956
onResponseFinishChannel.publish({
957-
request: req,
957+
__proto__: null, request: req,
958958
response: res,
959959
socket,
960960
server,
@@ -1037,7 +1037,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
10371037

10381038
const res = new server[kServerResponse](req,
10391039
{
1040-
highWaterMark: socket.writableHighWaterMark,
1040+
__proto__: null, highWaterMark: socket.writableHighWaterMark,
10411041
rejectNonStandardBodyWrites: server.rejectNonStandardBodyWrites,
10421042
});
10431043
res._keepAliveTimeout = server.keepAliveTimeout;
@@ -1050,7 +1050,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
10501050

10511051
if (onRequestStartChannel.hasSubscribers) {
10521052
onRequestStartChannel.publish({
1053-
request: req,
1053+
__proto__: null, request: req,
10541054
response: res,
10551055
socket,
10561056
server,

lib/_tls_wrap.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ function onPskClientCallback(hint, maxPskLen, maxIdentityLen) {
394394
);
395395
}
396396

397-
return { psk: ret.psk, identity: ret.identity };
397+
return { __proto__: null, psk: ret.psk, identity: ret.identity };
398398
}
399399

400400
function onkeylog(line) {
@@ -468,7 +468,7 @@ function initRead(tlsSocket, socket) {
468468
*/
469469

470470
function TLSSocket(socket, opts) {
471-
const tlsOptions = { ...opts };
471+
const tlsOptions = { __proto__: null, ...opts };
472472
let enableTrace = tlsOptions.enableTrace;
473473

474474
if (enableTrace == null) {
@@ -520,7 +520,7 @@ function TLSSocket(socket, opts) {
520520
this.encrypted = true;
521521

522522
ReflectApply(net.Socket, this, [{
523-
handle: this._wrapHandle(wrap),
523+
__proto__: null, handle: this._wrapHandle(wrap),
524524
allowHalfOpen: socket ? socket.allowHalfOpen : tlsOptions.allowHalfOpen,
525525
pauseOnCreate: tlsOptions.pauseOnConnect,
526526
manualStart: true,
@@ -790,7 +790,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
790790
'by writing secret key material to file ' + tlsKeylog);
791791
}
792792
this.on('keylog', (line) => {
793-
appendFile(tlsKeylog, line, { mode: 0o600 }, (err) => {
793+
appendFile(tlsKeylog, line, { __proto__: null, mode: 0o600 }, (err) => {
794794
if (err && warnOnTlsKeylogError) {
795795
warnOnTlsKeylogError = false;
796796
process.emitWarning('Failed to write TLS keylog (this warning ' +
@@ -1025,7 +1025,7 @@ TLSSocket.prototype.setSession = function(session) {
10251025
TLSSocket.prototype.getPeerCertificate = function(detailed) {
10261026
if (this._handle) {
10271027
return common.translatePeerCertificate(
1028-
this._handle.getPeerCertificate(detailed)) || {};
1028+
this._handle.getPeerCertificate(detailed)) || { __proto__: null };
10291029
}
10301030

10311031
return null;
@@ -1035,7 +1035,7 @@ TLSSocket.prototype.getCertificate = function() {
10351035
if (this._handle) {
10361036
// It's not a peer cert, but the formatting is identical.
10371037
return common.translatePeerCertificate(
1038-
this._handle.getCertificate()) || {};
1038+
this._handle.getCertificate()) || { __proto__: null };
10391039
}
10401040

10411041
return null;
@@ -1126,7 +1126,7 @@ function onSocketClose(err) {
11261126
function tlsConnectionListener(rawSocket) {
11271127
debug('net.Server.on(connection): new TLSSocket');
11281128
const socket = new TLSSocket(rawSocket, {
1129-
secureContext: this._sharedCreds,
1129+
__proto__: null, secureContext: this._sharedCreds,
11301130
isServer: true,
11311131
server: this,
11321132
requestCert: this.requestCert,
@@ -1378,7 +1378,7 @@ Server.prototype.setSecureContext = function(options) {
13781378
this.privateKeyEngine = options.privateKeyEngine;
13791379

13801380
this._sharedCreds = tls.createSecureContext({
1381-
pfx: this.pfx,
1381+
__proto__: null, pfx: this.pfx,
13821382
key: this.key,
13831383
passphrase: this.passphrase,
13841384
cert: this.cert,
@@ -1405,7 +1405,7 @@ Server.prototype.setSecureContext = function(options) {
14051405

14061406
Server.prototype._getServerData = function() {
14071407
return {
1408-
ticketKeys: this.getTicketKeys().toString('hex'),
1408+
__proto__: null, ticketKeys: this.getTicketKeys().toString('hex'),
14091409
};
14101410
};
14111411

@@ -1639,7 +1639,7 @@ exports.connect = function connect(...args) {
16391639
const allowUnauthorized = getAllowUnauthorized();
16401640

16411641
options = {
1642-
rejectUnauthorized: !allowUnauthorized,
1642+
__proto__: null, rejectUnauthorized: !allowUnauthorized,
16431643
ciphers: tls.DEFAULT_CIPHERS,
16441644
checkServerIdentity: tls.checkServerIdentity,
16451645
minDHSize: 1024,
@@ -1659,7 +1659,7 @@ exports.connect = function connect(...args) {
16591659
const context = options.secureContext || tls.createSecureContext(options);
16601660

16611661
const tlssock = new TLSSocket(options.socket, {
1662-
allowHalfOpen: options.allowHalfOpen,
1662+
__proto__: null, allowHalfOpen: options.allowHalfOpen,
16631663
pipe: !!options.path,
16641664
secureContext: context,
16651665
isServer: false,

0 commit comments

Comments
 (0)