SOLR-16711: Extract SolrCLI tool implementations into their own package and classes#1476
SOLR-16711: Extract SolrCLI tool implementations into their own package and classes#1476epugh wants to merge 27 commits intoapache:mainfrom
Conversation
Slim down the overwhelming size of the SolrCLI.java class
janhoy
left a comment
There was a problem hiding this comment.
Wow, this is soo over due :) Looks great!
| } // end HealthcheckTool | ||
|
|
||
| private static final Option[] CREATE_COLLECTION_OPTIONS = | ||
| public static final Option[] CREATE_COLLECTION_OPTIONS = |
There was a problem hiding this comment.
MutablePublicArray: Non-empty arrays are mutable, so this public static final array is not a constant and can be modified by clients of this class. Prefer an ImmutableList, or provide an accessor method that returns a defensive copy.
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| protected boolean isPortAvailable(int port) { | ||
| Socket s = null; | ||
| try { | ||
| s = new Socket("localhost", port); |
There was a problem hiding this comment.
UNENCRYPTED_SOCKET: Unencrypted socket to org.apache.solr.util.cli.RunExampleTool (instead of SSLSocket)
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| if (excMsg != null) { | ||
| CLIO.err("\nERROR: " + excMsg + "\n"); | ||
| if (verbose) { | ||
| exc.printStackTrace(CLIO.getErrStream()); |
There was a problem hiding this comment.
INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE: Possible information exposure through an error message
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| throw new IllegalArgumentException( | ||
| "Value of -serverDir option is invalid! " + zooCfg.getAbsolutePath() + " not found!"); | ||
|
|
||
| File solrHomeDir = new File(exampleParentDir, dirName + "/solr"); |
There was a problem hiding this comment.
PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/io/File;Ljava/lang/String;)V) reads a file whose location might be specified by user input
❗❗ 24 similar findings have been found in this PR
🔎 Expand here to view all instances of this finding
| File Path | Line Number |
|---|---|
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 275 |
| solr/core/src/java/org/apache/solr/util/cli/AuthTool.java | 432 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 201 |
| solr/core/src/java/org/apache/solr/util/cli/CreateCoreTool.java | 71 |
| solr/core/src/java/org/apache/solr/util/cli/AuthTool.java | 440 |
| solr/core/src/java/org/apache/solr/util/cli/ConfigSetDownloadTool.java | 73 |
| solr/core/src/java/org/apache/solr/util/cli/CreateCoreTool.java | 79 |
| solr/core/src/java/org/apache/solr/util/cli/ConfigSetDownloadTool.java | 69 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 481 |
| solr/core/src/java/org/apache/solr/util/cli/AuthTool.java | 235 |
Showing 10 of 24 findings. Visit the Lift Web Console to see all.
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| } | ||
|
|
||
| public static int assertNotRootUser() throws Exception { | ||
| if (currentUser().equals("root")) { |
There was a problem hiding this comment.
NULL_DEREFERENCE: object returned by currentUser() could be null and is dereferenced at line 308.
❗❗ 4 similar findings have been found in this PR
🔎 Expand here to view all instances of this finding
| File Path | Line Number |
|---|---|
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 277 |
| solr/core/src/java/org/apache/solr/util/cli/StatusTool.java | 141 |
| solr/core/src/java/org/apache/solr/util/cli/StatusTool.java | 169 |
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 301 |
Visit the Lift Web Console to find more details in your report.
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| if (excMsg != null) { | ||
| CLIO.err("\nERROR: " + excMsg + "\n"); | ||
| if (verbose) { | ||
| exc.printStackTrace(CLIO.getErrStream()); |
There was a problem hiding this comment.
INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE: Possible information exposure through an error message
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| protected boolean isPortAvailable(int port) { | ||
| Socket s = null; | ||
| try { | ||
| s = new Socket("localhost", port); |
There was a problem hiding this comment.
UNENCRYPTED_SOCKET: Unencrypted socket to org.apache.solr.util.cli.RunExampleTool (instead of SSLSocket)
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| // we try to be nice about having the "conf" in the directory, and we create it if it's not | ||
| // there. | ||
| if (!configSetPath.endsWith("/conf")) { | ||
| configSetPath = Paths.get(configSetPath.toString(), "conf"); |
There was a problem hiding this comment.
PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input
❗❗ 24 similar findings have been found in this PR
🔎 Expand here to view all instances of this finding
| File Path | Line Number |
|---|---|
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 212 |
| solr/core/src/java/org/apache/solr/util/cli/CreateCoreTool.java | 94 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 932 |
| solr/core/src/java/org/apache/solr/util/cli/CreateCoreTool.java | 91 |
| solr/core/src/java/org/apache/solr/util/cli/AuthTool.java | 441 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 628 |
| solr/core/src/java/org/apache/solr/util/cli/ConfigSetDownloadTool.java | 89 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 182 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 890 |
| solr/core/src/java/org/apache/solr/util/cli/RunExampleTool.java | 211 |
Showing 10 of 24 findings. Visit the Lift Web Console to see all.
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
| status.put("solr_home", solrHome != null ? solrHome : "?"); | ||
| status.put("version", SolrCLI.asString("/lucene/solr-impl-version", info)); | ||
| status.put("startTime", SolrCLI.asString("/jvm/jmx/startTime", info)); | ||
| status.put("uptime", SolrCLI.uptime(SolrCLI.asLong("/jvm/jmx/upTimeMS", info))); |
There was a problem hiding this comment.
NULL_DEREFERENCE: object returned by asLong("/jvm/jmx/upTimeMS",info) could be null and is dereferenced at line 154.
❗❗ 4 similar findings have been found in this PR
🔎 Expand here to view all instances of this finding
| File Path | Line Number |
|---|---|
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 318 |
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 294 |
| solr/core/src/java/org/apache/solr/util/cli/AssertTool.java | 325 |
| solr/core/src/java/org/apache/solr/util/cli/StatusTool.java | 182 |
Visit the Lift Web Console to find more details in your report.
ℹ️ Expand to see all @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
| Command | Usage |
|---|---|
@sonatype-lift ignore |
Leave out the above finding from this PR |
@sonatype-lift ignoreall |
Leave out all the existing findings from this PR |
@sonatype-lift exclude <file|issue|path|tool> |
Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file |
Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Help us improve LIFT! (Sonatype LiftBot external survey)
Was this a good recommendation for you? Answering this survey will not impact your Lift settings.
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]
getCommonToolOptions appears to offer a capability that isn't used in the SolrCLI today, so simplify.
|
Getting to done on this... A question, should I move SolrCLI.java into the |
Co-authored-by: sonatype-lift[bot] <37194012+sonatype-lift[bot]@users.noreply.github.com>
@janhoy @risdenk just wanted your opinons on making this change or not, and then I think I'm ready to commit ;-) |
https://issues.apache.org/jira/browse/SOLR-16711
Description
SolrCLI.java is overwhelming to work with.
Solution
Extract tools into their own package.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.