Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _safe_decode_message_body(fullMessageBody: Buffer, objMessage: any, binaryStream: BinaryStream) {
try {
// de-serialize the object from the binary stream
const options = this.objectFactory;
objMessage.decode(binaryStream, options);
} catch (err) {
console.log(err);
console.log(err.stack);
console.log(hexDump(fullMessageBody));
analyseExtensionObject(fullMessageBody, 0, 0);
console.log(" ---------------- block");
let i = 0;
this.messageChunks.forEach((messageChunk) => {
console.log(" ---------------- chunk i=", i++);
console.log(hexDump(messageChunk));
});
return false;
}
return true;
}
}
channelId: this.securityToken.channelId,
chunkSize: this.transport.receiveBufferSize,
requestId,
tokenId: this.securityToken.tokenId
};
const securityOptions =
msgType === "OPN" ? this._get_security_options_for_OPN() : this._get_security_options_for_MSG();
options = _.extend(options, securityOptions);
response.responseHeader.requestHandle = request.requestHeader.requestHandle;
/* istanbul ignore next */
if (0 && doDebug) {
console.log(" options ", options);
analyze_object_binary_encoding(response as any as BaseUAObject);
}
/* istanbul ignore next */
if (doTraceMessage) {
console.log(
chalk.cyan.bold("xxxx >>>> ---------------------------------------- "),
chalk.green.bold(response.schema.name),
requestId
);
console.log(response.toString());
console.log(chalk.cyan.bold("xxxx >>>> ----------------------------------------|\n"));
}
if (this._on_response) {
this._on_response(msgType, response, message);
}
};
assert(options.secureChannelId > 0);
const security_options =
msgType === "OPN" ? self._get_security_options_for_OPN() : self._get_security_options_for_MSG();
options = _.extend(options, security_options);
//xx assert(_.isFinite(request.requestHeader.requestHandle));
response.responseHeader.requestHandle = request.requestHeader.requestHandle;
/* istanbul ignore next */
if (0 && doDebug) {
console.log(" options ", options);
analyze_object_binary_encoding(response);
}
//xx console.log(" sending request ".bgWhite.red,requestId,message.request.constructor.name);
/* istanbul ignore next */
if (do_trace_message) {
console.log(
"xxxx >>>> ---------------------------------------- ".cyan.bold,
response._schema.name.green.bold,
requestId
);
console.log(response.toString());
console.log("xxxx >>>> ----------------------------------------|\n".cyan.bold);
}
if (self._on_response) {
MessageBuilder.prototype._safe_decode_message_body = function (full_message_body, objMessage, binaryStream) {
try {
// de-serialize the object from the binary stream
const options = this.objectFactory;
objMessage.decode(binaryStream, options);
}
catch (err) {
console.log(err);
console.log(err.stack);
console.log(hexDump(full_message_body));
packet_analyzer(full_message_body);
console.log(" ---------------- block");
let i=0;
this.message_chunks.forEach(function (messageChunk) {
console.log(" ---------------- chunk i=",i++);
console.log(hexDump(messageChunk));
});
return false;
}
return true;
};
}
assert(replies.length >= 1, " expecting at least one reply " + JSON.stringify(reply));
replies.forEach((reply1: any) => {
debugLog("\nFAKE SERVER SEND");
debugLog(chalk.red(hexDump(reply1)));
this._mockTransport.server.write(reply1);
});
} else {
const msg = " MockServerTransport has no more packets to send to client to" +
" emulate server responses.... ";
console.log(chalk.red.bold(msg));
console.log(chalk.blue.bold(hexDump(data)));
display_trace_from_this_projet_only();
analyseExtensionObject(data, 0, 0, {});
this.emit("done");
}
});
}
messageBuilder.on("full_message_body", (fullMessageBody: Buffer) => {
console.log("full_message_body received:");
analyseExtensionObject(fullMessageBody, 0, 0);
});
messageBuilder.on("start_chunk", (info) => {
messageBuilder.on("full_message_body", function (full_message_body) {
console.log("full_message_body received:");
packet_analyzer(full_message_body);
});
messageBuilder.on("start_chunk", function (info, data) {