sonatype-lift[bot] commented on code in PR #1670: URL: https://github.com/apache/solr/pull/1670#discussion_r1225342278
########## solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java: ########## @@ -54,56 +51,50 @@ public String getName() { public List<Option> getOptions() { return List.of( SolrCLI.OPTION_SOLRURL, - Option.builder(NAME) + Option.builder("c") + .longOpt("name") .argName("NAME") .hasArg() .required(true) .desc("Name of the core to create.") .build(), - Option.builder("confdir") - .argName("CONFIG") + Option.builder("d") + .longOpt("confdir") + .argName("NAME") .hasArg() .required(false) .desc( "Configuration directory to copy when creating the new core; default is " + SolrCLI.DEFAULT_CONFIG_SET + '.') .build(), - Option.builder("configsetsDir") - .argName("DIR") - .hasArg() - .required(true) - .desc("Path to configsets directory on the local system.") - .build(), + // Option.builder("configsetsDir") + // .argName("DIR") + // .hasArg() + // .required(true) + // .desc("Path to configsets directory on the local system.") + // .build(), SolrCLI.OPTION_VERBOSE); } @Override public void runImpl(CommandLine cli) throws Exception { + String coreName = cli.getOptionValue("name"); String solrUrl = cli.getOptionValue("solrUrl", SolrCLI.DEFAULT_SOLR_URL); - if (!solrUrl.endsWith("/")) solrUrl += "/"; - - File configsetsDir = new File(cli.getOptionValue("configsetsDir")); - if (!configsetsDir.isDirectory()) - throw new FileNotFoundException(configsetsDir.getAbsolutePath() + " not found!"); - - String configSet = cli.getOptionValue("confdir", SolrCLI.DEFAULT_CONFIG_SET); - File configSetDir = new File(configsetsDir, configSet); - if (!configSetDir.isDirectory()) { - // we allow them to pass a directory instead of a configset name - File possibleConfigDir = new File(configSet); - if (possibleConfigDir.isDirectory()) { - configSetDir = possibleConfigDir; - } else { - throw new FileNotFoundException( - "Specified config directory " - + configSet - + " not found in " - + configsetsDir.getAbsolutePath()); - } + if (!solrUrl.endsWith("/")) { + solrUrl += "/"; } - String coreName = cli.getOptionValue(NAME); + final String solrInstallDir = System.getProperty("solr.install.dir"); + final String confDirName = + cli.getOptionValue("confdir", SolrCLI.DEFAULT_CONFIG_SET); // CREATE_CONFDIR + + // we allow them to pass a directory instead of a configset name + File configsetDir = new File(confDirName); Review Comment: <picture><img alt="9% of developers fix this issue" src="https://lift.sonatype.com/api/commentimage/fixrate/9/display.svg"></picture> <b>*[PATH_TRAVERSAL_IN](https://find-sec-bugs.github.io/bugs.htm#PATH_TRAVERSAL_IN):</b>* This API (java/io/File.<init>(Ljava/lang/String;)V) reads a file whose location might be specified by user input ââ <b>2 similar findings have been found in this PR</b> <details><summary>đ Expand here to view all instances of this finding</summary><br/> <div align=\"center\"> | **File Path** | **Line Number** | | ------------- | ------------- | | solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java | [127](https://github.com/apache/solr/blob/6a915d38e697cefdd5a703c3cf541c11926cc52e/solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java#L127) | | solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java | [166](https://github.com/apache/solr/blob/6a915d38e697cefdd5a703c3cf541c11926cc52e/solr/core/src/java/org/apache/solr/cli/CreateCoreTool.java#L166) | <p><a href="https://lift.sonatype.com/results/github.com/apache/solr/01H2JJVT8RQKMKJRZ9WD6H34SG?t=FindSecBugs|PATH_TRAVERSAL_IN" target="_blank">Visit the Lift Web Console</a> to find more details in your report.</p></div></details> --- <details><summary>âšī¸ Expand to see all <b>@sonatype-lift</b> commands</summary> 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. <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org