Skip to content

Commit

Permalink
Most of codacy warnings resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Snafkin547 committed Jun 10, 2024
1 parent 98998b4 commit 241215a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/client/socket/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,22 @@ class SocketEvent {
} else {
// key must not exist yet for sender_id, and encrypted must be true
if (this.jiffClient.messagesWaitingKeys[sender_id] == null) {
this.jiffClient.messagesWaitingKeys[sender_id] = [];
this.jiffClient.messagesWaitingKeys[String(sender_id)] = [];
}
this.jiffClient.messagesWaitingKeys[String(sender_id)].push({ label: 'custom', msg: json_msg });
}
});

this.jiffClient.socket.on('crypto_provider', (msg, callback) => {
this.jiffClient.socket.on('crypto_provider', (_msg, callback) => {
callback(true); // send ack to server
this.jiffClient.handlers.receive_crypto_provider(JSON.parse(String(msg)));
const msg = JSON.parse(String(_msg));

Check failure on line 85 in lib/client/socket/events.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/client/socket/events.js#L85

Passing untrusted user input in `xpath.parse()` can result in XPATH injection vulnerability.
this.jiffClient.handlers.receive_crypto_provider(msg);
});

this.jiffClient.socket.on('error', (_msg) => {

Check warning on line 89 in lib/client/socket/events.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/client/socket/events.js#L89

Detect inappropriate function body content
try {
const msg = JSON.parse(_msg);
this.jiffClient.handlers.error(msg['label'], msg['error']);
} catch (error) {
this.jiffClient.handlers.error('socket.io', _msg);
throw new Error('socket.io' + _msg);
}
const msg = JSON.parse(_msg);
this.jiffClient.handlers.error(msg['label'], msg['error']);
this.jiffClient.handlers.error('socket.io', _msg);
});

this.jiffClient.socket.on('disconnect', (reason) => {
Expand Down Expand Up @@ -146,7 +143,7 @@ class SocketEvent {
*/
resolve_messages_waiting_for_keys() {
for (let party_id in this.jiffClient.keymap) {
if (!this.jiffClient.keymap.hasOwnProperty(String(party_id))) {
if (!Object.prototype.hasOwnProperty.call(this.jiffClient.keymap, String(party_id))) {
continue;
}

Expand Down

0 comments on commit 241215a

Please sign in to comment.