Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

improve 'METHOD_DENIED' error message #2127

Merged
merged 5 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions modules/ipc/ipcProviderBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ const log = require('../utils/logger').create('ipcProviderBackend');
const Sockets = require('../socketManager');
const Settings = require('../settings');
const ethereumNode = require('../ethereumNode');
const Windows = require('../windows');


const ERRORS = {
INVALID_PAYLOAD: { code: -32600, message: 'Payload, or some of its content properties are invalid. Please check if they are valid HEX.' },
METHOD_DENIED: { code: -32601, message: "Method \'__method__\' not allowed." },
METHOD_TIMEOUT: { code: -32603, message: "Request timed out for method \'__method__\'." },
METHOD_DENIED: { code: -32601, message: 'Method __method__ not allowed.' },
METHOD_TIMEOUT: { code: -32603, message: 'Request timed out for method __method__.' },
TX_DENIED: { code: -32603, message: 'Transaction denied' },
BATCH_TX_DENIED: { code: -32603, message: 'Transactions denied, sendTransaction is not allowed in batch requests.' },
BATCH_COMPILE_DENIED: { code: -32603, message: 'Compilation denied, compileSolidity is not allowed in batch requests.' },
Expand Down
8 changes: 4 additions & 4 deletions modules/ipc/methods/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ module.exports = class BaseProcessor {
}

// prevent dapps from acccesing admin endpoints
if (!/^eth_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
if (!/^eth_|^bzz_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
delete payload.result;

payload.error = this.ERRORS.METHOD_DENIED;
const err = this.ERRORS.METHOD_DENIED;
err.message = err.message.replace(/__method__/, payload.method);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess a simple string replace '__method__' would be enough here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we are not modifying the original object?

payload.error = err;
}
}
};