Replace whitelist/blacklist with allowlist/denylist (#1077)

* replace whitelist/blacklist with allowlist/denylist and support both versions in CLI options

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/1083/head
Sally MacFarlane 5 years ago committed by GitHub
parent 165be86aa9
commit 4eef568b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/perm/AllowListContainsKeyAndValue.java
  2. 44
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/perm/PermissioningConditions.java
  3. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java
  4. 6
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  5. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/NodeConfigurationFactory.java
  6. 24
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/permissioning/PermissionedNodeBuilder.java
  7. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/perm/PermissioningTransactions.java
  8. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java
  9. 46
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java
  10. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java
  11. 14
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java
  12. 4
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbftStallAcceptanceTest.java
  13. 4
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  14. 28
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  15. 30
      besu/src/main/java/org/hyperledger/besu/cli/custom/JsonRPCAllowlistHostsProperty.java
  16. 10
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java
  17. 23
      besu/src/main/java/org/hyperledger/besu/util/PermissioningConfigurationValidator.java
  18. 4
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  19. 52
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  20. 20
      besu/src/test/java/org/hyperledger/besu/util/LocalPermissioningConfigurationValidatorTest.java
  21. 4
      consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/StubValidatorMulticaster.java
  22. 4
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/UniqueMessageMulticaster.java
  23. 2
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/ValidatorMulticaster.java
  24. 4
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/network/ValidatorPeers.java
  25. 10
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/UniqueMessageMulticasterTest.java
  26. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java
  27. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java
  28. 16
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java
  29. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelist.java
  30. 18
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromAllowlist.java
  31. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PermJsonRpcMethods.java
  32. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketConfiguration.java
  33. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpServiceHostWhitelistTest.java
  34. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostWhitelistTest.java
  35. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
  36. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java
  37. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
  38. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
  39. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
  40. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddAccountsToWhitelistTest.java
  41. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java
  42. 18
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveAccountsFromAllowlistTest.java
  43. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java
  44. 16
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostWhitelistTest.java
  45. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
  46. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceTest.java
  47. 4
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/DefaultP2PNetwork.java
  48. 6
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManager.java
  49. 14
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsDenylist.java
  50. 4
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/PeerDiscoveryAgentTest.java
  51. 8
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/PeerDiscoveryControllerTest.java
  52. 4
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/network/P2PNetworkTest.java
  53. 8
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/network/PeerReputationManagerTest.java
  54. 20
      ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/permissions/PeerPermissionsDenylistTest.java
  55. 68
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java
  56. 2
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AllowlistFileSyncException.java
  57. 2
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AllowlistOperationResult.java
  58. 60
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistor.java
  59. 44
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfiguration.java
  60. 64
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java
  61. 4
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodePermissioningControllerFactory.java
  62. 6
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java
  63. 24
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/SmartContractPermissioningConfiguration.java
  64. 4
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactory.java
  65. 108
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningControllerTest.java
  66. 36
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java
  67. 32
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java
  68. 32
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java
  69. 50
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java
  70. 18
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/account/AccountPermissioningControllerFactoryTest.java
  71. 12
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/node/NodePermissioningControllerFactoryTest.java
  72. 4
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java
  73. 16
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java
  74. 2
      metrics/core/src/test/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpServiceTest.java

@ -16,24 +16,25 @@ package org.hyperledger.besu.tests.acceptance.dsl.condition.perm;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import java.nio.file.Path;
import java.util.Collection;
public class WhiteListContainsKeyAndValue implements Condition {
private final WhitelistPersistor.WHITELIST_TYPE whitelistType;
private final Collection<String> whitelistValues;
public class AllowListContainsKeyAndValue implements Condition {
private final ALLOWLIST_TYPE allowlistType;
private final Collection<String> allowlistValues;
private final Path configFilePath;
public WhiteListContainsKeyAndValue(
final WhitelistPersistor.WHITELIST_TYPE whitelistType,
final Collection<String> whitelistValues,
public AllowListContainsKeyAndValue(
final ALLOWLIST_TYPE allowlistType,
final Collection<String> allowlistValues,
final Path configFilePath) {
this.whitelistType = whitelistType;
this.whitelistValues = whitelistValues;
this.allowlistType = allowlistType;
this.allowlistValues = allowlistValues;
this.configFilePath = configFilePath;
}
@ -42,8 +43,8 @@ public class WhiteListContainsKeyAndValue implements Condition {
boolean result;
try {
result =
WhitelistPersistor.verifyConfigFileMatchesState(
whitelistType, whitelistValues, configFilePath);
AllowlistPersistor.verifyConfigFileMatchesState(
allowlistType, allowlistValues, configFilePath);
} catch (final Exception e) {
result = false;
}

@ -17,7 +17,7 @@ package org.hyperledger.besu.tests.acceptance.dsl.condition.perm;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode;
@ -36,53 +36,53 @@ public class PermissioningConditions {
private final PermissioningTransactions transactions;
public Condition addAccountsToWhitelist(final String... accounts) {
return new AddAccountsToWhitelistSuccessfully(transactions.addAccountsToWhitelist(accounts));
public Condition addAccountsToAllowlist(final String... accounts) {
return new AddAccountsToWhitelistSuccessfully(transactions.addAccountsToAllowlist(accounts));
}
public Condition removeAccountsFromWhitelist(final String... accounts) {
public Condition removeAccountsFromAllowlist(final String... accounts) {
return new RemoveAccountsFromWhitelistSuccessfully(
transactions.removeAccountsFromWhitelist(accounts));
transactions.removeAccountsFromAllowlist(accounts));
}
public Condition expectAccountsWhitelist(final String... expectedAccounts) {
public Condition expectAccountsAllowlist(final String... expectedAccounts) {
return new GetExpectedAccountsWhitelist(
transactions.getAccountsWhiteList(), asList(expectedAccounts));
}
public Condition addNodesToWhitelist(final String... nodes) {
return addNodesToWhitelist(Stream.of(nodes).map(URI::create).collect(toList()));
public Condition addNodesToAllowlist(final String... nodes) {
return addNodesToAllowlist(Stream.of(nodes).map(URI::create).collect(toList()));
}
public Condition addNodesToWhitelist(final Node... nodes) {
public Condition addNodesToAllowlist(final Node... nodes) {
final List<URI> enodeList = toEnodeUris(nodes);
return addNodesToWhitelist(enodeList);
return addNodesToAllowlist(enodeList);
}
private Condition addNodesToWhitelist(final List<URI> enodeList) {
return new AddNodeSuccess(transactions.addNodesToWhitelist(enodeList));
private Condition addNodesToAllowlist(final List<URI> enodeList) {
return new AddNodeSuccess(transactions.addNodesToAllowlist(enodeList));
}
public Condition removeNodesFromWhitelist(final String... nodes) {
return removeNodesFromWhitelist(Stream.of(nodes).map(URI::create).collect(toList()));
public Condition removeNodesFromAllowlist(final String... nodes) {
return removeNodesFromAllowlist(Stream.of(nodes).map(URI::create).collect(toList()));
}
public Condition removeNodesFromWhitelist(final Node... nodes) {
public Condition removeNodesFromAllowlist(final Node... nodes) {
final List<URI> enodeList = toEnodeUris(nodes);
return removeNodesFromWhitelist(enodeList);
return removeNodesFromAllowlist(enodeList);
}
private Condition removeNodesFromWhitelist(final List<URI> enodeList) {
return new RemoveNodeSuccess(transactions.removeNodesFromWhitelist(enodeList));
private Condition removeNodesFromAllowlist(final List<URI> enodeList) {
return new RemoveNodeSuccess(transactions.removeNodesFromAllowlist(enodeList));
}
public Condition getNodesWhitelist(final int expectedNodeNum) {
public Condition getNodesAllowlist(final int expectedNodeNum) {
return new GetNodesWhitelistPopulated(transactions.getNodesWhiteList(), expectedNodeNum);
}
public Condition expectPermissioningWhitelistFileKeyValue(
final WHITELIST_TYPE whitelistType, final Path configFilePath, final String... val) {
return new WhiteListContainsKeyAndValue(whitelistType, asList(val), configFilePath);
public Condition expectPermissioningAllowlistFileKeyValue(
final ALLOWLIST_TYPE allowlistType, final Path configFilePath, final String... val) {
return new AllowListContainsKeyAndValue(allowlistType, asList(val), configFilePath);
}
private List<URI> toEnodeUris(final Node[] nodes) {

@ -237,14 +237,14 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
.flatMap(PermissioningConfiguration::getLocalConfig)
.ifPresent(
permissioningConfiguration -> {
if (permissioningConfiguration.isNodeWhitelistEnabled()) {
if (permissioningConfiguration.isNodeAllowlistEnabled()) {
params.add("--permissions-nodes-config-file-enabled");
}
if (permissioningConfiguration.getNodePermissioningConfigFilePath() != null) {
params.add("--permissions-nodes-config-file");
params.add(permissioningConfiguration.getNodePermissioningConfigFilePath());
}
if (permissioningConfiguration.isAccountWhitelistEnabled()) {
if (permissioningConfiguration.isAccountAllowlistEnabled()) {
params.add("--permissions-accounts-config-file-enabled");
}
if (permissioningConfiguration.getAccountPermissioningConfigFilePath() != null) {
@ -257,14 +257,14 @@ public class ProcessBesuNodeRunner implements BesuNodeRunner {
.flatMap(PermissioningConfiguration::getSmartContractConfig)
.ifPresent(
permissioningConfiguration -> {
if (permissioningConfiguration.isSmartContractNodeWhitelistEnabled()) {
if (permissioningConfiguration.isSmartContractNodeAllowlistEnabled()) {
params.add("--permissions-nodes-contract-enabled");
}
if (permissioningConfiguration.getNodeSmartContractAddress() != null) {
params.add("--permissions-nodes-contract-address");
params.add(permissioningConfiguration.getNodeSmartContractAddress().toString());
}
if (permissioningConfiguration.isSmartContractAccountWhitelistEnabled()) {
if (permissioningConfiguration.isSmartContractAccountAllowlistEnabled()) {
params.add("--permissions-accounts-contract-enabled");
}
if (permissioningConfiguration.getAccountSmartContractAddress() != null) {

@ -101,7 +101,7 @@ public class BesuNodeConfigurationBuilder {
public BesuNodeConfigurationBuilder jsonRpcEnabled() {
this.jsonRpcConfiguration.setEnabled(true);
this.jsonRpcConfiguration.setPort(0);
this.jsonRpcConfiguration.setHostsWhitelist(singletonList("*"));
this.jsonRpcConfiguration.setHostsAllowlist(singletonList("*"));
return this;
}
@ -111,7 +111,7 @@ public class BesuNodeConfigurationBuilder {
MetricsConfiguration.builder()
.enabled(true)
.port(0)
.hostsWhitelist(singletonList("*"))
.hostsAllowlist(singletonList("*"))
.build();
return this;
@ -168,7 +168,7 @@ public class BesuNodeConfigurationBuilder {
final WebSocketConfiguration config = WebSocketConfiguration.createDefault();
config.setEnabled(true);
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
this.webSocketConfiguration = config;
return this;

@ -59,7 +59,7 @@ public class NodeConfigurationFactory {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setEnabled(true);
config.setPort(0);
config.setHostsWhitelist(singletonList("*"));
config.setHostsAllowlist(singletonList("*"));
return config;
}

@ -21,11 +21,11 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApi;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration;
import org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor;
import org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE;
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode;
@ -212,9 +212,9 @@ public class PermissionedNodeBuilder {
List<String> nodesAsListOfStrings =
localConfigPermittedNodes.stream().map(URI::toASCIIString).collect(Collectors.toList());
initPermissioningConfigurationFile(
WHITELIST_TYPE.NODES, nodesAsListOfStrings, localConfigNodesPermissioningFile);
ALLOWLIST_TYPE.NODES, nodesAsListOfStrings, localConfigNodesPermissioningFile);
localPermissioningConfiguration.setNodeWhitelist(localConfigPermittedNodes);
localPermissioningConfiguration.setNodeAllowlist(localConfigPermittedNodes);
localPermissioningConfiguration.setNodePermissioningConfigFilePath(
localConfigNodesPermissioningFile.toAbsolutePath().toString());
}
@ -225,11 +225,11 @@ public class PermissionedNodeBuilder {
}
initPermissioningConfigurationFile(
WHITELIST_TYPE.ACCOUNTS,
ALLOWLIST_TYPE.ACCOUNTS,
localConfigPermittedAccounts,
localConfigAccountsPermissioningFile);
localPermissioningConfiguration.setAccountWhitelist(localConfigPermittedAccounts);
localPermissioningConfiguration.setAccountAllowlist(localConfigPermittedAccounts);
localPermissioningConfiguration.setAccountPermissioningConfigFilePath(
localConfigAccountsPermissioningFile.toAbsolutePath().toString());
}
@ -243,13 +243,13 @@ public class PermissionedNodeBuilder {
if (nodePermissioningSmartContractAddress != null) {
config.setNodeSmartContractAddress(
Address.fromHexString(nodePermissioningSmartContractAddress));
config.setSmartContractNodeWhitelistEnabled(true);
config.setSmartContractNodeAllowlistEnabled(true);
}
if (accountPermissioningSmartContractAddress != null) {
config.setAccountSmartContractAddress(
Address.fromHexString(accountPermissioningSmartContractAddress));
config.setSmartContractAccountWhitelistEnabled(true);
config.setSmartContractAccountAllowlistEnabled(true);
}
return config;
@ -270,7 +270,7 @@ public class PermissionedNodeBuilder {
final JsonRpcConfiguration jsonRpcConfig = JsonRpcConfiguration.createDefault();
jsonRpcConfig.setEnabled(true);
jsonRpcConfig.setPort(0);
jsonRpcConfig.setHostsWhitelist(singletonList("*"));
jsonRpcConfig.setHostsAllowlist(singletonList("*"));
jsonRpcConfig.setCorsAllowedDomains(singletonList("*"));
final List<RpcApi> rpcApis = new ArrayList<>(jsonRpcConfig.getRpcApis());
rpcApis.add(RpcApis.PERM);
@ -280,11 +280,11 @@ public class PermissionedNodeBuilder {
}
private void initPermissioningConfigurationFile(
final WhitelistPersistor.WHITELIST_TYPE listType,
final Collection<String> whitelistVal,
final ALLOWLIST_TYPE listType,
final Collection<String> allowlistVal,
final Path configFilePath) {
try {
WhitelistPersistor.addNewConfigItem(listType, whitelistVal, configFilePath);
AllowlistPersistor.addNewConfigItem(listType, allowlistVal, configFilePath);
Files.write(
configFilePath,

@ -22,11 +22,11 @@ import java.util.List;
public class PermissioningTransactions {
public PermAddAccountsToWhitelistTransaction addAccountsToWhitelist(final String... accounts) {
public PermAddAccountsToWhitelistTransaction addAccountsToAllowlist(final String... accounts) {
return new PermAddAccountsToWhitelistTransaction(Arrays.asList(accounts));
}
public PermRemoveAccountsFromWhitelistTransaction removeAccountsFromWhitelist(
public PermRemoveAccountsFromWhitelistTransaction removeAccountsFromAllowlist(
final String... accounts) {
return new PermRemoveAccountsFromWhitelistTransaction(Arrays.asList(accounts));
}
@ -35,11 +35,11 @@ public class PermissioningTransactions {
return new PermGetAccountsWhitelistTransaction();
}
public PermAddNodeTransaction addNodesToWhitelist(final List<URI> enodeList) {
public PermAddNodeTransaction addNodesToAllowlist(final List<URI> enodeList) {
return new PermAddNodeTransaction(enodeList);
}
public PermRemoveNodeTransaction removeNodesFromWhitelist(final List<URI> enodeList) {
public PermRemoveNodeTransaction removeNodesFromAllowlist(final List<URI> enodeList) {
return new PermRemoveNodeTransaction(enodeList);
}

@ -56,20 +56,20 @@ public class AccountLocalConfigPermissioningAcceptanceTest extends AcceptanceTes
}
@Test
public void manipulatingAccountsWhitelistViaJsonRpc() {
public void manipulatingAccountsAllowlistViaJsonRpc() {
Account beneficiary = accounts.createAccount("beneficiary");
node.verify(beneficiary.balanceEquals(0));
verifyTransferForbidden(senderB, beneficiary);
node.execute(permissioningTransactions.addAccountsToWhitelist(senderB.getAddress()));
node.verify(perm.expectAccountsWhitelist(senderA.getAddress(), senderB.getAddress()));
node.execute(permissioningTransactions.addAccountsToAllowlist(senderB.getAddress()));
node.verify(perm.expectAccountsAllowlist(senderA.getAddress(), senderB.getAddress()));
node.execute(accountTransactions.createTransfer(senderB, beneficiary, 1));
node.verify(beneficiary.balanceEquals(1));
node.execute(permissioningTransactions.removeAccountsFromWhitelist(senderB.getAddress()));
node.verify(perm.expectAccountsWhitelist(senderA.getAddress()));
node.execute(permissioningTransactions.removeAccountsFromAllowlist(senderB.getAddress()));
node.verify(perm.expectAccountsAllowlist(senderA.getAddress()));
verifyTransferForbidden(senderB, beneficiary);
}

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.tests.acceptance.permissioning;
import static org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE;
import static org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
@ -28,7 +28,7 @@ import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
public class WhitelistPersistorAcceptanceTest extends AcceptanceTestBase {
public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase {
private static final String ENODE_ONE =
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.10:4567";
@ -63,40 +63,40 @@ public class WhitelistPersistorAcceptanceTest extends AcceptanceTestBase {
@Test
public void manipulatedAccountsWhitelistIsPersisted() {
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(
WHITELIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress()));
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress()));
node.execute(permissioningTransactions.addAccountsToWhitelist(senderB.getAddress()));
node.verify(perm.expectAccountsWhitelist(senderA.getAddress(), senderB.getAddress()));
node.execute(permissioningTransactions.addAccountsToAllowlist(senderB.getAddress()));
node.verify(perm.expectAccountsAllowlist(senderA.getAddress(), senderB.getAddress()));
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(
WHITELIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress(), senderB.getAddress()));
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress(), senderB.getAddress()));
node.execute(permissioningTransactions.removeAccountsFromWhitelist(senderB.getAddress()));
node.verify(perm.expectAccountsWhitelist(senderA.getAddress()));
node.execute(permissioningTransactions.removeAccountsFromAllowlist(senderB.getAddress()));
node.verify(perm.expectAccountsAllowlist(senderA.getAddress()));
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(
WHITELIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress()));
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress()));
node.execute(permissioningTransactions.removeAccountsFromWhitelist(senderA.getAddress()));
node.verify(perm.expectAccountsWhitelist());
node.verify(perm.expectPermissioningWhitelistFileKeyValue(WHITELIST_TYPE.ACCOUNTS, tempFile));
node.execute(permissioningTransactions.removeAccountsFromAllowlist(senderA.getAddress()));
node.verify(perm.expectAccountsAllowlist());
node.verify(perm.expectPermissioningAllowlistFileKeyValue(ALLOWLIST_TYPE.ACCOUNTS, tempFile));
}
@Test
public void manipulatedNodesWhitelistIsPersisted() {
node.verify(perm.addNodesToWhitelist(ENODE_ONE, ENODE_TWO));
node.verify(perm.addNodesToAllowlist(ENODE_ONE, ENODE_TWO));
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(
WHITELIST_TYPE.NODES, tempFile, ENODE_ONE, ENODE_TWO));
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.NODES, tempFile, ENODE_ONE, ENODE_TWO));
node.verify(perm.removeNodesFromWhitelist(ENODE_ONE));
node.verify(perm.removeNodesFromAllowlist(ENODE_ONE));
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(WHITELIST_TYPE.NODES, tempFile, ENODE_TWO));
perm.expectPermissioningAllowlistFileKeyValue(ALLOWLIST_TYPE.NODES, tempFile, ENODE_TWO));
node.verify(perm.addNodesToWhitelist(ENODE_ONE, ENODE_THREE));
node.verify(perm.addNodesToAllowlist(ENODE_ONE, ENODE_THREE));
node.verify(
perm.expectPermissioningWhitelistFileKeyValue(
WHITELIST_TYPE.NODES, tempFile, ENODE_TWO, ENODE_ONE, ENODE_THREE));
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.NODES, tempFile, ENODE_TWO, ENODE_ONE, ENODE_THREE));
}
}

@ -37,7 +37,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
}
@Test
public void testNodeCannotConnectWhenWhiteListedOnChainButNotLocal() {
public void testNodeCannotConnectWhnAllowlistedOnChainButNotLocal() {
// add permissioned node after cluster start because we need enode URI for local config
permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode);
@ -60,9 +60,9 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
}
@Test
public void testNodeCannotConnectWhenWhitelistedLocalButNotOnChain() {
// onchain whitelist: A, B
// local whitelist: A, B, C
public void testNodeCannotConnectWhenAllowlistedLocalButNotOnChain() {
// onchain allowlist: A, B
// local allowlist: A, B, C
// add permissioned node after cluster start because we need enode URI for local config
permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode, forbiddenNode);
@ -82,7 +82,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest
}
@Test
public void testNodesCanConnectWhenWhitelistedBothOnChainAndLocal() {
public void testNodesCanConnectWhenAllowlistedBothOnChainAndLocal() {
// add permissioned node after cluster start because we need enode URI for local config
permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode, forbiddenNode);
permissionedCluster.addNode(permissionedNode);

@ -58,12 +58,12 @@ public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBa
}
@Test
public void permissionedNodeShouldDisconnectFromNodeRemovedFromWhitelist() {
public void permissionedNodeShouldDisconnectFromNodeRemovedFromAllowlist() {
permissionedNode.verify(net.awaitPeerCount(2));
// remove node from the whitelist
permissionedNode.verify(perm.removeNodesFromWhitelist(allowedNode));
permissionedNode.verify(perm.getNodesWhitelist(1));
// remove node from the allowlist
permissionedNode.verify(perm.removeNodesFromAllowlist(allowedNode));
permissionedNode.verify(perm.getNodesAllowlist(1));
permissionedNode.verify(net.awaitPeerCount(1));
}
@ -72,9 +72,9 @@ public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBa
public void forbiddenNodeAddedToWhitelistCanConnectToPermissionedNode() {
permissionedNode.verify(net.awaitPeerCount(2));
// add node to the whitelist
permissionedNode.verify(perm.addNodesToWhitelist(forbiddenNode));
permissionedNode.verify(perm.getNodesWhitelist(3));
// add node to the allowlist
permissionedNode.verify(perm.addNodesToAllowlist(forbiddenNode));
permissionedNode.verify(perm.getNodesAllowlist(3));
permissionedNode.verify(admin.addPeer(forbiddenNode));
permissionedNode.verify(net.awaitPeerCount(3));

@ -41,7 +41,7 @@ public class NodeSmartContractPermissioningIbftStallAcceptanceTest
// make sure we are producing blocks before sending any transactions
waitForBlockHeight(bootnode, 1);
// update onchain smart contract to whitelist nodes
// allow nodes in onchain smart contract
nodeA.execute(allowNode(bootnode));
nodeA.execute(allowNode(nodeA));
nodeA.execute(allowNode(nodeB));
@ -56,7 +56,7 @@ public class NodeSmartContractPermissioningIbftStallAcceptanceTest
// Create permissioning config
final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration =
new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString(CONTRACT_ADDRESS));
final PermissioningConfiguration permissioningConfiguration =

@ -72,7 +72,7 @@ import org.hyperledger.besu.ethereum.p2p.network.ProtocolManager;
import org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.SubProtocol;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
@ -337,7 +337,7 @@ public class RunnerBuilder {
.setFractionRemoteWireConnectionsAllowed(fractionRemoteConnectionsAllowed);
networkingConfiguration.setRlpx(rlpxConfiguration).setDiscovery(discoveryConfiguration);
final PeerPermissionsBlacklist bannedNodes = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist bannedNodes = PeerPermissionsDenylist.create();
bannedNodeIds.forEach(bannedNodes::add);
final List<EnodeURL> bootnodes = discoveryConfiguration.getBootnodes();

@ -44,7 +44,7 @@ import org.hyperledger.besu.cli.converter.MetricCategoryConverter;
import org.hyperledger.besu.cli.converter.PercentageConverter;
import org.hyperledger.besu.cli.converter.RpcApisConverter;
import org.hyperledger.besu.cli.custom.CorsAllowedOriginsProperty;
import org.hyperledger.besu.cli.custom.JsonRPCWhitelistHostsProperty;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.cli.custom.RpcAuthFileValidator;
import org.hyperledger.besu.cli.error.BesuExceptionHandler;
import org.hyperledger.besu.cli.options.EthProtocolOptions;
@ -692,12 +692,12 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private String metricsPrometheusJob = "besu-client";
@Option(
names = {"--host-whitelist"},
names = {"--host-allowlist", "--host-whitelist"},
paramLabel = "<hostname>[,<hostname>...]... or * or all",
description =
"Comma separated list of hostnames to whitelist for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
"Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
defaultValue = "localhost,127.0.0.1")
private final JsonRPCWhitelistHostsProperty hostsWhitelist = new JsonRPCWhitelistHostsProperty();
private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty();
@Option(
names = {"--logging", "-l"},
@ -1369,13 +1369,13 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
ethNetworkConfig.getBootNodes().stream().map(EnodeURL::toURI).collect(Collectors.toList());
permissioningConfiguration
.flatMap(PermissioningConfiguration::getLocalConfig)
.ifPresent(p -> ensureAllNodesAreInWhitelist(enodeURIs, p));
.ifPresent(p -> ensureAllNodesAreInAllowlist(enodeURIs, p));
permissioningConfiguration
.flatMap(PermissioningConfiguration::getLocalConfig)
.ifPresent(
p ->
ensureAllNodesAreInWhitelist(
ensureAllNodesAreInAllowlist(
staticNodes.stream().map(EnodeURL::toURI).collect(Collectors.toList()), p));
metricsConfiguration = metricsConfiguration();
@ -1389,11 +1389,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return network == null ? MAINNET : network;
}
private void ensureAllNodesAreInWhitelist(
private void ensureAllNodesAreInAllowlist(
final Collection<URI> enodeAddresses,
final LocalPermissioningConfiguration permissioningConfiguration) {
try {
PermissioningConfigurationValidator.areAllNodesAreInWhitelist(
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(
enodeAddresses, permissioningConfiguration);
} catch (final Exception e) {
throw new ParameterException(this.commandLine, e.getMessage());
@ -1462,7 +1462,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
graphQLConfiguration.setEnabled(isGraphQLHttpEnabled);
graphQLConfiguration.setHost(graphQLHttpHost);
graphQLConfiguration.setPort(graphQLHttpPort);
graphQLConfiguration.setHostsWhitelist(hostsWhitelist);
graphQLConfiguration.setHostsAllowlist(hostsAllowlist);
graphQLConfiguration.setCorsAllowedDomains(graphQLHttpCorsAllowedOrigins);
graphQLConfiguration.setHttpTimeoutSec(httpTimeoutSec);
@ -1508,7 +1508,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
jsonRpcConfiguration.setPort(rpcHttpPort);
jsonRpcConfiguration.setCorsAllowedDomains(rpcHttpCorsAllowedOrigins);
jsonRpcConfiguration.setRpcApis(rpcHttpApis.stream().distinct().collect(Collectors.toList()));
jsonRpcConfiguration.setHostsWhitelist(hostsWhitelist);
jsonRpcConfiguration.setHostsAllowlist(hostsAllowlist);
jsonRpcConfiguration.setAuthenticationEnabled(isRpcHttpAuthenticationEnabled);
jsonRpcConfiguration.setAuthenticationCredentialsFile(rpcHttpAuthenticationCredentialsFile());
jsonRpcConfiguration.setAuthenticationPublicKeyFile(rpcHttpAuthenticationPublicKeyFile);
@ -1631,7 +1631,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
webSocketConfiguration.setRpcApis(rpcWsApis);
webSocketConfiguration.setAuthenticationEnabled(isRpcWsAuthenticationEnabled);
webSocketConfiguration.setAuthenticationCredentialsFile(rpcWsAuthenticationCredentialsFile());
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsAllowlist);
webSocketConfiguration.setAuthenticationPublicKeyFile(rpcWsAuthenticationPublicKeyFile);
return webSocketConfiguration;
}
@ -1672,7 +1672,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.pushHost(metricsPushHost)
.pushPort(metricsPushPort)
.pushInterval(metricsPushInterval)
.hostsWhitelist(hostsWhitelist)
.hostsAllowlist(hostsAllowlist)
.prometheusJob(metricsPrometheusJob)
.build();
}
@ -1724,7 +1724,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
this.commandLine,
"No node permissioning contract address specified. Cannot enable smart contract based node permissioning.");
} else {
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(
permissionsNodesContractEnabled);
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
permissionsNodesContractAddress);
@ -1741,7 +1741,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
this.commandLine,
"No account permissioning contract address specified. Cannot enable smart contract based account permissioning.");
} else {
smartContractPermissioningConfiguration.setSmartContractAccountWhitelistEnabled(
smartContractPermissioningConfiguration.setSmartContractAccountAllowlistEnabled(
permissionsAccountsContractEnabled);
smartContractPermissioningConfiguration.setAccountSmartContractAddress(
permissionsAccountsContractAddress);

@ -25,25 +25,25 @@ import javax.annotation.Nonnull;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
public class JsonRPCWhitelistHostsProperty extends AbstractList<String> {
public class JsonRPCAllowlistHostsProperty extends AbstractList<String> {
private final List<String> hostnamesWhitelist = new ArrayList<>();
private final List<String> hostnamesAllowlist = new ArrayList<>();
public JsonRPCWhitelistHostsProperty() {}
public JsonRPCAllowlistHostsProperty() {}
@Override
@Nonnull
public Iterator<String> iterator() {
if (hostnamesWhitelist.size() == 1 && hostnamesWhitelist.get(0).equals("none")) {
if (hostnamesAllowlist.size() == 1 && hostnamesAllowlist.get(0).equals("none")) {
return Collections.emptyIterator();
} else {
return hostnamesWhitelist.iterator();
return hostnamesAllowlist.iterator();
}
}
@Override
public int size() {
return hostnamesWhitelist.size();
return hostnamesAllowlist.size();
}
@Override
@ -53,36 +53,36 @@ public class JsonRPCWhitelistHostsProperty extends AbstractList<String> {
@Override
public String get(final int index) {
return hostnamesWhitelist.get(index);
return hostnamesAllowlist.get(index);
}
@Override
public boolean addAll(final Collection<? extends String> collection) {
final int initialSize = hostnamesWhitelist.size();
final int initialSize = hostnamesAllowlist.size();
for (final String string : collection) {
if (Strings.isNullOrEmpty(string)) {
throw new IllegalArgumentException("Hostname cannot be empty string or null string.");
}
for (final String s : Splitter.onPattern("\\s*,+\\s*").split(string)) {
if ("all".equals(s)) {
hostnamesWhitelist.add("*");
hostnamesAllowlist.add("*");
} else {
hostnamesWhitelist.add(s);
hostnamesAllowlist.add(s);
}
}
}
if (hostnamesWhitelist.contains("none")) {
if (hostnamesWhitelist.size() > 1) {
if (hostnamesAllowlist.contains("none")) {
if (hostnamesAllowlist.size() > 1) {
throw new IllegalArgumentException("Value 'none' can't be used with other hostnames");
}
} else if (hostnamesWhitelist.contains("*")) {
if (hostnamesWhitelist.size() > 1) {
} else if (hostnamesAllowlist.contains("*")) {
if (hostnamesAllowlist.size() > 1) {
throw new IllegalArgumentException(
"Values '*' or 'all' can't be used with other hostnames");
}
}
return hostnamesWhitelist.size() != initialSize;
return hostnamesAllowlist.size() != initialSize;
}
}

@ -18,7 +18,7 @@ import static org.hyperledger.besu.cli.subcommands.RetestethSubCommand.COMMAND_N
import org.hyperledger.besu.BesuInfo;
import org.hyperledger.besu.cli.DefaultCommandValues;
import org.hyperledger.besu.cli.custom.JsonRPCWhitelistHostsProperty;
import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration;
import org.hyperledger.besu.ethereum.retesteth.RetestethService;
@ -80,12 +80,12 @@ public class RetestethSubCommand implements Runnable {
private final Integer rpcHttpPort = RETESTETH_PORT;
@Option(
names = {"--host-whitelist"},
names = {"--host-allowlist", "--host-whitelist"},
paramLabel = "<hostname>[,<hostname>...]... or * or all",
description =
"Comma separated list of hostnames to whitelist for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
"Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})",
defaultValue = "localhost,127.0.0.1")
private final JsonRPCWhitelistHostsProperty hostsWhitelist = new JsonRPCWhitelistHostsProperty();
private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty();
private InetAddress autoDiscoveredDefaultIP;
@ -119,7 +119,7 @@ public class RetestethSubCommand implements Runnable {
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.setHost(rpcHttpHost);
jsonRpcConfiguration.setPort(rpcHttpPort);
jsonRpcConfiguration.setHostsWhitelist(hostsWhitelist);
jsonRpcConfiguration.setHostsAllowlist(hostsAllowlist);
final RetestethService retestethService =
new RetestethService(BesuInfo.version(), retestethConfiguration, jsonRpcConfiguration);

@ -24,26 +24,26 @@ import java.util.stream.Collectors;
public class PermissioningConfigurationValidator {
public static void areAllNodesAreInWhitelist(
public static void areAllNodesAreInAllowlist(
final Collection<URI> nodeURIs,
final LocalPermissioningConfiguration permissioningConfiguration)
throws Exception {
if (permissioningConfiguration.isNodeWhitelistEnabled() && nodeURIs != null) {
final List<URI> whitelistNodesWithoutQueryParam =
permissioningConfiguration.getNodeWhitelist().stream()
if (permissioningConfiguration.isNodeAllowlistEnabled() && nodeURIs != null) {
final List<URI> allowlistNodesWithoutQueryParam =
permissioningConfiguration.getNodeAllowlist().stream()
.map(PermissioningConfigurationValidator::removeQueryFromURI)
.collect(Collectors.toList());
final List<URI> nodeURIsNotInWhitelist =
final List<URI> nodeURIsNotInAllowlist =
nodeURIs.stream()
.map(PermissioningConfigurationValidator::removeQueryFromURI)
.filter(uri -> !whitelistNodesWithoutQueryParam.contains(uri))
.filter(uri -> !allowlistNodesWithoutQueryParam.contains(uri))
.collect(Collectors.toList());
if (!nodeURIsNotInWhitelist.isEmpty()) {
if (!nodeURIsNotInAllowlist.isEmpty()) {
throw new Exception(
"Specified node(s) not in nodes-whitelist " + enodesAsStrings(nodeURIsNotInWhitelist));
"Specified node(s) not in nodes-whitelist " + enodesAsStrings(nodeURIsNotInAllowlist));
}
}
}
@ -63,10 +63,7 @@ public class PermissioningConfigurationValidator {
}
}
private static Collection<String> enodesAsStrings(final List<URI> bootnodesNotInWhitelist) {
return bootnodesNotInWhitelist
.parallelStream()
.map(URI::toASCIIString)
.collect(Collectors.toList());
private static Collection<String> enodesAsStrings(final List<URI> enodes) {
return enodes.parallelStream().map(URI::toASCIIString).collect(Collectors.toList());
}
}

@ -399,7 +399,7 @@ public final class RunnerTest {
final JsonRpcConfiguration configuration = JsonRpcConfiguration.createDefault();
configuration.setPort(0);
configuration.setEnabled(true);
configuration.setHostsWhitelist(Collections.singletonList("*"));
configuration.setHostsAllowlist(Collections.singletonList("*"));
return configuration;
}
@ -414,7 +414,7 @@ public final class RunnerTest {
final WebSocketConfiguration configuration = WebSocketConfiguration.createDefault();
configuration.setPort(0);
configuration.setEnabled(true);
configuration.setHostsWhitelist(Collections.singletonList("*"));
configuration.setHostsAllowlist(Collections.singletonList("*"));
return configuration;
}

@ -408,7 +408,7 @@ public class BesuCommandTest extends CommandTestAbstract {
new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString(smartContractAddress));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
verify(mockRunnerBuilder)
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
@ -483,7 +483,7 @@ public class BesuCommandTest extends CommandTestAbstract {
new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setAccountSmartContractAddress(
Address.fromHexString(smartContractAddress));
smartContractPermissioningConfiguration.setSmartContractAccountWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractAccountAllowlistEnabled(true);
verify(mockRunnerBuilder)
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
@ -493,7 +493,7 @@ public class BesuCommandTest extends CommandTestAbstract {
final SmartContractPermissioningConfiguration effectiveSmartContractConfig =
permissioningConfiguration.getSmartContractConfig().get();
assertThat(effectiveSmartContractConfig.isSmartContractAccountWhitelistEnabled()).isTrue();
assertThat(effectiveSmartContractConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
assertThat(effectiveSmartContractConfig.getAccountSmartContractAddress())
.isEqualTo(Address.fromHexString(smartContractAddress));
@ -588,7 +588,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void nodePermissioningTomlPathMustUseOption() throws IOException {
final List<URI> whitelistedNodes =
final List<URI> allowlistedNodes =
Lists.newArrayList(
URI.create(
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567"),
@ -598,18 +598,18 @@ public class BesuCommandTest extends CommandTestAbstract {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_TOML);
final Path permToml = createTempFile("toml", Resources.toByteArray(configFile));
final String whitelistedNodesString =
whitelistedNodes.stream().map(Object::toString).collect(Collectors.joining(","));
final String allowlistedNodesString =
allowlistedNodes.stream().map(Object::toString).collect(Collectors.joining(","));
parseCommand(
"--permissions-nodes-config-file-enabled",
"--permissions-nodes-config-file",
permToml.toString(),
"--bootnodes",
whitelistedNodesString);
allowlistedNodesString);
final LocalPermissioningConfiguration localPermissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
localPermissioningConfiguration.setNodePermissioningConfigFilePath(permToml.toString());
localPermissioningConfiguration.setNodeWhitelist(whitelistedNodes);
localPermissioningConfiguration.setNodeAllowlist(allowlistedNodes);
verify(mockRunnerBuilder)
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
@ -636,7 +636,7 @@ public class BesuCommandTest extends CommandTestAbstract {
final LocalPermissioningConfiguration localPermissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
localPermissioningConfiguration.setAccountPermissioningConfigFilePath(permToml.toString());
localPermissioningConfiguration.setAccountWhitelist(
localPermissioningConfiguration.setAccountAllowlist(
Collections.singletonList("0x0000000000000000000000000000000000000009"));
verify(mockRunnerBuilder)
@ -647,7 +647,7 @@ public class BesuCommandTest extends CommandTestAbstract {
final LocalPermissioningConfiguration effectiveLocalPermissioningConfig =
permissioningConfiguration.getLocalConfig().get();
assertThat(effectiveLocalPermissioningConfig.isAccountWhitelistEnabled()).isTrue();
assertThat(effectiveLocalPermissioningConfig.isAccountAllowlistEnabled()).isTrue();
assertThat(effectiveLocalPermissioningConfig.getAccountPermissioningConfigFilePath())
.isEqualTo(permToml.toString());
@ -1978,9 +1978,9 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(1);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist())
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(1);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("localhost");
assertThat(commandOutput.toString()).isEmpty();
@ -1994,9 +1994,9 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist())
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("*", "localhost");
assertThat(commandOutput.toString()).isEmpty();
@ -2010,9 +2010,9 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist())
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("*", "localhost");
assertThat(commandOutput.toString()).isEmpty();
@ -2026,9 +2026,9 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist())
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2);
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b");
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist())
.doesNotContain("*", "localhost");
assertThat(commandOutput.toString()).isEmpty();
@ -2079,7 +2079,7 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsWhitelist()).isEmpty();
assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
@ -3010,7 +3010,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Rule public TemporaryFolder testFolder = new TemporaryFolder();
@Test
public void errorIsRaisedIfStaticNodesAreNotWhitelisted() throws IOException {
public void errorIsRaisedIfStaticNodesAreNotAllowlisted() throws IOException {
final File staticNodesFile = testFolder.newFile("static-nodes.json");
staticNodesFile.deleteOnExit();
final File permissioningConfig = testFolder.newFile("permissioning");
@ -3024,7 +3024,7 @@ public class BesuCommandTest extends CommandTestAbstract {
.useDefaultPorts()
.build();
final EnodeURL whiteListedNode =
final EnodeURL allowedNode =
EnodeURL.builder()
.nodeId(
"50203c6bfca6874370e71aecc8958529fd723feb05013dc1abca8fc1fff845c5259faba05852e9dfe5ce172a7d6e7c2a3a5eaa8b541c8af15ea5518bbff5f2fa")
@ -3037,7 +3037,7 @@ public class BesuCommandTest extends CommandTestAbstract {
staticNodesFile.toPath(), ("[\"" + staticNodeURI.toString() + "\"]").getBytes(UTF_8));
Files.write(
permissioningConfig.toPath(),
("nodes-whitelist=[\"" + whiteListedNode.toString() + "\"]").getBytes(UTF_8));
("nodes-whitelist=[\"" + allowedNode.toString() + "\"]").getBytes(UTF_8));
parseCommand(
"--data-path=" + testFolder.getRoot().getPath(),

@ -41,7 +41,7 @@ public class LocalPermissioningConfigurationValidatorTest {
static final String PERMISSIONING_CONFIG = "/permissioning_config.toml";
@Test
public void ropstenWithNodesWhitelistOptionWhichDoesIncludeRopstenBootnodesMustNotError()
public void ropstenWithNodesAllowlistOptionWhichDoesIncludeRopstenBootnodesMustNotError()
throws Exception {
EthNetworkConfig ethNetworkConfig = EthNetworkConfig.getNetworkConfig(NetworkName.ROPSTEN);
@ -56,12 +56,12 @@ public class LocalPermissioningConfigurationValidatorTest {
final List<URI> enodeURIs =
ethNetworkConfig.getBootNodes().stream().map(EnodeURL::toURI).collect(Collectors.toList());
PermissioningConfigurationValidator.areAllNodesAreInWhitelist(
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(
enodeURIs, permissioningConfiguration);
}
@Test
public void nodesWhitelistOptionWhichDoesNotIncludeBootnodesMustError() throws Exception {
public void nodesAllowlistOptionWhichDoesNotIncludeBootnodesMustError() throws Exception {
EthNetworkConfig ethNetworkConfig = EthNetworkConfig.getNetworkConfig(NetworkName.ROPSTEN);
@ -79,7 +79,7 @@ public class LocalPermissioningConfigurationValidatorTest {
ethNetworkConfig.getBootNodes().stream()
.map(EnodeURL::toURI)
.collect(Collectors.toList());
PermissioningConfigurationValidator.areAllNodesAreInWhitelist(
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(
enodeURIs, permissioningConfiguration);
fail("expected exception because ropsten bootnodes are not in node-whitelist");
} catch (Exception e) {
@ -94,7 +94,7 @@ public class LocalPermissioningConfigurationValidatorTest {
}
@Test
public void nodeWhitelistCheckShouldIgnoreDiscoveryPortParam() throws Exception {
public void nodeAllowlistCheckShouldIgnoreDiscoveryPortParam() throws Exception {
final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG);
final Path toml = Files.createTempFile("toml", "");
toml.toFile().deleteOnExit();
@ -110,17 +110,17 @@ public class LocalPermissioningConfigurationValidatorTest {
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567?discport=30303");
// In an URI comparison the URLs should not match
boolean isInWhitelist = permissioningConfiguration.getNodeWhitelist().contains(enodeURL);
assertThat(isInWhitelist).isFalse();
boolean isInAllowlist = permissioningConfiguration.getNodeAllowlist().contains(enodeURL);
assertThat(isInAllowlist).isFalse();
// However, for the whitelist validation, we should ignore the discovery port and don't throw an
// However, for the allowlist validation, we should ignore the discovery port and don't throw an
// error
try {
PermissioningConfigurationValidator.areAllNodesAreInWhitelist(
PermissioningConfigurationValidator.areAllNodesAreInAllowlist(
Lists.newArrayList(enodeURL), permissioningConfiguration);
} catch (Exception e) {
fail(
"Exception not expected. Validation of nodes in whitelist should ignore the optional discovery port param.");
"Exception not expected. Validation of nodes in allowlist should ignore the optional discovery port param.");
}
}
}

@ -39,9 +39,9 @@ public class StubValidatorMulticaster implements ValidatorMulticaster {
}
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
public void send(final MessageData message, final Collection<Address> denylist) {
validatorNodes.stream()
.filter(peer -> !blackList.contains(peer.getNodeAddress()))
.filter(peer -> !denylist.contains(peer.getNodeAddress()))
.forEach(peer -> peer.handleReceivedMessage(message));
}
}

@ -52,11 +52,11 @@ public class UniqueMessageMulticaster implements ValidatorMulticaster {
}
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
public void send(final MessageData message, final Collection<Address> denylist) {
if (gossipedMessageTracker.hasSeenMessage(message)) {
return;
}
multicaster.send(message, blackList);
multicaster.send(message, denylist);
gossipedMessageTracker.addSeenMessage(message);
}
}

@ -23,5 +23,5 @@ public interface ValidatorMulticaster {
void send(final MessageData message);
void send(final MessageData message, final Collection<Address> blackList);
void send(final MessageData message, final Collection<Address> denylist);
}

@ -75,10 +75,10 @@ public class ValidatorPeers implements ValidatorMulticaster, PeerConnectionTrack
}
@Override
public void send(final MessageData message, final Collection<Address> blackList) {
public void send(final MessageData message, final Collection<Address> denylist) {
final Collection<Address> includedValidators =
getLatestValidators().stream()
.filter(a -> !blackList.contains(a))
.filter(a -> !denylist.contains(a))
.collect(Collectors.toSet());
sendMessageToSpecificAddresses(includedValidators, message);
}

@ -58,7 +58,7 @@ public class UniqueMessageMulticasterTest {
}
@Test
public void messagesSentWithABlackListAreNotRetransmitted() {
public void messagesSentWithADenylistAreNotRetransmitted() {
when(messageTracker.hasSeenMessage(messageSent)).thenReturn(false);
uniqueMessageMulticaster.send(messageSent, emptyList());
verify(multicaster, times(1)).send(messageSent, emptyList());
@ -71,10 +71,10 @@ public class UniqueMessageMulticasterTest {
}
@Test
public void passedInBlackListIsPassedToUnderlyingValidator() {
final List<Address> blackList =
public void passedInDenylistIsPassedToUnderlyingValidator() {
final List<Address> denylist =
Lists.newArrayList(AddressHelpers.ofValue(0), AddressHelpers.ofValue(1));
uniqueMessageMulticaster.send(messageSent, blackList);
verify(multicaster, times(1)).send(messageSent, blackList);
uniqueMessageMulticaster.send(messageSent, denylist);
verify(multicaster, times(1)).send(messageSent, denylist);
}
}

@ -85,7 +85,7 @@ public class GraphQLConfiguration {
return Collections.unmodifiableCollection(this.hostsWhitelist);
}
public void setHostsWhitelist(final List<String> hostsWhitelist) {
public void setHostsAllowlist(final List<String> hostsWhitelist) {
checkNotNull(hostsWhitelist);
this.hostsWhitelist = hostsWhitelist;
}

@ -103,11 +103,11 @@ public class JsonRpcConfiguration {
rpcApis.add(rpcApi);
}
public Collection<String> getHostsWhitelist() {
public Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist);
}
public void setHostsWhitelist(final List<String> hostsWhitelist) {
public void setHostsAllowlist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist;
}

@ -228,7 +228,7 @@ public class JsonRpcHttpService {
final Router router = Router.router(vertx);
// Verify Host header to avoid rebind attack.
router.route().handler(checkWhitelistHostHeader());
router.route().handler(checkAllowlistHostHeader());
router
.route()
@ -341,11 +341,11 @@ public class JsonRpcHttpService {
return listenFailure;
}
private Handler<RoutingContext> checkWhitelistHostHeader() {
private Handler<RoutingContext> checkAllowlistHostHeader() {
return event -> {
final Optional<String> hostHeader = getAndValidateHostHeader(event);
if (config.getHostsWhitelist().contains("*")
|| (hostHeader.isPresent() && hostIsInWhitelist(hostHeader.get()))) {
if (config.getHostsAllowlist().contains("*")
|| (hostHeader.isPresent() && hostIsInAllowlist(hostHeader.get()))) {
event.next();
} else {
final HttpServerResponse response = event.response();
@ -376,13 +376,13 @@ public class JsonRpcHttpService {
return Optional.ofNullable(Iterables.get(splitHostHeader, 0));
}
private boolean hostIsInWhitelist(final String hostHeader) {
if (config.getHostsWhitelist().stream()
private boolean hostIsInAllowlist(final String hostHeader) {
if (config.getHostsAllowlist().stream()
.anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
allowlistEntry -> allowlistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true;
} else {
LOG.trace("Host not in whitelist: '{}'", hostHeader);
LOG.trace("Host not in allowlist: '{}'", hostHeader);
return false;
}
}

@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import java.util.List;
import java.util.Optional;
@ -47,7 +47,7 @@ public class PermAddAccountsToWhitelist implements JsonRpcMethod {
final List<String> accountsList = requestContext.getRequiredParameter(0, List.class);
if (whitelistController.isPresent()) {
final WhitelistOperationResult addResult =
final AllowlistOperationResult addResult =
whitelistController.get().addAccounts(accountsList);
switch (addResult) {

@ -22,18 +22,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import java.util.List;
import java.util.Optional;
public class PermRemoveAccountsFromWhitelist implements JsonRpcMethod {
public class PermRemoveAccountsFromAllowlist implements JsonRpcMethod {
private final Optional<AccountLocalConfigPermissioningController> whitelistController;
private final Optional<AccountLocalConfigPermissioningController> allowlistController;
public PermRemoveAccountsFromWhitelist(
final Optional<AccountLocalConfigPermissioningController> whitelistController) {
this.whitelistController = whitelistController;
public PermRemoveAccountsFromAllowlist(
final Optional<AccountLocalConfigPermissioningController> allowlistController) {
this.allowlistController = allowlistController;
}
@Override
@ -45,9 +45,9 @@ public class PermRemoveAccountsFromWhitelist implements JsonRpcMethod {
@SuppressWarnings("unchecked")
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final List<String> accountsList = requestContext.getRequiredParameter(0, List.class);
if (whitelistController.isPresent()) {
final WhitelistOperationResult removeResult =
whitelistController.get().removeAccounts(accountsList);
if (allowlistController.isPresent()) {
final AllowlistOperationResult removeResult =
allowlistController.get().removeAccounts(accountsList);
switch (removeResult) {
case ERROR_EMPTY_ENTRY:

@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermGetAccountsWhitelist;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermGetNodesWhitelist;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermReloadPermissionsFromFile;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermRemoveAccountsFromWhitelist;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermRemoveAccountsFromAllowlist;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning.PermRemoveNodesFromWhitelist;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
@ -55,7 +55,7 @@ public class PermJsonRpcMethods extends ApiGroupJsonRpcMethods {
new PermGetNodesWhitelist(nodeWhitelistController),
new PermGetAccountsWhitelist(accountsWhitelistController),
new PermAddAccountsToWhitelist(accountsWhitelistController),
new PermRemoveAccountsFromWhitelist(accountsWhitelistController),
new PermRemoveAccountsFromAllowlist(accountsWhitelistController),
new PermReloadPermissionsFromFile(accountsWhitelistController, nodeWhitelistController));
}
}

@ -100,7 +100,7 @@ public class WebSocketConfiguration {
return authenticationCredentialsFile;
}
public void setHostsWhitelist(final List<String> hostsWhitelist) {
public void setHostsAllowlist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist;
}

@ -118,14 +118,14 @@ public class GraphQLHttpServiceHostWhitelistTest {
@Test
public void requestWithAnyHostnameAndWildcardConfigIsAccepted() throws IOException {
graphQLConfig.setHostsWhitelist(Collections.singletonList("*"));
graphQLConfig.setHostsAllowlist(Collections.singletonList("*"));
Assertions.assertThat(doRequest("ally")).isEqualTo(200);
Assertions.assertThat(doRequest("foe")).isEqualTo(200);
}
@Test
public void requestWithWhitelistedHostIsAccepted() throws IOException {
graphQLConfig.setHostsWhitelist(hostsWhitelist);
graphQLConfig.setHostsAllowlist(hostsWhitelist);
Assertions.assertThat(doRequest("ally")).isEqualTo(200);
Assertions.assertThat(doRequest("ally:12345")).isEqualTo(200);
Assertions.assertThat(doRequest("friend")).isEqualTo(200);
@ -133,7 +133,7 @@ public class GraphQLHttpServiceHostWhitelistTest {
@Test
public void requestWithUnknownHostIsRejected() throws IOException {
graphQLConfig.setHostsWhitelist(hostsWhitelist);
graphQLConfig.setHostsAllowlist(hostsWhitelist);
Assertions.assertThat(doRequest("foe")).isEqualTo(403);
}
@ -151,7 +151,7 @@ public class GraphQLHttpServiceHostWhitelistTest {
@Test
public void requestWithMalformedHostIsRejected() throws IOException {
graphQLConfig.setHostsWhitelist(hostsWhitelist);
graphQLConfig.setHostsAllowlist(hostsWhitelist);
Assertions.assertThat(doRequest("ally:friend")).isEqualTo(403);
Assertions.assertThat(doRequest("ally:123456")).isEqualTo(403);
Assertions.assertThat(doRequest("ally:friend:1234")).isEqualTo(403);

@ -161,14 +161,14 @@ public class JsonRpcHttpServiceHostWhitelistTest {
@Test
public void requestWithAnyHostnameAndWildcardConfigIsAccepted() throws IOException {
jsonRpcConfig.setHostsWhitelist(Collections.singletonList("*"));
jsonRpcConfig.setHostsAllowlist(Collections.singletonList("*"));
assertThat(doRequest("ally")).isEqualTo(200);
assertThat(doRequest("foe")).isEqualTo(200);
}
@Test
public void requestWithWhitelistedHostIsAccepted() throws IOException {
jsonRpcConfig.setHostsWhitelist(hostsWhitelist);
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
assertThat(doRequest("ally")).isEqualTo(200);
assertThat(doRequest("ally:12345")).isEqualTo(200);
assertThat(doRequest("friend")).isEqualTo(200);
@ -176,7 +176,7 @@ public class JsonRpcHttpServiceHostWhitelistTest {
@Test
public void requestWithUnknownHostIsRejected() throws IOException {
jsonRpcConfig.setHostsWhitelist(hostsWhitelist);
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
assertThat(doRequest("foe")).isEqualTo(403);
}
@ -193,7 +193,7 @@ public class JsonRpcHttpServiceHostWhitelistTest {
@Test
public void requestWithMalformedHostIsRejected() throws IOException {
jsonRpcConfig.setHostsWhitelist(hostsWhitelist);
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
assertThat(doRequest("ally:friend")).isEqualTo(403);
assertThat(doRequest("ally:123456")).isEqualTo(403);
assertThat(doRequest("ally:friend:1234")).isEqualTo(403);

@ -178,7 +178,7 @@ public class JsonRpcHttpServiceLoginTest {
private static JsonRpcConfiguration createJsonRpcConfig() {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
return config;
}

@ -183,7 +183,7 @@ public class JsonRpcHttpServiceTest {
private static JsonRpcConfiguration createJsonRpcConfig() {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
return config;
}

@ -164,7 +164,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
final Supplier<Optional<TlsConfiguration>> tlsConfigurationSupplier) {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
config.setTlsConfiguration(tlsConfigurationSupplier.get());
return config;
}

@ -273,7 +273,7 @@ public class JsonRpcHttpServiceTlsMisconfigurationTest {
private JsonRpcConfiguration createJsonRpcConfig(final TlsConfiguration tlsConfiguration) {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
config.setTlsConfiguration(Optional.of(tlsConfiguration));
return config;
}

@ -147,7 +147,7 @@ public class JsonRpcHttpServiceTlsTest {
private JsonRpcConfiguration createJsonRpcConfig() {
final JsonRpcConfiguration config = JsonRpcConfiguration.createDefault();
config.setPort(0);
config.setHostsWhitelist(Collections.singletonList("*"));
config.setHostsAllowlist(Collections.singletonList("*"));
config.setTlsConfiguration(getRpcHttpTlsConfiguration());
return config;
}

@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import java.util.ArrayList;
import java.util.Arrays;
@ -60,7 +60,7 @@ public class PermAddAccountsToWhitelistTest {
public void whenAccountsAreAddedToWhitelistShouldReturnSuccess() {
List<String> accounts = Arrays.asList("0x0", "0x1");
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null);
when(accountWhitelist.addAccounts(eq(accounts))).thenReturn(WhitelistOperationResult.SUCCESS);
when(accountWhitelist.addAccounts(eq(accounts))).thenReturn(AllowlistOperationResult.SUCCESS);
JsonRpcResponse actualResponse = method.response(request(accounts));
@ -72,7 +72,7 @@ public class PermAddAccountsToWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_INVALID_ENTRY);
when(accountWhitelist.addAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_INVALID_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_INVALID_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -84,7 +84,7 @@ public class PermAddAccountsToWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_EXISTING_ENTRY);
when(accountWhitelist.addAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_EXISTING_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_EXISTING_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -96,7 +96,7 @@ public class PermAddAccountsToWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_DUPLICATED_ENTRY);
when(accountWhitelist.addAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -109,7 +109,7 @@ public class PermAddAccountsToWhitelistTest {
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_EMPTY_ENTRY);
when(accountWhitelist.addAccounts(eq(new ArrayList<>())))
.thenReturn(WhitelistOperationResult.ERROR_EMPTY_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));

@ -29,8 +29,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import java.util.ArrayList;
import java.util.List;
@ -110,7 +110,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_EMPTY_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -125,7 +125,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -140,7 +140,7 @@ public class PermAddNodesToWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_EMPTY_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -153,7 +153,7 @@ public class PermAddNodesToWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.SUCCESS));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request);
@ -169,7 +169,7 @@ public class PermAddNodesToWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.addNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.SUCCESS));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request);

@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import java.util.ArrayList;
import java.util.Arrays;
@ -41,14 +41,14 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class PermRemoveAccountsFromWhitelistTest {
public class PermRemoveAccountsFromAllowlistTest {
@Mock private AccountLocalConfigPermissioningController accountWhitelist;
private PermRemoveAccountsFromWhitelist method;
private PermRemoveAccountsFromAllowlist method;
@Before
public void before() {
method = new PermRemoveAccountsFromWhitelist(java.util.Optional.of(accountWhitelist));
method = new PermRemoveAccountsFromAllowlist(java.util.Optional.of(accountWhitelist));
}
@Test
@ -61,7 +61,7 @@ public class PermRemoveAccountsFromWhitelistTest {
List<String> accounts = Arrays.asList("0x0", "0x1");
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null);
when(accountWhitelist.removeAccounts(eq(accounts)))
.thenReturn(WhitelistOperationResult.SUCCESS);
.thenReturn(AllowlistOperationResult.SUCCESS);
JsonRpcResponse actualResponse = method.response(request(accounts));
@ -73,7 +73,7 @@ public class PermRemoveAccountsFromWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_INVALID_ENTRY);
when(accountWhitelist.removeAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_INVALID_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_INVALID_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -85,7 +85,7 @@ public class PermRemoveAccountsFromWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_ABSENT_ENTRY);
when(accountWhitelist.removeAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_ABSENT_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_ABSENT_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -97,7 +97,7 @@ public class PermRemoveAccountsFromWhitelistTest {
JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_DUPLICATED_ENTRY);
when(accountWhitelist.removeAccounts(any()))
.thenReturn(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));
@ -110,7 +110,7 @@ public class PermRemoveAccountsFromWhitelistTest {
new JsonRpcErrorResponse(null, JsonRpcError.ACCOUNT_WHITELIST_EMPTY_ENTRY);
when(accountWhitelist.removeAccounts(eq(new ArrayList<>())))
.thenReturn(WhitelistOperationResult.ERROR_EMPTY_ENTRY);
.thenReturn(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
JsonRpcResponse actualResponse = method.response(request(new ArrayList<>()));

@ -29,8 +29,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.permissioning.AllowlistOperationResult;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.WhitelistOperationResult;
import java.util.ArrayList;
import java.util.List;
@ -93,7 +93,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList())))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_EMPTY_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -106,7 +106,7 @@ public class PermRemoveNodesFromWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.SUCCESS));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request);
@ -122,7 +122,7 @@ public class PermRemoveNodesFromWhitelistTest {
final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId());
when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.SUCCESS));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS));
final JsonRpcResponse actual = method.response(request);
@ -152,7 +152,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_DUPLICATED_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -167,7 +167,7 @@ public class PermRemoveNodesFromWhitelistTest {
request.getRequest().getId(), JsonRpcError.NODE_WHITELIST_EMPTY_ENTRY);
when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>())))
.thenReturn(new NodesWhitelistResult(WhitelistOperationResult.ERROR_EMPTY_ENTRY));
.thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY));
final JsonRpcResponse actual = method.response(request);
@ -183,7 +183,7 @@ public class PermRemoveNodesFromWhitelistTest {
when(nodeLocalConfigPermissioningController.removeNodes(any()))
.thenReturn(
new NodesWhitelistResult(WhitelistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED));
new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED));
final JsonRpcResponse actual = method.response(request);

@ -116,21 +116,21 @@ public class WebSocketHostWhitelistTest {
@Test
public void websocketRequestWithAnyHostnameAndWildcardConfigIsAccepted() {
webSocketConfiguration.setHostsWhitelist(Collections.singletonList("*"));
webSocketConfiguration.setHostsAllowlist(Collections.singletonList("*"));
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally"))).isTrue();
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("foe"))).isTrue();
}
@Test
public void httpRequestWithAnyHostnameAndWildcardConfigIsAccepted(final TestContext context) {
webSocketConfiguration.setHostsWhitelist(Collections.singletonList("*"));
webSocketConfiguration.setHostsAllowlist(Collections.singletonList("*"));
doHttpRequestAndVerify(context, "ally", 400);
doHttpRequestAndVerify(context, "foe", 400);
}
@Test
public void websocketRequestWithWhitelistedHostIsAccepted() {
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally"))).isTrue();
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally:12345"))).isTrue();
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("friend"))).isTrue();
@ -138,7 +138,7 @@ public class WebSocketHostWhitelistTest {
@Test
public void httpRequestWithWhitelistedHostIsAccepted(final TestContext context) {
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
doHttpRequestAndVerify(context, "ally", 400);
doHttpRequestAndVerify(context, "ally:12345", 400);
doHttpRequestAndVerify(context, "friend", 400);
@ -146,20 +146,20 @@ public class WebSocketHostWhitelistTest {
@Test
public void websocketRequestWithUnknownHostIsRejected() {
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("foe"))).isFalse();
}
@Test
public void httpRequestWithUnknownHostIsRejected(final TestContext context) {
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
doHttpRequestAndVerify(context, "foe", 403);
}
@Test
public void websocketRequestWithMalformedHostIsRejected() {
webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally:friend"))).isFalse();
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally:123456"))).isFalse();
assertThat(websocketService.hasWhitelistedHostnameHeader(Optional.of("ally:friend:1234")))
@ -169,7 +169,7 @@ public class WebSocketHostWhitelistTest {
@Test
public void httpRequestWithMalformedHostIsRejected(final TestContext context) {
webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setHostsWhitelist(hostsWhitelist);
webSocketConfiguration.setHostsAllowlist(hostsWhitelist);
doHttpRequestAndVerify(context, "ally:friend", 403);
doHttpRequestAndVerify(context, "ally:123456", 403);
doHttpRequestAndVerify(context, "ally:friend:1234", 403);

@ -81,7 +81,7 @@ public class WebSocketServiceLoginTest {
websocketConfiguration.setPort(0);
websocketConfiguration.setAuthenticationEnabled(true);
websocketConfiguration.setAuthenticationCredentialsFile(authTomlPath);
websocketConfiguration.setHostsWhitelist(Collections.singletonList("*"));
websocketConfiguration.setHostsAllowlist(Collections.singletonList("*"));
final Map<String, JsonRpcMethod> websocketMethods =
new WebSocketMethodsFactory(

@ -63,7 +63,7 @@ public class WebSocketServiceTest {
websocketConfiguration = WebSocketConfiguration.createDefault();
websocketConfiguration.setPort(0);
websocketConfiguration.setHostsWhitelist(Collections.singletonList("*"));
websocketConfiguration.setHostsAllowlist(Collections.singletonList("*"));
final Map<String, JsonRpcMethod> websocketMethods =
new WebSocketMethodsFactory(

@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.MutableLocalNode;
import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.peers.PeerPrivileges;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.ethereum.p2p.rlpx.ConnectCallback;
import org.hyperledger.besu.ethereum.p2p.rlpx.DisconnectCallback;
import org.hyperledger.besu.ethereum.p2p.rlpx.MessageCallback;
@ -408,7 +408,7 @@ public class DefaultP2PNetwork implements P2PNetwork {
private P2PNetwork doBuild() {
// Set up permissions
// Fold peer reputation into permissions
final PeerPermissionsBlacklist misbehavingPeers = PeerPermissionsBlacklist.create(500);
final PeerPermissionsDenylist misbehavingPeers = PeerPermissionsDenylist.create(500);
final PeerReputationManager reputationManager = new PeerReputationManager(misbehavingPeers);
peerPermissions = PeerPermissions.combine(peerPermissions, misbehavingPeers);

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.p2p.network;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.ethereum.p2p.rlpx.DisconnectCallback;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason;
@ -31,9 +31,9 @@ public class PeerReputationManager implements DisconnectCallback {
private static final Set<DisconnectReason> remotelyTriggeredDisconnectReasons =
ImmutableSet.of(DisconnectReason.INCOMPATIBLE_P2P_PROTOCOL_VERSION);
private final PeerPermissionsBlacklist blacklist;
private final PeerPermissionsDenylist blacklist;
public PeerReputationManager(final PeerPermissionsBlacklist blacklist) {
public PeerReputationManager(final PeerPermissionsDenylist blacklist) {
this.blacklist = blacklist;
}

@ -26,12 +26,12 @@ import java.util.Set;
import io.vertx.core.impl.ConcurrentHashSet;
import org.apache.tuweni.bytes.Bytes;
public class PeerPermissionsBlacklist extends PeerPermissions {
public class PeerPermissionsDenylist extends PeerPermissions {
private static final int DEFAULT_INITIAL_CAPACITY = 20;
private final Set<Bytes> blacklist;
private PeerPermissionsBlacklist(final int initialCapacity, final OptionalInt maxSize) {
private PeerPermissionsDenylist(final int initialCapacity, final OptionalInt maxSize) {
if (maxSize.isPresent()) {
blacklist =
LimitedSet.create(initialCapacity, maxSize.getAsInt(), Mode.DROP_LEAST_RECENTLY_ACCESSED);
@ -40,16 +40,16 @@ public class PeerPermissionsBlacklist extends PeerPermissions {
}
}
private PeerPermissionsBlacklist(final OptionalInt maxSize) {
private PeerPermissionsDenylist(final OptionalInt maxSize) {
this(DEFAULT_INITIAL_CAPACITY, maxSize);
}
public static PeerPermissionsBlacklist create() {
return new PeerPermissionsBlacklist(OptionalInt.empty());
public static PeerPermissionsDenylist create() {
return new PeerPermissionsDenylist(OptionalInt.empty());
}
public static PeerPermissionsBlacklist create(final int maxSize) {
return new PeerPermissionsBlacklist(OptionalInt.of(maxSize));
public static PeerPermissionsDenylist create(final int maxSize) {
return new PeerPermissionsDenylist(OptionalInt.of(maxSize));
}
@Override

@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import java.util.Collections;
import java.util.List;
@ -146,7 +146,7 @@ public class PeerDiscoveryAgentTest {
@Test
public void shouldEvictPeerWhenPermissionsRevoked() {
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final MockPeerDiscoveryAgent peerDiscoveryAgent1 = helper.startDiscoveryAgent();
peerDiscoveryAgent1.start(BROADCAST_TCP_PORT).join();
final DiscoveryPeer peer = peerDiscoveryAgent1.getAdvertisedPeer().get();

@ -40,7 +40,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.util.Subscribers;
@ -653,7 +653,7 @@ public class PeerDiscoveryControllerTest {
final DiscoveryPeer otherPeer = peers.get(1);
final DiscoveryPeer otherPeer2 = peers.get(2);
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final OutboundMessageHandler outboundMessageHandler = mock(OutboundMessageHandler.class);
controller =
getControllerBuilder()
@ -731,7 +731,7 @@ public class PeerDiscoveryControllerTest {
final DiscoveryPeer otherPeer = peers.get(1);
final DiscoveryPeer otherPeer2 = peers.get(2);
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final OutboundMessageHandler outboundMessageHandler = mock(OutboundMessageHandler.class);
controller =
getControllerBuilder()
@ -907,7 +907,7 @@ public class PeerDiscoveryControllerTest {
final DiscoveryPeer discoPeer = peers.get(0);
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final OutboundMessageHandler outboundMessageHandler = mock(OutboundMessageHandler.class);
controller =
getControllerBuilder()

@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.SubProtocol;
@ -201,7 +201,7 @@ public class P2PNetworkTest {
@Test
public void rejectIncomingConnectionFromBlacklistedPeer() throws Exception {
final PeerPermissionsBlacklist localBlacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist localBlacklist = PeerPermissionsDenylist.create();
try (final P2PNetwork localNetwork = builder().peerPermissions(localBlacklist).build();
final P2PNetwork remoteNetwork = builder().build()) {

@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsBlacklist;
import org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.PeerInfo;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason;
@ -33,10 +33,10 @@ import org.junit.Test;
public class PeerReputationManagerTest {
private final Peer localNode = generatePeer();
private final PeerReputationManager peerReputationManager;
private final PeerPermissionsBlacklist blacklist;
private final PeerPermissionsDenylist blacklist;
public PeerReputationManagerTest() {
blacklist = PeerPermissionsBlacklist.create();
blacklist = PeerPermissionsDenylist.create();
peerReputationManager = new PeerReputationManager(blacklist);
}
@ -90,7 +90,7 @@ public class PeerReputationManagerTest {
}
private void checkPermissions(
final PeerPermissionsBlacklist blacklist,
final PeerPermissionsDenylist blacklist,
final Peer remotePeer,
final boolean expectedResult) {
for (PeerPermissions.Action action : PeerPermissions.Action.values()) {

@ -29,13 +29,13 @@ import java.util.stream.Stream;
import org.junit.Test;
public class PeerPermissionsBlacklistTest {
public class PeerPermissionsDenylistTest {
private final Peer localNode = createPeer();
@Test
public void add_peer() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
Peer peer = createPeer();
final AtomicInteger callbackCount = new AtomicInteger(0);
@ -54,7 +54,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void remove_peer() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
Peer peer = createPeer();
blacklist.add(peer);
@ -74,7 +74,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void add_id() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
Peer peer = createPeer();
final AtomicInteger callbackCount = new AtomicInteger(0);
@ -93,7 +93,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void remove_id() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
Peer peer = createPeer();
blacklist.add(peer);
@ -113,7 +113,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void trackedPeerIsNotPermitted() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
Peer peer = createPeer();
checkPermissions(blacklist, peer, true);
@ -127,7 +127,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void subscribeUpdate() {
PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final AtomicInteger callbackCount = new AtomicInteger(0);
final AtomicInteger restrictedCallbackCount = new AtomicInteger(0);
Peer peer = createPeer();
@ -167,7 +167,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void createWithLimitedCapacity() {
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create(2);
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create(2);
Peer peerA = createPeer();
Peer peerB = createPeer();
Peer peerC = createPeer();
@ -198,7 +198,7 @@ public class PeerPermissionsBlacklistTest {
}
private void checkPermissions(
final PeerPermissionsBlacklist blacklist,
final PeerPermissionsDenylist blacklist,
final Peer remotePeer,
final boolean expectedResult) {
for (Action action : Action.values()) {
@ -208,7 +208,7 @@ public class PeerPermissionsBlacklistTest {
@Test
public void createWithUnlimitedCapacity() {
final PeerPermissionsBlacklist blacklist = PeerPermissionsBlacklist.create();
final PeerPermissionsDenylist blacklist = PeerPermissionsDenylist.create();
final int peerCount = 200;
final List<Peer> peers =
Stream.generate(this::createPeer).limit(peerCount).collect(Collectors.toList());

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.permissioning;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.Hash;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.account.TransactionPermissioningProvider;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.services.MetricsSystem;
@ -41,7 +42,7 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
private static final int ACCOUNT_BYTES_SIZE = 20;
private LocalPermissioningConfiguration configuration;
private List<String> accountWhitelist = new ArrayList<>();
private final WhitelistPersistor whitelistPersistor;
private final AllowlistPersistor allowlistPersistor;
private final Counter checkCounter;
private final Counter checkCounterPermitted;
@ -51,16 +52,16 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
final LocalPermissioningConfiguration configuration, final MetricsSystem metricsSystem) {
this(
configuration,
new WhitelistPersistor(configuration.getAccountPermissioningConfigFilePath()),
new AllowlistPersistor(configuration.getAccountPermissioningConfigFilePath()),
metricsSystem);
}
public AccountLocalConfigPermissioningController(
final LocalPermissioningConfiguration configuration,
final WhitelistPersistor whitelistPersistor,
final AllowlistPersistor allowlistPersistor,
final MetricsSystem metricsSystem) {
this.configuration = configuration;
this.whitelistPersistor = whitelistPersistor;
this.allowlistPersistor = allowlistPersistor;
readAccountsFromConfig(configuration);
this.checkCounter =
metricsSystem.createCounter(
@ -80,24 +81,24 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
}
private void readAccountsFromConfig(final LocalPermissioningConfiguration configuration) {
if (configuration != null && configuration.isAccountWhitelistEnabled()) {
if (!configuration.getAccountWhitelist().isEmpty()) {
addAccounts(configuration.getAccountWhitelist());
if (configuration != null && configuration.isAccountAllowlistEnabled()) {
if (!configuration.getAccountAllowlist().isEmpty()) {
addAccounts(configuration.getAccountAllowlist());
}
}
}
public WhitelistOperationResult addAccounts(final List<String> accounts) {
public AllowlistOperationResult addAccounts(final List<String> accounts) {
final List<String> normalizedAccounts = normalizeAccounts(accounts);
final WhitelistOperationResult inputValidationResult = inputValidation(normalizedAccounts);
if (inputValidationResult != WhitelistOperationResult.SUCCESS) {
final AllowlistOperationResult inputValidationResult = inputValidation(normalizedAccounts);
if (inputValidationResult != AllowlistOperationResult.SUCCESS) {
return inputValidationResult;
}
boolean inputHasExistingAccount =
normalizedAccounts.stream().anyMatch(accountWhitelist::contains);
if (inputHasExistingAccount) {
return WhitelistOperationResult.ERROR_EXISTING_ENTRY;
return AllowlistOperationResult.ERROR_EXISTING_ENTRY;
}
final List<String> oldWhitelist = new ArrayList<>(this.accountWhitelist);
@ -108,22 +109,22 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
verifyConfigurationFileState(accountWhitelist);
} catch (IOException e) {
revertState(oldWhitelist);
return WhitelistOperationResult.ERROR_WHITELIST_PERSIST_FAIL;
} catch (WhitelistFileSyncException e) {
return WhitelistOperationResult.ERROR_WHITELIST_FILE_SYNC;
return AllowlistOperationResult.ERROR_WHITELIST_PERSIST_FAIL;
} catch (AllowlistFileSyncException e) {
return AllowlistOperationResult.ERROR_WHITELIST_FILE_SYNC;
}
return WhitelistOperationResult.SUCCESS;
return AllowlistOperationResult.SUCCESS;
}
public WhitelistOperationResult removeAccounts(final List<String> accounts) {
public AllowlistOperationResult removeAccounts(final List<String> accounts) {
final List<String> normalizedAccounts = normalizeAccounts(accounts);
final WhitelistOperationResult inputValidationResult = inputValidation(normalizedAccounts);
if (inputValidationResult != WhitelistOperationResult.SUCCESS) {
final AllowlistOperationResult inputValidationResult = inputValidation(normalizedAccounts);
if (inputValidationResult != AllowlistOperationResult.SUCCESS) {
return inputValidationResult;
}
if (!accountWhitelist.containsAll(normalizedAccounts)) {
return WhitelistOperationResult.ERROR_ABSENT_ENTRY;
return AllowlistOperationResult.ERROR_ABSENT_ENTRY;
}
final List<String> oldWhitelist = new ArrayList<>(this.accountWhitelist);
@ -135,37 +136,36 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
verifyConfigurationFileState(accountWhitelist);
} catch (IOException e) {
revertState(oldWhitelist);
return WhitelistOperationResult.ERROR_WHITELIST_PERSIST_FAIL;
} catch (WhitelistFileSyncException e) {
return WhitelistOperationResult.ERROR_WHITELIST_FILE_SYNC;
return AllowlistOperationResult.ERROR_WHITELIST_PERSIST_FAIL;
} catch (AllowlistFileSyncException e) {
return AllowlistOperationResult.ERROR_WHITELIST_FILE_SYNC;
}
return WhitelistOperationResult.SUCCESS;
return AllowlistOperationResult.SUCCESS;
}
private WhitelistOperationResult inputValidation(final List<String> accounts) {
private AllowlistOperationResult inputValidation(final List<String> accounts) {
if (accounts == null || accounts.isEmpty()) {
return WhitelistOperationResult.ERROR_EMPTY_ENTRY;
return AllowlistOperationResult.ERROR_EMPTY_ENTRY;
}
if (containsInvalidAccount(accounts)) {
return WhitelistOperationResult.ERROR_INVALID_ENTRY;
return AllowlistOperationResult.ERROR_INVALID_ENTRY;
}
if (inputHasDuplicates(accounts)) {
return WhitelistOperationResult.ERROR_DUPLICATED_ENTRY;
return AllowlistOperationResult.ERROR_DUPLICATED_ENTRY;
}
return WhitelistOperationResult.SUCCESS;
return AllowlistOperationResult.SUCCESS;
}
private void verifyConfigurationFileState(final Collection<String> oldAccounts)
throws IOException, WhitelistFileSyncException {
whitelistPersistor.verifyConfigFileMatchesState(
WhitelistPersistor.WHITELIST_TYPE.ACCOUNTS, oldAccounts);
throws IOException, AllowlistFileSyncException {
allowlistPersistor.verifyConfigFileMatchesState(ALLOWLIST_TYPE.ACCOUNTS, oldAccounts);
}
private void updateConfigurationFile(final Collection<String> accounts) throws IOException {
whitelistPersistor.updateConfig(WhitelistPersistor.WHITELIST_TYPE.ACCOUNTS, accounts);
allowlistPersistor.updateConfig(ALLOWLIST_TYPE.ACCOUNTS, accounts);
}
private void revertState(final List<String> accountWhitelist) {
@ -208,9 +208,9 @@ public class AccountLocalConfigPermissioningController implements TransactionPer
try {
final LocalPermissioningConfiguration updatedConfig =
PermissioningConfigurationBuilder.permissioningConfiguration(
configuration.isNodeWhitelistEnabled(),
configuration.isNodeAllowlistEnabled(),
configuration.getNodePermissioningConfigFilePath(),
configuration.isAccountWhitelistEnabled(),
configuration.isAccountAllowlistEnabled(),
configuration.getAccountPermissioningConfigFilePath());
readAccountsFromConfig(updatedConfig);
configuration = updatedConfig;

@ -14,4 +14,4 @@
*/
package org.hyperledger.besu.ethereum.permissioning;
public class WhitelistFileSyncException extends Exception {}
public class AllowlistFileSyncException extends Exception {}

@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.permissioning;
public enum WhitelistOperationResult {
public enum AllowlistOperationResult {
SUCCESS,
ERROR_DUPLICATED_ENTRY,
ERROR_EMPTY_ENTRY,

@ -32,17 +32,17 @@ import com.google.common.base.Charsets;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlParseResult;
public class WhitelistPersistor {
public class AllowlistPersistor {
private final File configurationFile;
public enum WHITELIST_TYPE {
public enum ALLOWLIST_TYPE {
ACCOUNTS("accounts-whitelist"),
NODES("nodes-whitelist");
private final String tomlKey;
WHITELIST_TYPE(final String tomlKey) {
ALLOWLIST_TYPE(final String tomlKey) {
this.tomlKey = tomlKey;
}
@ -51,53 +51,53 @@ public class WhitelistPersistor {
}
}
public WhitelistPersistor(final String configurationFile) {
public AllowlistPersistor(final String configurationFile) {
this.configurationFile = new File(configurationFile);
}
public static boolean verifyConfigFileMatchesState(
final WHITELIST_TYPE whitelistType,
final ALLOWLIST_TYPE allowlistType,
final Collection<String> checkLists,
final Path configurationFilePath)
throws IOException, WhitelistFileSyncException {
throws IOException, AllowlistFileSyncException {
final Map<WHITELIST_TYPE, Collection<String>> configItems =
final Map<ALLOWLIST_TYPE, Collection<String>> configItems =
existingConfigItems(configurationFilePath);
final Collection<String> existingValues =
configItems.get(whitelistType) != null
? configItems.get(whitelistType)
configItems.get(allowlistType) != null
? configItems.get(allowlistType)
: Collections.emptyList();
boolean listsMatch = existingValues.containsAll(checkLists);
if (!listsMatch) {
throw new WhitelistFileSyncException();
throw new AllowlistFileSyncException();
}
return listsMatch;
}
public boolean verifyConfigFileMatchesState(
final WHITELIST_TYPE whitelistType, final Collection<String> checkLists)
throws IOException, WhitelistFileSyncException {
return verifyConfigFileMatchesState(whitelistType, checkLists, configurationFile.toPath());
final ALLOWLIST_TYPE allowlistType, final Collection<String> checkLists)
throws IOException, AllowlistFileSyncException {
return verifyConfigFileMatchesState(allowlistType, checkLists, configurationFile.toPath());
}
public synchronized void updateConfig(
final WHITELIST_TYPE whitelistType, final Collection<String> updatedWhitelistValues)
final ALLOWLIST_TYPE allowlistType, final Collection<String> updatedAllowlistValues)
throws IOException {
removeExistingConfigItem(whitelistType);
addNewConfigItem(whitelistType, updatedWhitelistValues);
removeExistingConfigItem(allowlistType);
addNewConfigItem(allowlistType, updatedAllowlistValues);
}
private static Map<WHITELIST_TYPE, Collection<String>> existingConfigItems(
private static Map<ALLOWLIST_TYPE, Collection<String>> existingConfigItems(
final Path configurationFilePath) throws IOException {
TomlParseResult parsedToml = Toml.parse(configurationFilePath);
return Arrays.stream(WHITELIST_TYPE.values())
return Arrays.stream(ALLOWLIST_TYPE.values())
.filter(k -> parsedToml.contains(k.getTomlKey()))
.map(
whitelist_type ->
allowlist_type ->
new AbstractMap.SimpleImmutableEntry<>(
whitelist_type, parsedToml.getArrayOrEmpty(whitelist_type.getTomlKey())))
allowlist_type, parsedToml.getArrayOrEmpty(allowlist_type.getTomlKey())))
.collect(
Collectors.toMap(
o -> o.getKey(),
@ -110,12 +110,12 @@ public class WhitelistPersistor {
}
@VisibleForTesting
void removeExistingConfigItem(final WHITELIST_TYPE whitelistType) throws IOException {
void removeExistingConfigItem(final ALLOWLIST_TYPE allowlistType) throws IOException {
List<String> otherConfigItems =
existingConfigItems(configurationFile.toPath())
.entrySet()
.parallelStream()
.filter(listType -> !listType.getKey().equals(whitelistType))
.filter(listType -> !listType.getKey().equals(allowlistType))
.map(keyVal -> valueListToTomlArray(keyVal.getKey(), keyVal.getValue()))
.collect(Collectors.toList());
@ -128,11 +128,11 @@ public class WhitelistPersistor {
@VisibleForTesting
public static void addNewConfigItem(
final WHITELIST_TYPE whitelistType,
final Collection<String> whitelistValues,
final ALLOWLIST_TYPE allowlistType,
final Collection<String> allowlistValues,
final Path configFilePath)
throws IOException {
String newConfigItem = valueListToTomlArray(whitelistType, whitelistValues);
String newConfigItem = valueListToTomlArray(allowlistType, allowlistValues);
Files.write(
configFilePath,
@ -143,17 +143,17 @@ public class WhitelistPersistor {
@VisibleForTesting
void addNewConfigItem(
final WHITELIST_TYPE whitelistType, final Collection<String> whitelistValues)
final ALLOWLIST_TYPE allowlistType, final Collection<String> allowlistValues)
throws IOException {
addNewConfigItem(whitelistType, whitelistValues, configurationFile.toPath());
addNewConfigItem(allowlistType, allowlistValues, configurationFile.toPath());
}
private static String valueListToTomlArray(
final WHITELIST_TYPE whitelistType, final Collection<String> whitelistValues) {
final ALLOWLIST_TYPE allowlistType, final Collection<String> allowlistValues) {
return String.format(
"%s=[%s]",
whitelistType.getTomlKey(),
whitelistValues
allowlistType.getTomlKey(),
allowlistValues
.parallelStream()
.map(uri -> String.format("\"%s\"", uri))
.collect(Collectors.joining(",")));

@ -20,48 +20,48 @@ import java.util.Collection;
import java.util.List;
public class LocalPermissioningConfiguration {
private List<URI> nodeWhitelist;
private List<String> accountWhitelist;
private boolean nodeWhitelistEnabled;
private List<URI> nodeAllowlist;
private List<String> accountAllowlist;
private boolean nodeAllowlistEnabled;
private String nodePermissioningConfigFilePath;
private boolean accountWhitelistEnabled;
private boolean accountAllowlistEnabled;
private String accountPermissioningConfigFilePath;
public List<URI> getNodeWhitelist() {
return nodeWhitelist;
public List<URI> getNodeAllowlist() {
return nodeAllowlist;
}
public static LocalPermissioningConfiguration createDefault() {
final LocalPermissioningConfiguration config = new LocalPermissioningConfiguration();
config.nodeWhitelist = new ArrayList<>();
config.accountWhitelist = new ArrayList<>();
config.nodeAllowlist = new ArrayList<>();
config.accountAllowlist = new ArrayList<>();
return config;
}
public void setNodeWhitelist(final Collection<URI> nodeWhitelist) {
if (nodeWhitelist != null) {
this.nodeWhitelist.addAll(nodeWhitelist);
this.nodeWhitelistEnabled = true;
public void setNodeAllowlist(final Collection<URI> nodeAllowlist) {
if (nodeAllowlist != null) {
this.nodeAllowlist.addAll(nodeAllowlist);
this.nodeAllowlistEnabled = true;
}
}
public boolean isNodeWhitelistEnabled() {
return nodeWhitelistEnabled;
public boolean isNodeAllowlistEnabled() {
return nodeAllowlistEnabled;
}
public List<String> getAccountWhitelist() {
return accountWhitelist;
public List<String> getAccountAllowlist() {
return accountAllowlist;
}
public void setAccountWhitelist(final Collection<String> accountWhitelist) {
if (accountWhitelist != null) {
this.accountWhitelist.addAll(accountWhitelist);
this.accountWhitelistEnabled = true;
public void setAccountAllowlist(final Collection<String> accountAllowlist) {
if (accountAllowlist != null) {
this.accountAllowlist.addAll(accountAllowlist);
this.accountAllowlistEnabled = true;
}
}
public boolean isAccountWhitelistEnabled() {
return accountWhitelistEnabled;
public boolean isAccountAllowlistEnabled() {
return accountAllowlistEnabled;
}
public String getNodePermissioningConfigFilePath() {

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.permissioning;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.node.NodePermissioningProvider;
import org.hyperledger.besu.ethereum.permissioning.node.NodeWhitelistUpdatedEvent;
import org.hyperledger.besu.metrics.BesuMetricCategory;
@ -47,7 +48,7 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
private final List<EnodeURL> fixedNodes;
private final Bytes localNodeId;
private final List<EnodeURL> nodesWhitelist = new ArrayList<>();
private final WhitelistPersistor whitelistPersistor;
private final AllowlistPersistor allowlistPersistor;
private final Subscribers<Consumer<NodeWhitelistUpdatedEvent>> nodeWhitelistUpdatedObservers =
Subscribers.create();
@ -64,7 +65,7 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
permissioningConfiguration,
fixedNodes,
localNodeId,
new WhitelistPersistor(permissioningConfiguration.getNodePermissioningConfigFilePath()),
new AllowlistPersistor(permissioningConfiguration.getNodePermissioningConfigFilePath()),
metricsSystem);
}
@ -72,12 +73,12 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
final LocalPermissioningConfiguration configuration,
final List<EnodeURL> fixedNodes,
final Bytes localNodeId,
final WhitelistPersistor whitelistPersistor,
final AllowlistPersistor allowlistPersistor,
final MetricsSystem metricsSystem) {
this.configuration = configuration;
this.fixedNodes = fixedNodes;
this.localNodeId = localNodeId;
this.whitelistPersistor = whitelistPersistor;
this.allowlistPersistor = allowlistPersistor;
readNodesFromConfig(configuration);
this.checkCounter =
@ -98,8 +99,8 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
}
private void readNodesFromConfig(final LocalPermissioningConfiguration configuration) {
if (configuration.isNodeWhitelistEnabled() && configuration.getNodeWhitelist() != null) {
for (URI uri : configuration.getNodeWhitelist()) {
if (configuration.isNodeAllowlistEnabled() && configuration.getNodeAllowlist() != null) {
for (URI uri : configuration.getNodeAllowlist()) {
addNode(EnodeURL.fromString(uri.toString()));
}
}
@ -107,7 +108,7 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
public NodesWhitelistResult addNodes(final List<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs);
if (inputValidationResult.result() != WhitelistOperationResult.SUCCESS) {
if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) {
return inputValidationResult;
}
final List<EnodeURL> peers =
@ -116,7 +117,7 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
for (EnodeURL peer : peers) {
if (nodesWhitelist.contains(peer)) {
return new NodesWhitelistResult(
WhitelistOperationResult.ERROR_EXISTING_ENTRY,
AllowlistOperationResult.ERROR_EXISTING_ENTRY,
String.format("Specified peer: %s already exists in whitelist.", peer.getNodeId()));
}
}
@ -126,11 +127,11 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(peers, Collections.emptyList()));
final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist);
if (updateConfigFileResult.result() != WhitelistOperationResult.SUCCESS) {
if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) {
return updateConfigFileResult;
}
return new NodesWhitelistResult(WhitelistOperationResult.SUCCESS);
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS);
}
public boolean addNode(final EnodeURL enodeURL) {
@ -139,7 +140,7 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
public NodesWhitelistResult removeNodes(final List<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs);
if (inputValidationResult.result() != WhitelistOperationResult.SUCCESS) {
if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) {
return inputValidationResult;
}
final List<EnodeURL> peers =
@ -147,13 +148,13 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
boolean anyBootnode = peers.stream().anyMatch(fixedNodes::contains);
if (anyBootnode) {
return new NodesWhitelistResult(WhitelistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
}
for (EnodeURL peer : peers) {
if (!(nodesWhitelist.contains(peer))) {
return new NodesWhitelistResult(
WhitelistOperationResult.ERROR_ABSENT_ENTRY,
AllowlistOperationResult.ERROR_ABSENT_ENTRY,
String.format("Specified peer: %s does not exist in whitelist.", peer.getNodeId()));
}
}
@ -163,11 +164,11 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(Collections.emptyList(), peers));
final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist);
if (updateConfigFileResult.result() != WhitelistOperationResult.SUCCESS) {
if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) {
return updateConfigFileResult;
}
return new NodesWhitelistResult(WhitelistOperationResult.SUCCESS);
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS);
}
private boolean removeNode(final EnodeURL enodeURL) {
@ -181,27 +182,27 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
verifyConfigurationFileState(peerToEnodeURI(nodesWhitelist));
} catch (IOException e) {
revertState(oldWhitelist);
return new NodesWhitelistResult(WhitelistOperationResult.ERROR_WHITELIST_PERSIST_FAIL);
} catch (WhitelistFileSyncException e) {
return new NodesWhitelistResult(WhitelistOperationResult.ERROR_WHITELIST_FILE_SYNC);
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_WHITELIST_PERSIST_FAIL);
} catch (AllowlistFileSyncException e) {
return new NodesWhitelistResult(AllowlistOperationResult.ERROR_WHITELIST_FILE_SYNC);
}
return new NodesWhitelistResult(WhitelistOperationResult.SUCCESS);
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS);
}
private NodesWhitelistResult validInput(final List<String> peers) {
if (peers == null || peers.isEmpty()) {
return new NodesWhitelistResult(
WhitelistOperationResult.ERROR_EMPTY_ENTRY, String.format("Null/empty peers list"));
AllowlistOperationResult.ERROR_EMPTY_ENTRY, String.format("Null/empty peers list"));
}
if (peerListHasDuplicates(peers)) {
return new NodesWhitelistResult(
WhitelistOperationResult.ERROR_DUPLICATED_ENTRY,
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY,
String.format("Specified peer list contains duplicates"));
}
return new NodesWhitelistResult(WhitelistOperationResult.SUCCESS);
return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS);
}
private boolean peerListHasDuplicates(final List<String> peers) {
@ -209,13 +210,12 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
}
private void verifyConfigurationFileState(final Collection<String> oldNodes)
throws IOException, WhitelistFileSyncException {
whitelistPersistor.verifyConfigFileMatchesState(
WhitelistPersistor.WHITELIST_TYPE.NODES, oldNodes);
throws IOException, AllowlistFileSyncException {
allowlistPersistor.verifyConfigFileMatchesState(ALLOWLIST_TYPE.NODES, oldNodes);
}
private void updateConfigurationFile(final Collection<String> nodes) throws IOException {
whitelistPersistor.updateConfig(WhitelistPersistor.WHITELIST_TYPE.NODES, nodes);
allowlistPersistor.updateConfig(ALLOWLIST_TYPE.NODES, nodes);
}
private void revertState(final List<EnodeURL> nodesWhitelist) {
@ -249,9 +249,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
try {
final LocalPermissioningConfiguration updatedConfig =
PermissioningConfigurationBuilder.permissioningConfiguration(
configuration.isNodeWhitelistEnabled(),
configuration.isNodeAllowlistEnabled(),
configuration.getNodePermissioningConfigFilePath(),
configuration.isAccountWhitelistEnabled(),
configuration.isAccountAllowlistEnabled(),
configuration.getAccountPermissioningConfigFilePath());
readNodesFromConfig(updatedConfig);
@ -300,21 +300,21 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
}
public static class NodesWhitelistResult {
private final WhitelistOperationResult result;
private final AllowlistOperationResult result;
private final Optional<String> message;
NodesWhitelistResult(final WhitelistOperationResult result, final String message) {
NodesWhitelistResult(final AllowlistOperationResult result, final String message) {
this.result = result;
this.message = Optional.of(message);
}
@VisibleForTesting
public NodesWhitelistResult(final WhitelistOperationResult result) {
public NodesWhitelistResult(final AllowlistOperationResult result) {
this.result = result;
this.message = Optional.empty();
}
public WhitelistOperationResult result() {
public AllowlistOperationResult result() {
return result;
}

@ -49,7 +49,7 @@ public class NodePermissioningControllerFactory {
if (permissioningConfiguration.getLocalConfig().isPresent()) {
LocalPermissioningConfiguration localPermissioningConfiguration =
permissioningConfiguration.getLocalConfig().get();
if (localPermissioningConfiguration.isNodeWhitelistEnabled()) {
if (localPermissioningConfiguration.isNodeAllowlistEnabled()) {
NodeLocalConfigPermissioningController localProvider =
new NodeLocalConfigPermissioningController(
localPermissioningConfiguration,
@ -63,7 +63,7 @@ public class NodePermissioningControllerFactory {
if (permissioningConfiguration.getSmartContractConfig().isPresent()) {
SmartContractPermissioningConfiguration smartContractPermissioningConfiguration =
permissioningConfiguration.getSmartContractConfig().get();
if (smartContractPermissioningConfiguration.isSmartContractNodeWhitelistEnabled()) {
if (smartContractPermissioningConfiguration.isSmartContractNodeAllowlistEnabled()) {
NodeSmartContractPermissioningController smartContractProvider =
new NodeSmartContractPermissioningController(
smartContractPermissioningConfiguration.getNodeSmartContractAddress(),

@ -33,7 +33,7 @@ public class PermissioningConfigurationBuilder {
final Address address, final boolean smartContractPermissionedNodeEnabled) {
SmartContractPermissioningConfiguration config = new SmartContractPermissioningConfiguration();
config.setNodeSmartContractAddress(address);
config.setSmartContractNodeWhitelistEnabled(smartContractPermissionedNodeEnabled);
config.setSmartContractNodeAllowlistEnabled(smartContractPermissionedNodeEnabled);
return config;
}
@ -78,7 +78,7 @@ public class PermissioningConfigurationBuilder {
.map(Object::toString)
.map(EnodeURL::asURI)
.collect(Collectors.toList());
permissioningConfiguration.setNodeWhitelist(nodesWhitelistToml);
permissioningConfiguration.setNodeAllowlist(nodesWhitelistToml);
} else {
throw new Exception(
NODES_WHITELIST_KEY
@ -119,7 +119,7 @@ public class PermissioningConfigurationBuilder {
throw new IllegalArgumentException("Invalid account " + s);
});
permissioningConfiguration.setAccountWhitelist(accountsWhitelistToml);
permissioningConfiguration.setAccountAllowlist(accountsWhitelistToml);
} else {
throw new Exception(
ACCOUNTS_WHITELIST_KEY

@ -17,23 +17,23 @@ package org.hyperledger.besu.ethereum.permissioning;
import org.hyperledger.besu.ethereum.core.Address;
public class SmartContractPermissioningConfiguration {
private boolean smartContractNodeWhitelistEnabled;
private boolean smartContractNodeAllowlistEnabled;
private Address nodeSmartContractAddress;
private boolean smartContractAccountWhitelistEnabled;
private boolean smartContractAccountAllowlistEnabled;
private Address accountSmartContractAddress;
public static SmartContractPermissioningConfiguration createDefault() {
return new SmartContractPermissioningConfiguration();
}
public boolean isSmartContractNodeWhitelistEnabled() {
return smartContractNodeWhitelistEnabled;
public boolean isSmartContractNodeAllowlistEnabled() {
return smartContractNodeAllowlistEnabled;
}
public void setSmartContractNodeWhitelistEnabled(
final boolean smartContractNodeWhitelistEnabled) {
this.smartContractNodeWhitelistEnabled = smartContractNodeWhitelistEnabled;
public void setSmartContractNodeAllowlistEnabled(
final boolean smartContractNodeAllowlistEnabled) {
this.smartContractNodeAllowlistEnabled = smartContractNodeAllowlistEnabled;
}
public Address getNodeSmartContractAddress() {
@ -44,13 +44,13 @@ public class SmartContractPermissioningConfiguration {
this.nodeSmartContractAddress = nodeSmartContractAddress;
}
public boolean isSmartContractAccountWhitelistEnabled() {
return smartContractAccountWhitelistEnabled;
public boolean isSmartContractAccountAllowlistEnabled() {
return smartContractAccountAllowlistEnabled;
}
public void setSmartContractAccountWhitelistEnabled(
final boolean smartContractAccountWhitelistEnabled) {
this.smartContractAccountWhitelistEnabled = smartContractAccountWhitelistEnabled;
public void setSmartContractAccountAllowlistEnabled(
final boolean smartContractAccountAllowlistEnabled) {
this.smartContractAccountAllowlistEnabled = smartContractAccountAllowlistEnabled;
}
public Address getAccountSmartContractAddress() {

@ -77,7 +77,7 @@ public class AccountPermissioningControllerFactory {
final SmartContractPermissioningConfiguration smartContractPermissioningConfiguration =
permissioningConfiguration.getSmartContractConfig().get();
if (smartContractPermissioningConfiguration.isSmartContractAccountWhitelistEnabled()) {
if (smartContractPermissioningConfiguration.isSmartContractAccountAllowlistEnabled()) {
final Address accountSmartContractAddress =
smartContractPermissioningConfiguration.getAccountSmartContractAddress();
@ -104,7 +104,7 @@ public class AccountPermissioningControllerFactory {
final LocalPermissioningConfiguration localPermissioningConfiguration =
permissioningConfiguration.getLocalConfig().get();
if (localPermissioningConfiguration.isAccountWhitelistEnabled()) {
if (localPermissioningConfiguration.isAccountAllowlistEnabled()) {
return Optional.of(
new AccountLocalConfigPermissioningController(
localPermissioningConfiguration, metricsSystem));

@ -50,7 +50,7 @@ public class AccountLocalConfigPermissioningControllerTest {
private AccountLocalConfigPermissioningController controller;
@Mock private LocalPermissioningConfiguration permissioningConfig;
@Mock private WhitelistPersistor whitelistPersistor;
@Mock private AllowlistPersistor allowlistPersistor;
@Mock private MetricsSystem metricsSystem;
@Mock private Counter checkCounter;
@Mock private Counter checkPermittedCounter;
@ -79,17 +79,17 @@ public class AccountLocalConfigPermissioningControllerTest {
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
}
@Test
public void whenPermConfigHasAccountsShouldAddAllAccountsToWhitelist() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
assertThat(controller.getAccountWhitelist())
.contains("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
@ -97,12 +97,12 @@ public class AccountLocalConfigPermissioningControllerTest {
@Test
public void whenLoadingAccountsFromConfigShouldNormalizeAccountsToLowerCase() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(singletonList("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
assertThat(controller.getAccountWhitelist())
.containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
@ -110,30 +110,30 @@ public class AccountLocalConfigPermissioningControllerTest {
@Test
public void whenPermConfigContainsEmptyListOfAccountsContainsShouldReturnFalse() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist()).thenReturn(new ArrayList<>());
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist()).thenReturn(new ArrayList<>());
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
assertThat(controller.contains("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73")).isFalse();
}
@Test
public void addAccountsWithInvalidAccountShouldReturnInvalidEntryResult() {
WhitelistOperationResult addResult = controller.addAccounts(Arrays.asList("0x0"));
AllowlistOperationResult addResult = controller.addAccounts(Arrays.asList("0x0"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.ERROR_INVALID_ENTRY);
assertThat(addResult).isEqualTo(AllowlistOperationResult.ERROR_INVALID_ENTRY);
assertThat(controller.getAccountWhitelist()).isEmpty();
}
@Test
public void addExistingAccountShouldReturnExistingEntryResult() {
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
WhitelistOperationResult addResult =
AllowlistOperationResult addResult =
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.ERROR_EXISTING_ENTRY);
assertThat(addResult).isEqualTo(AllowlistOperationResult.ERROR_EXISTING_ENTRY);
assertThat(controller.getAccountWhitelist())
.containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
}
@ -141,30 +141,30 @@ public class AccountLocalConfigPermissioningControllerTest {
@Test
public void addExistingAccountWithDifferentCasingShouldReturnExistingEntryResult() {
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
WhitelistOperationResult addResult =
AllowlistOperationResult addResult =
controller.addAccounts(Arrays.asList("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.ERROR_EXISTING_ENTRY);
assertThat(addResult).isEqualTo(AllowlistOperationResult.ERROR_EXISTING_ENTRY);
assertThat(controller.getAccountWhitelist())
.containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
}
@Test
public void addValidAccountsShouldReturnSuccessResult() {
WhitelistOperationResult addResult =
AllowlistOperationResult addResult =
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.SUCCESS);
assertThat(addResult).isEqualTo(AllowlistOperationResult.SUCCESS);
assertThat(controller.getAccountWhitelist())
.containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
}
@Test
public void addAccountsShouldAddAccountNormalizedToLowerCase() {
WhitelistOperationResult addResult =
AllowlistOperationResult addResult =
controller.addAccounts(Arrays.asList("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.SUCCESS);
assertThat(addResult).isEqualTo(AllowlistOperationResult.SUCCESS);
assertThat(controller.getAccountWhitelist())
.containsExactly("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
}
@ -173,10 +173,10 @@ public class AccountLocalConfigPermissioningControllerTest {
public void removeExistingAccountShouldReturnSuccessResult() {
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
WhitelistOperationResult removeResult =
AllowlistOperationResult removeResult =
controller.removeAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(removeResult).isEqualTo(WhitelistOperationResult.SUCCESS);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.SUCCESS);
assertThat(controller.getAccountWhitelist()).isEmpty();
}
@ -184,69 +184,69 @@ public class AccountLocalConfigPermissioningControllerTest {
public void removeAccountShouldNormalizeAccountToLowerCAse() {
controller.addAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
WhitelistOperationResult removeResult =
AllowlistOperationResult removeResult =
controller.removeAccounts(Arrays.asList("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"));
assertThat(removeResult).isEqualTo(WhitelistOperationResult.SUCCESS);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.SUCCESS);
assertThat(controller.getAccountWhitelist()).isEmpty();
}
@Test
public void removeAbsentAccountShouldReturnAbsentEntryResult() {
WhitelistOperationResult removeResult =
AllowlistOperationResult removeResult =
controller.removeAccounts(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(removeResult).isEqualTo(WhitelistOperationResult.ERROR_ABSENT_ENTRY);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.ERROR_ABSENT_ENTRY);
assertThat(controller.getAccountWhitelist()).isEmpty();
}
@Test
public void removeInvalidAccountShouldReturnInvalidEntryResult() {
WhitelistOperationResult removeResult = controller.removeAccounts(Arrays.asList("0x0"));
AllowlistOperationResult removeResult = controller.removeAccounts(Arrays.asList("0x0"));
assertThat(removeResult).isEqualTo(WhitelistOperationResult.ERROR_INVALID_ENTRY);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.ERROR_INVALID_ENTRY);
assertThat(controller.getAccountWhitelist()).isEmpty();
}
@Test
public void addDuplicatedAccountShouldReturnDuplicatedEntryResult() {
WhitelistOperationResult addResult =
AllowlistOperationResult addResult =
controller.addAccounts(
Arrays.asList(
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(addResult).isEqualTo(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
assertThat(addResult).isEqualTo(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
}
@Test
public void removeDuplicatedAccountShouldReturnDuplicatedEntryResult() {
WhitelistOperationResult removeResult =
AllowlistOperationResult removeResult =
controller.removeAccounts(
Arrays.asList(
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
assertThat(removeResult).isEqualTo(WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
}
@Test
public void removeNullListShouldReturnEmptyEntryResult() {
WhitelistOperationResult removeResult = controller.removeAccounts(null);
AllowlistOperationResult removeResult = controller.removeAccounts(null);
assertThat(removeResult).isEqualTo(WhitelistOperationResult.ERROR_EMPTY_ENTRY);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
}
@Test
public void removeEmptyListShouldReturnEmptyEntryResult() {
WhitelistOperationResult removeResult = controller.removeAccounts(new ArrayList<>());
AllowlistOperationResult removeResult = controller.removeAccounts(new ArrayList<>());
assertThat(removeResult).isEqualTo(WhitelistOperationResult.ERROR_EMPTY_ENTRY);
assertThat(removeResult).isEqualTo(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
}
@Test
public void stateShouldRevertIfWhitelistPersistFails()
throws IOException, WhitelistFileSyncException {
throws IOException, AllowlistFileSyncException {
List<String> newAccount = singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73");
List<String> newAccount2 = singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd72");
@ -255,15 +255,15 @@ public class AccountLocalConfigPermissioningControllerTest {
controller.addAccounts(newAccount);
assertThat(controller.getAccountWhitelist().size()).isEqualTo(1);
doThrow(new IOException()).when(whitelistPersistor).updateConfig(any(), any());
doThrow(new IOException()).when(allowlistPersistor).updateConfig(any(), any());
controller.addAccounts(newAccount2);
assertThat(controller.getAccountWhitelist().size()).isEqualTo(1);
assertThat(controller.getAccountWhitelist()).isEqualTo(newAccount);
verify(whitelistPersistor, times(3)).verifyConfigFileMatchesState(any(), any());
verify(whitelistPersistor, times(2)).updateConfig(any(), any());
verifyNoMoreInteractions(whitelistPersistor);
verify(allowlistPersistor, times(3)).verifyConfigFileMatchesState(any(), any());
verify(allowlistPersistor, times(2)).updateConfig(any(), any());
verifyNoMoreInteractions(allowlistPersistor);
}
@Test
@ -273,12 +273,12 @@ public class AccountLocalConfigPermissioningControllerTest {
when(permissioningConfig.getAccountPermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString());
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
controller.reload();
@ -288,12 +288,12 @@ public class AccountLocalConfigPermissioningControllerTest {
@Test
public void reloadAccountWhitelistWithErrorReadingConfigFileShouldKeepOldWhitelist() {
when(permissioningConfig.getAccountPermissioningConfigFilePath()).thenReturn("foo");
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(Arrays.asList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
final Throwable thrown = catchThrowable(() -> controller.reload());
@ -320,24 +320,24 @@ public class AccountLocalConfigPermissioningControllerTest {
@Test
public void shouldMatchAccountsWithInconsistentCasing() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
assertThat(controller.contains("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73")).isTrue();
}
@Test
public void isPermittedShouldCheckIfAccountExistInTheWhitelist() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
when(permissioningConfig.isAccountAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountAllowlist())
.thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller =
new AccountLocalConfigPermissioningController(
permissioningConfig, whitelistPersistor, metricsSystem);
permissioningConfig, allowlistPersistor, metricsSystem);
final Transaction transaction = mock(Transaction.class);
when(transaction.getSender())

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.permissioning;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.permissioning.WhitelistPersistor.WHITELIST_TYPE;
import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE;
import java.io.File;
import java.io.IOException;
@ -32,14 +32,14 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class WhitelistPersistorTest {
public class AllowlistPersistorTest {
private WhitelistPersistor whitelistPersistor;
private AllowlistPersistor allowlistPersistor;
private File tempFile;
private final String accountsWhitelist =
String.format("%s=[%s]", WHITELIST_TYPE.ACCOUNTS.getTomlKey(), "\"account1\",\"account2\"");
String.format("%s=[%s]", ALLOWLIST_TYPE.ACCOUNTS.getTomlKey(), "\"account1\",\"account2\"");
private final String nodesWhitelist =
String.format("%s=[%s]", WHITELIST_TYPE.NODES.getTomlKey(), "\"node1\",\"node2\"");
String.format("%s=[%s]", ALLOWLIST_TYPE.NODES.getTomlKey(), "\"node1\",\"node2\"");
@Before
public void setUp() throws IOException {
@ -47,17 +47,17 @@ public class WhitelistPersistorTest {
tempFile = File.createTempFile("test", "test");
tempFile.deleteOnExit();
Files.write(tempFile.toPath(), lines, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
whitelistPersistor = new WhitelistPersistor(tempFile.getAbsolutePath());
allowlistPersistor = new AllowlistPersistor(tempFile.getAbsolutePath());
}
@Test
public void lineShouldBeRemoved() throws IOException {
WHITELIST_TYPE keyForRemoval = WHITELIST_TYPE.ACCOUNTS;
ALLOWLIST_TYPE keyForRemoval = ALLOWLIST_TYPE.ACCOUNTS;
assertThat(countLines()).isEqualTo(2);
assertThat(hasKey(keyForRemoval)).isTrue();
whitelistPersistor.removeExistingConfigItem(keyForRemoval);
allowlistPersistor.removeExistingConfigItem(keyForRemoval);
assertThat(countLines()).isEqualTo(1);
assertThat(hasKey(keyForRemoval)).isFalse();
@ -65,18 +65,18 @@ public class WhitelistPersistorTest {
@Test
public void lineShouldBeAdded() throws IOException {
final WHITELIST_TYPE key = WHITELIST_TYPE.NODES;
final ALLOWLIST_TYPE key = ALLOWLIST_TYPE.NODES;
final Set<String> updatedWhitelist = Collections.singleton("node5");
assertThat(countLines()).isEqualTo(2);
assertThat(hasKey(key)).isTrue();
whitelistPersistor.removeExistingConfigItem(WHITELIST_TYPE.NODES);
allowlistPersistor.removeExistingConfigItem(ALLOWLIST_TYPE.NODES);
assertThat(countLines()).isEqualTo(1);
assertThat(hasKey(key)).isFalse();
whitelistPersistor.addNewConfigItem(key, updatedWhitelist);
allowlistPersistor.addNewConfigItem(key, updatedWhitelist);
assertThat(countLines()).isEqualTo(2);
assertThat(hasKey(key)).isTrue();
@ -84,13 +84,13 @@ public class WhitelistPersistorTest {
@Test
public void lineShouldBeReplaced() throws IOException {
WHITELIST_TYPE key = WHITELIST_TYPE.NODES;
ALLOWLIST_TYPE key = ALLOWLIST_TYPE.NODES;
String newValue = "node5";
assertThat(countLines()).isEqualTo(2);
assertThat(hasKeyAndExactLineContent(key, nodesWhitelist)).isTrue();
whitelistPersistor.updateConfig(key, Collections.singleton(newValue));
allowlistPersistor.updateConfig(key, Collections.singleton(newValue));
assertThat(countLines()).isEqualTo(2);
assertThat(hasKeyAndContainsValue(key, newValue)).isTrue();
@ -99,12 +99,12 @@ public class WhitelistPersistorTest {
@Test
public void outputIsValidTOML() throws IOException {
WHITELIST_TYPE key = WHITELIST_TYPE.ACCOUNTS;
ALLOWLIST_TYPE key = ALLOWLIST_TYPE.ACCOUNTS;
List<String> newValue = Lists.newArrayList("account5", "account6", "account4");
String expectedValue =
String.format("%s=[%s]", "accounts-whitelist", "\"account5\",\"account6\",\"account4\"");
whitelistPersistor.updateConfig(key, newValue);
allowlistPersistor.updateConfig(key, newValue);
assertThat(hasKey(key)).isTrue();
assertThat(hasKeyAndExactLineContent(key, expectedValue)).isTrue();
@ -121,20 +121,20 @@ public class WhitelistPersistorTest {
}
}
private boolean hasKey(final WHITELIST_TYPE key) throws IOException {
private boolean hasKey(final ALLOWLIST_TYPE key) throws IOException {
try (Stream<String> lines = Files.lines(tempFile.toPath())) {
return lines.anyMatch(s -> s.startsWith(key.getTomlKey()));
}
}
private boolean hasKeyAndContainsValue(final WHITELIST_TYPE key, final String value)
private boolean hasKeyAndContainsValue(final ALLOWLIST_TYPE key, final String value)
throws IOException {
try (Stream<String> lines = Files.lines(tempFile.toPath())) {
return lines.anyMatch(s -> s.startsWith(key.getTomlKey()) && s.contains(value));
}
}
private boolean hasKeyAndExactLineContent(final WHITELIST_TYPE key, final String exactKeyValue)
private boolean hasKeyAndExactLineContent(final ALLOWLIST_TYPE key, final String exactKeyValue)
throws IOException {
try (Stream<String> lines = Files.lines(tempFile.toPath())) {
return lines.anyMatch(s -> s.startsWith(key.getTomlKey()) && s.equals(exactKeyValue));

@ -61,11 +61,11 @@ public class LocalPermissioningConfigurationBuilderTest {
LocalPermissioningConfiguration permissioningConfiguration = permissioningConfig(toml);
assertThat(permissioningConfiguration.isAccountWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountWhitelist())
assertThat(permissioningConfiguration.isAccountAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountAllowlist())
.containsExactly("0x0000000000000000000000000000000000000009");
assertThat(permissioningConfiguration.isNodeWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeWhitelist())
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeAllowlist())
.containsExactly(URI.create(uri), URI.create(uri2));
}
@ -80,9 +80,9 @@ public class LocalPermissioningConfigurationBuilderTest {
PermissioningConfigurationBuilder.permissioningConfiguration(
true, toml.toAbsolutePath().toString(), false, toml.toAbsolutePath().toString());
assertThat(permissioningConfiguration.isAccountWhitelistEnabled()).isFalse();
assertThat(permissioningConfiguration.isNodeWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeWhitelist()).containsExactly(URI.create(uri));
assertThat(permissioningConfiguration.isAccountAllowlistEnabled()).isFalse();
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeAllowlist()).containsExactly(URI.create(uri));
}
@Test
@ -94,9 +94,9 @@ public class LocalPermissioningConfigurationBuilderTest {
PermissioningConfigurationBuilder.permissioningConfiguration(
false, toml.toAbsolutePath().toString(), true, toml.toAbsolutePath().toString());
assertThat(permissioningConfiguration.isNodeWhitelistEnabled()).isFalse();
assertThat(permissioningConfiguration.isAccountWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountWhitelist())
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isFalse();
assertThat(permissioningConfiguration.isAccountAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountAllowlist())
.containsExactly("0x0000000000000000000000000000000000000009");
}
@ -131,10 +131,10 @@ public class LocalPermissioningConfigurationBuilderTest {
LocalPermissioningConfiguration permissioningConfiguration = permissioningConfig(toml);
assertThat(permissioningConfiguration.isNodeWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeWhitelist()).isEmpty();
assertThat(permissioningConfiguration.isAccountWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountWhitelist()).isEmpty();
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeAllowlist()).isEmpty();
assertThat(permissioningConfiguration.isAccountAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getAccountAllowlist()).isEmpty();
}
@Test
@ -203,8 +203,8 @@ public class LocalPermissioningConfigurationBuilderTest {
PermissioningConfigurationBuilder.permissioningConfiguration(
true, configFile.getPath(), false, configFile.getPath());
assertThat(permissioningConfiguration.isNodeWhitelistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeWhitelist().size()).isEqualTo(5);
assertThat(permissioningConfiguration.isNodeAllowlistEnabled()).isTrue();
assertThat(permissioningConfiguration.getNodeAllowlist().size()).isEqualTo(5);
}
private LocalPermissioningConfiguration accountOnlyPermissioningConfig(final Path toml)

@ -33,28 +33,28 @@ public class LocalPermissioningConfigurationTest {
public void defaultConfiguration() {
final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault();
assertThat(configuration.getNodeWhitelist()).isEmpty();
assertThat(configuration.isNodeWhitelistEnabled()).isFalse();
assertThat(configuration.getAccountWhitelist()).isEmpty();
assertThat(configuration.isAccountWhitelistEnabled()).isFalse();
assertThat(configuration.getNodeAllowlist()).isEmpty();
assertThat(configuration.isNodeAllowlistEnabled()).isFalse();
assertThat(configuration.getAccountAllowlist()).isEmpty();
assertThat(configuration.isAccountAllowlistEnabled()).isFalse();
}
@Test
public void setNodeWhitelist() {
final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault();
configuration.setNodeWhitelist(Arrays.asList(nodes));
assertThat(configuration.getNodeWhitelist()).containsExactlyInAnyOrder(nodes);
assertThat(configuration.isNodeWhitelistEnabled()).isTrue();
configuration.setNodeAllowlist(Arrays.asList(nodes));
assertThat(configuration.getNodeAllowlist()).containsExactlyInAnyOrder(nodes);
assertThat(configuration.isNodeAllowlistEnabled()).isTrue();
}
@Test
public void setNodeWhiteListPassingNull() {
final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault();
configuration.setNodeWhitelist(null);
assertThat(configuration.getNodeWhitelist()).isEmpty();
assertThat(configuration.isNodeWhitelistEnabled()).isFalse();
configuration.setNodeAllowlist(null);
assertThat(configuration.getNodeAllowlist()).isEmpty();
assertThat(configuration.isNodeAllowlistEnabled()).isFalse();
}
@Test
@ -62,17 +62,17 @@ public class LocalPermissioningConfigurationTest {
final String[] accounts = {"1111111111111111", "2222222222222222", "ffffffffffffffff"};
final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault();
configuration.setAccountWhitelist(Arrays.asList(accounts));
assertThat(configuration.getAccountWhitelist()).containsExactlyInAnyOrder(accounts);
assertThat(configuration.isAccountWhitelistEnabled()).isTrue();
configuration.setAccountAllowlist(Arrays.asList(accounts));
assertThat(configuration.getAccountAllowlist()).containsExactlyInAnyOrder(accounts);
assertThat(configuration.isAccountAllowlistEnabled()).isTrue();
}
@Test
public void setAccountWhiteListPassingNull() {
final LocalPermissioningConfiguration configuration =
LocalPermissioningConfiguration.createDefault();
configuration.setAccountWhitelist(null);
assertThat(configuration.getAccountWhitelist()).isEmpty();
assertThat(configuration.isAccountWhitelistEnabled()).isFalse();
configuration.setAccountAllowlist(null);
assertThat(configuration.getAccountAllowlist()).isEmpty();
assertThat(configuration.isAccountAllowlistEnabled()).isFalse();
}
}

@ -54,7 +54,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class NodeLocalConfigPermissioningControllerTest {
@Mock private WhitelistPersistor whitelistPersistor;
@Mock private AllowlistPersistor allowlistPersistor;
private final List<EnodeURL> bootnodesList = new ArrayList<>();
private NodeLocalConfigPermissioningController controller;
@ -97,7 +97,7 @@ public class NodeLocalConfigPermissioningControllerTest {
LocalPermissioningConfiguration.createDefault(),
bootnodesList,
selfEnode.getNodeId(),
whitelistPersistor,
allowlistPersistor,
metricsSystem);
}
@ -105,7 +105,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenAddNodesWithValidInputShouldReturnSuccess() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.SUCCESS);
AllowlistOperationResult.SUCCESS);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.addNodes(Lists.newArrayList(enode1));
@ -119,7 +119,7 @@ public class NodeLocalConfigPermissioningControllerTest {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_EXISTING_ENTRY);
AllowlistOperationResult.ERROR_EXISTING_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.addNodes(Lists.newArrayList(enode1, enode2));
@ -130,7 +130,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.addNodes(Arrays.asList(enode1, enode1));
@ -142,7 +142,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenAddNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(new ArrayList<>());
@ -153,7 +153,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenAddNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(null);
@ -164,7 +164,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_ABSENT_ENTRY);
AllowlistOperationResult.ERROR_ABSENT_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(Lists.newArrayList(enode1, enode2));
@ -175,7 +175,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenRemoveNodesInputHasDuplicateNodesShouldReturnErrorDuplicatedEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_DUPLICATED_ENTRY);
AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(Lists.newArrayList(enode1, enode1));
@ -186,7 +186,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(new ArrayList<>());
@ -197,7 +197,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenRemoveNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_EMPTY_ENTRY);
AllowlistOperationResult.ERROR_EMPTY_ENTRY);
NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult =
controller.removeNodes(null);
@ -326,7 +326,7 @@ public class NodeLocalConfigPermissioningControllerTest {
@Test
public void stateShouldRevertIfWhitelistPersistFails()
throws IOException, WhitelistFileSyncException {
throws IOException, AllowlistFileSyncException {
List<String> newNode1 = singletonList(EnodeURL.fromString(enode1).toString());
List<String> newNode2 = singletonList(EnodeURL.fromString(enode2).toString());
@ -335,15 +335,15 @@ public class NodeLocalConfigPermissioningControllerTest {
controller.addNodes(newNode1);
assertThat(controller.getNodesWhitelist().size()).isEqualTo(1);
doThrow(new IOException()).when(whitelistPersistor).updateConfig(any(), any());
doThrow(new IOException()).when(allowlistPersistor).updateConfig(any(), any());
controller.addNodes(newNode2);
assertThat(controller.getNodesWhitelist().size()).isEqualTo(1);
assertThat(controller.getNodesWhitelist()).isEqualTo(newNode1);
verify(whitelistPersistor, times(3)).verifyConfigFileMatchesState(any(), any());
verify(whitelistPersistor, times(2)).updateConfig(any(), any());
verifyNoMoreInteractions(whitelistPersistor);
verify(allowlistPersistor, times(3)).verifyConfigFileMatchesState(any(), any());
verify(allowlistPersistor, times(2)).updateConfig(any(), any());
verifyNoMoreInteractions(allowlistPersistor);
}
@Test
@ -356,8 +356,8 @@ public class NodeLocalConfigPermissioningControllerTest {
when(permissioningConfig.getNodePermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString());
when(permissioningConfig.isNodeWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeWhitelist())
when(permissioningConfig.isNodeAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeAllowlist())
.thenReturn(Arrays.asList(URI.create(expectedEnodeURL)));
controller =
new NodeLocalConfigPermissioningController(
@ -376,8 +376,8 @@ public class NodeLocalConfigPermissioningControllerTest {
mock(LocalPermissioningConfiguration.class);
when(permissioningConfig.getNodePermissioningConfigFilePath()).thenReturn("foo");
when(permissioningConfig.isNodeWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeWhitelist())
when(permissioningConfig.isNodeAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeAllowlist())
.thenReturn(Arrays.asList(URI.create(expectedEnodeURI)));
controller =
new NodeLocalConfigPermissioningController(
@ -453,7 +453,7 @@ public class NodeLocalConfigPermissioningControllerTest {
public void whenRemovingBootnodeShouldReturnRemoveBootnodeError() {
NodeLocalConfigPermissioningController.NodesWhitelistResult expected =
new NodeLocalConfigPermissioningController.NodesWhitelistResult(
WhitelistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
bootnodesList.add(EnodeURL.fromString(enode1));
controller.addNodes(Lists.newArrayList(enode1, enode2));
@ -478,8 +478,8 @@ public class NodeLocalConfigPermissioningControllerTest {
when(permissioningConfig.getNodePermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString());
when(permissioningConfig.isNodeWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeWhitelist()).thenReturn(Arrays.asList(URI.create(enode1)));
when(permissioningConfig.isNodeAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeAllowlist()).thenReturn(Arrays.asList(URI.create(enode1)));
controller =
new NodeLocalConfigPermissioningController(
permissioningConfig, bootnodesList, selfEnode.getNodeId(), metricsSystem);
@ -501,8 +501,8 @@ public class NodeLocalConfigPermissioningControllerTest {
when(permissioningConfig.getNodePermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString());
when(permissioningConfig.isNodeWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeWhitelist()).thenReturn(Arrays.asList(URI.create(enode1)));
when(permissioningConfig.isNodeAllowlistEnabled()).thenReturn(true);
when(permissioningConfig.getNodeAllowlist()).thenReturn(Arrays.asList(URI.create(enode1)));
controller =
new NodeLocalConfigPermissioningController(
permissioningConfig, bootnodesList, selfEnode.getNodeId(), metricsSystem);

@ -57,7 +57,7 @@ public class AccountPermissioningControllerFactoryTest {
@Test
public void createLocalConfigWithAccountPermissioningDisabledShouldReturnEmpty() {
LocalPermissioningConfiguration localConfig = LocalPermissioningConfiguration.createDefault();
assertThat(localConfig.isAccountWhitelistEnabled()).isFalse();
assertThat(localConfig.isAccountAllowlistEnabled()).isFalse();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.of(localConfig), Optional.empty());
@ -72,7 +72,7 @@ public class AccountPermissioningControllerFactoryTest {
@Test
public void createLocalConfigOnlyControllerShouldReturnExpectedController() {
LocalPermissioningConfiguration localConfig = localConfig();
assertThat(localConfig.isAccountWhitelistEnabled()).isTrue();
assertThat(localConfig.isAccountAllowlistEnabled()).isTrue();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.of(localConfig), Optional.empty());
@ -90,7 +90,7 @@ public class AccountPermissioningControllerFactoryTest {
public void createOnchainConfigWithAccountPermissioningDisabledShouldReturnEmpty() {
SmartContractPermissioningConfiguration onchainConfig =
SmartContractPermissioningConfiguration.createDefault();
assertThat(onchainConfig.isSmartContractAccountWhitelistEnabled()).isFalse();
assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isFalse();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig));
@ -105,7 +105,7 @@ public class AccountPermissioningControllerFactoryTest {
@Test
public void createOnchainConfigOnlyControllerShouldReturnExpectedController() {
SmartContractPermissioningConfiguration onchainConfig = onchainConfig();
assertThat(onchainConfig.isSmartContractAccountWhitelistEnabled()).isTrue();
assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig));
@ -122,7 +122,7 @@ public class AccountPermissioningControllerFactoryTest {
@Test
public void createOnchainShouldFailIfValidationFails() {
SmartContractPermissioningConfiguration onchainConfig = onchainConfig();
assertThat(onchainConfig.isSmartContractAccountWhitelistEnabled()).isTrue();
assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.empty(), Optional.of(onchainConfig));
@ -143,10 +143,10 @@ public class AccountPermissioningControllerFactoryTest {
@Test
public void createLocalAndOnchainControllerShouldReturnExpectedControllers() {
LocalPermissioningConfiguration localConfig = localConfig();
assertThat(localConfig.isAccountWhitelistEnabled()).isTrue();
assertThat(localConfig.isAccountAllowlistEnabled()).isTrue();
SmartContractPermissioningConfiguration onchainConfig = onchainConfig();
assertThat(onchainConfig.isSmartContractAccountWhitelistEnabled()).isTrue();
assertThat(onchainConfig.isSmartContractAccountAllowlistEnabled()).isTrue();
PermissioningConfiguration permissioningConfiguration =
new PermissioningConfiguration(Optional.of(localConfig), Optional.of(onchainConfig));
@ -163,7 +163,7 @@ public class AccountPermissioningControllerFactoryTest {
private LocalPermissioningConfiguration localConfig() {
LocalPermissioningConfiguration localPermissioningConfiguration =
LocalPermissioningConfiguration.createDefault();
localPermissioningConfiguration.setAccountWhitelist(
localPermissioningConfiguration.setAccountAllowlist(
Arrays.asList(Address.fromHexString("0x00").toString()));
localPermissioningConfiguration.setAccountPermissioningConfigFilePath(
createTempFile().getPath());
@ -175,7 +175,7 @@ public class AccountPermissioningControllerFactoryTest {
SmartContractPermissioningConfiguration.createDefault();
onchainPermissioningConfiguration.setAccountSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000008888"));
onchainPermissioningConfiguration.setSmartContractAccountWhitelistEnabled(true);
onchainPermissioningConfiguration.setSmartContractAccountAllowlistEnabled(true);
return onchainPermissioningConfiguration;
}

@ -78,7 +78,7 @@ public class NodePermissioningControllerFactoryTest {
smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000001234"));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
config =
new PermissioningConfiguration(
Optional.empty(), Optional.of(smartContractPermissioningConfiguration));
@ -104,7 +104,7 @@ public class NodePermissioningControllerFactoryTest {
@Test
public void testCreateWithLocalNodePermissioningEnabledOnly() {
localPermissioningConfig = LocalPermissioningConfiguration.createDefault();
localPermissioningConfig.setNodeWhitelist(Collections.emptyList());
localPermissioningConfig.setNodeAllowlist(Collections.emptyList());
localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path");
config =
new PermissioningConfiguration(Optional.of(localPermissioningConfig), Optional.empty());
@ -130,13 +130,13 @@ public class NodePermissioningControllerFactoryTest {
@Test
public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() {
localPermissioningConfig = LocalPermissioningConfiguration.createDefault();
localPermissioningConfig.setNodeWhitelist(Collections.emptyList());
localPermissioningConfig.setNodeAllowlist(Collections.emptyList());
localPermissioningConfig.setNodePermissioningConfigFilePath("fake-file-path");
smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000001234"));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
config =
new PermissioningConfiguration(
Optional.of(localPermissioningConfig),
@ -173,7 +173,7 @@ public class NodePermissioningControllerFactoryTest {
smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000001234"));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
config =
new PermissioningConfiguration(
Optional.empty(), Optional.of(smartContractPermissioningConfiguration));
@ -196,7 +196,7 @@ public class NodePermissioningControllerFactoryTest {
smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000001234"));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
smartContractPermissioningConfiguration.setSmartContractNodeAllowlistEnabled(true);
config =
new PermissioningConfiguration(
Optional.empty(), Optional.of(smartContractPermissioningConfiguration));

@ -121,7 +121,7 @@ public class MetricsConfiguration {
return prometheusJob;
}
Collection<String> getHostsWhitelist() {
Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist);
}
@ -241,7 +241,7 @@ public class MetricsConfiguration {
return this;
}
public Builder hostsWhitelist(final List<String> hostsWhitelist) {
public Builder hostsAllowlist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist;
return this;
}

@ -85,7 +85,7 @@ class MetricsHttpService implements MetricsService {
final Router router = Router.router(vertx);
// Verify Host header.
router.route().handler(checkWhitelistHostHeader());
router.route().handler(checkAllowlistHostHeader());
// Endpoint for AWS health check.
router.route("/").method(HttpMethod.GET).handler(this::handleEmptyRequest);
@ -130,11 +130,11 @@ class MetricsHttpService implements MetricsService {
return resultFuture;
}
private Handler<RoutingContext> checkWhitelistHostHeader() {
private Handler<RoutingContext> checkAllowlistHostHeader() {
return event -> {
final Optional<String> hostHeader = getAndValidateHostHeader(event);
if (config.getHostsWhitelist().contains("*")
|| (hostHeader.isPresent() && hostIsInWhitelist(hostHeader.get()))) {
if (config.getHostsAllowlist().contains("*")
|| (hostHeader.isPresent() && hostIsInAllowlist(hostHeader.get()))) {
event.next();
} else {
final HttpServerResponse response = event.response();
@ -164,13 +164,13 @@ class MetricsHttpService implements MetricsService {
return Optional.ofNullable(Iterables.get(splitHostHeader, 0));
}
private boolean hostIsInWhitelist(final String hostHeader) {
if (config.getHostsWhitelist().stream()
private boolean hostIsInAllowlist(final String hostHeader) {
if (config.getHostsAllowlist().stream()
.anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
allowlistEntry -> allowlistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true;
} else {
LOG.trace("Host not in whitelist: '{}'", hostHeader);
LOG.trace("Host not in allowlist: '{}'", hostHeader);
return false;
}
}

@ -66,7 +66,7 @@ public class MetricsHttpServiceTest {
}
private static MetricsConfiguration.Builder createMetricsConfigBuilder() {
return MetricsConfiguration.builder().enabled(true).port(0).hostsWhitelist(singletonList("*"));
return MetricsConfiguration.builder().enabled(true).port(0).hostsAllowlist(singletonList("*"));
}
/** Tears down the HTTP server. */

Loading…
Cancel
Save