diff --git a/besu/build.gradle b/besu/build.gradle index fa2b0548c5..fb9aeef9e6 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -68,20 +68,21 @@ dependencies { implementation 'com.google.guava:guava' implementation 'com.google.dagger:dagger' implementation 'com.graphql-java:graphql-java' + implementation 'commons-net:commons-net' implementation 'info.picocli:picocli' implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' - implementation 'org.apache.commons:commons-lang3' - implementation 'org.apache.logging.log4j:log4j-core' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-config' implementation 'io.tmio:tuweni-toml' implementation 'io.tmio:tuweni-units' + implementation 'org.apache.commons:commons-lang3' + implementation 'org.apache.logging.log4j:log4j-core' + implementation 'org.hibernate.validator:hibernate-validator' + implementation 'org.rocksdb:rocksdbjni' implementation 'org.springframework.security:spring-security-crypto' implementation 'org.xerial.snappy:snappy-java' implementation 'tech.pegasys:jc-kzg-4844' - implementation 'org.rocksdb:rocksdbjni' - implementation 'commons-net:commons-net' runtimeOnly 'org.apache.logging.log4j:log4j-jul' runtimeOnly 'com.splunk.logging:splunk-library-javalogging' diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index b21305c87a..08f36d7fed 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1421,7 +1421,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } private void validateOptions() { - validateRequiredOptions(); issueOptionWarnings(); validateP2PInterface(p2PDiscoveryOptions.p2pInterface); validateMiningParams(); @@ -1475,19 +1474,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { dataStorageOptions.validate(commandLine); } - private void validateRequiredOptions() { - commandLine - .getCommandSpec() - .options() - .forEach( - option -> { - if (option.required() && option.stringValues().isEmpty()) { - throw new ParameterException( - this.commandLine, "Missing required option: " + option.longestName()); - } - }); - } - private void validateMiningParams() { miningOptions.validate( commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java index b35cc2f5cf..5f5e8c3fca 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java @@ -23,6 +23,7 @@ import org.hyperledger.besu.cli.util.VersionProvider; import java.io.PrintWriter; +import jakarta.validation.constraints.NotEmpty; import org.springframework.security.crypto.bcrypt.BCrypt; import picocli.CommandLine.Command; import picocli.CommandLine.Model.CommandSpec; @@ -75,6 +76,7 @@ public class PasswordSubCommand implements Runnable { static class HashSubCommand implements Runnable { @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. + @NotEmpty @Option( names = "--password", arity = "1..1", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java index 9a0a453768..5bd0aacee2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java @@ -54,6 +54,7 @@ import java.util.function.Function; import java.util.function.Supplier; import io.vertx.core.Vertx; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -335,6 +336,7 @@ public class BlocksSubCommand implements Runnable { arity = "1..1") private final BlockExportFormat format = BlockExportFormat.RLP; + @NotBlank @Option( names = "--to", required = true, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java index 793c817e52..efd924e5e2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java @@ -33,6 +33,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; +import jakarta.validation.constraints.NotBlank; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.ParentCommand; @@ -55,6 +56,7 @@ public class BackupState implements Runnable { arity = "1..1") private final Long block = Long.MAX_VALUE; + @NotBlank @Option( names = "--backup-path", required = true, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java index f53f3a8057..d71cf652a5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java @@ -52,6 +52,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.io.Resources; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,6 +71,7 @@ class GenerateBlockchainConfig implements Runnable { private final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); + @NotBlank @Option( required = true, names = "--config-file", @@ -78,6 +80,7 @@ class GenerateBlockchainConfig implements Runnable { arity = "1..1") private final File configurationFile = null; + @NotBlank @Option( required = true, names = "--to", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java index 52ee255d4f..6480380240 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.slf4j.Logger; @@ -64,6 +65,7 @@ public class RestoreState implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(RestoreState.class); + @NotBlank @Option( names = "--backup-path", required = true, diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 00603bec87..8508edc54e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -113,6 +113,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.json.JsonObject; +import jakarta.validation.constraints.NotEmpty; import org.apache.commons.net.util.SubnetUtils.SubnetInfo; import org.apache.commons.text.StringEscapeUtils; import org.apache.tuweni.bytes.Bytes; @@ -621,6 +622,7 @@ public abstract class CommandTestAbstract { @CommandLine.Command public static class TestBesuCommandWithRequiredOption extends TestBesuCommand { + @NotEmpty @CommandLine.Option( names = {"--accept-terms-and-conditions"}, description = "You must explicitly accept terms and conditions", diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 0c72f91416..d4407855f0 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -123,6 +123,19 @@ + + + + + + + + + + + + + @@ -3008,6 +3021,14 @@ + + + + + + + + @@ -3694,6 +3715,11 @@ + + + + + @@ -3707,6 +3733,11 @@ + + + + + @@ -5015,6 +5046,19 @@ + + + + + + + + + + + + + @@ -5194,6 +5238,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/build.gradle b/platform/build.gradle index 0718d41642..307c54dc1a 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -127,6 +127,8 @@ dependencies { api 'org.fusesource.jansi:jansi:2.4.1' + api 'org.hibernate.validator:hibernate-validator:8.0.1.Final' + api 'org.hyperledger.besu:arithmetic:0.9.7' api 'org.hyperledger.besu:blake2bf:0.9.7' api 'org.hyperledger.besu:bls12-381:0.9.7'