From fc65ddfc44fa95cc42d8f8629524cddd0de767f0 Mon Sep 17 00:00:00 2001 From: Antony Denyer Date: Thu, 30 Sep 2021 12:41:45 +0100 Subject: [PATCH] Prevent rpc endpoints from being overridden Signed-off-by: Antony Denyer --- .../main/java/org/hyperledger/besu/RunnerBuilder.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index c149cfb749b..ee69acf9be9 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -863,7 +863,16 @@ private Map jsonRpcMethods( dataDir, besuController.getProtocolManager().ethContext().getEthPeers()); methods.putAll(besuController.getAdditionalJsonRpcMethods(jsonRpcApis)); - methods.putAll(rpcEndpointServiceImpl.getPluginMethods(jsonRpcConfiguration.getRpcApis())); + + var pluginMethods = rpcEndpointServiceImpl.getPluginMethods(jsonRpcConfiguration.getRpcApis()); + + var overriddenMethods = + methods.keySet().stream().filter(pluginMethods::containsKey).collect(Collectors.toList()); + if (overriddenMethods.size() > 0) { + throw new RuntimeException("You can not override built in methods " + overriddenMethods); + } + + methods.putAll(pluginMethods); return methods; }