Class CliParser

java.lang.Object
org.owasp.dependencycheck.CliParser

public final class CliParser extends Object
A utility to parse command line arguments for the DependencyCheck.
Author:
Jeremy Long
  • Constructor Details

    • CliParser

      public CliParser(Settings settings)
      Constructs a new CLI Parser object with the configured settings.
      Parameters:
      settings - the configured settings
  • Method Details

    • parse

      public void parse(String[] args) throws FileNotFoundException, org.apache.commons.cli.ParseException
      Parses the arguments passed in and captures the results for later use.
      Parameters:
      args - the command line arguments
      Throws:
      FileNotFoundException - is thrown when a 'file' argument does not point to a file that exists.
      org.apache.commons.cli.ParseException - is thrown when a Parse Exception occurs.
    • isGetVersion

      public boolean isGetVersion()
      Determines if the 'version' command line argument was passed in.
      Returns:
      whether or not the 'version' command line argument was passed in
    • isGetHelp

      public boolean isGetHelp()
      Determines if the 'help' command line argument was passed in.
      Returns:
      whether or not the 'help' command line argument was passed in
    • isRunScan

      public boolean isRunScan()
      Determines if the 'scan' command line argument was passed in.
      Returns:
      whether or not the 'scan' command line argument was passed in
    • getSymLinkDepth

      public int getSymLinkDepth()
      Returns the symbolic link depth (how deeply symbolic links will be followed).
      Returns:
      the symbolic link depth
    • isDisabled

      public boolean isDisabled(String disableFlag, String setting)
      Utility method to determine if one of the disable options has been set. If not set, this method will check the currently configured settings for the current value to return.

      Example given `--disableArchive` on the command line would cause this method to return true for the disable archive setting.

      Parameters:
      disableFlag - the command line disable option
      setting - the corresponding settings key
      Returns:
      true if the disable option was set, if not set the currently configured value will be returned
    • isNodeAuditDisabled

      public boolean isNodeAuditDisabled()
      Returns true if the disableNodeAudit command line argument was specified.
      Returns:
      true if the disableNodeAudit command line argument was specified; otherwise false
    • isYarnAuditDisabled

      public boolean isYarnAuditDisabled()
      Returns true if the disableYarnAudit command line argument was specified.
      Returns:
      true if the disableYarnAudit command line argument was specified; otherwise false
    • isPnpmAuditDisabled

      public boolean isPnpmAuditDisabled()
      Returns true if the disablePnpmAudit command line argument was specified.
      Returns:
      true if the disablePnpmAudit command line argument was specified; otherwise false
    • isNexusUsesProxy

      public boolean isNexusUsesProxy()
      Returns true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false is returned.
      Returns:
      true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false
    • getBooleanArgument

      public Boolean getBooleanArgument(String argument)
      Returns the argument boolean value.
      Parameters:
      argument - the argument
      Returns:
      the argument boolean value
    • getStringArgument

      public String getStringArgument(String option)
      Returns the argument value for the given option.
      Parameters:
      option - the option
      Returns:
      the value of the argument
    • getStringArgument

      public String getStringArgument(String option, String key)
      Returns the argument value for the given option.
      Parameters:
      option - the option
      key - the dependency-check settings key for the option.
      Returns:
      the value of the argument
    • getStringArguments

      public String[] getStringArguments(String option)
      Returns the argument value for the given option.
      Parameters:
      option - the option
      Returns:
      the value of the argument
    • getFileArgument

      public File getFileArgument(String option)
      Returns the argument value for the given option.
      Parameters:
      option - the option
      Returns:
      the value of the argument
    • printHelp

      public void printHelp()
      Displays the command line help message to the standard output.
    • getScanFiles

      public String[] getScanFiles()
      Retrieves the file command line parameter(s) specified for the 'scan' argument.
      Returns:
      the file paths specified on the command line for scan
    • getExcludeList

      public String[] getExcludeList()
      Retrieves the list of excluded file patterns specified by the 'exclude' argument.
      Returns:
      the excluded file patterns
    • getRetireJsFilters

      public String[] getRetireJsFilters()
      Retrieves the list of retire JS content filters used to exclude JS files by content.
      Returns:
      the retireJS filters
    • isRetireJsFilterNonVulnerable

      public Boolean isRetireJsFilterNonVulnerable()
      Returns whether or not the retireJS analyzer should exclude non-vulnerable JS from the report.
      Returns:
      true if non-vulnerable JS should be filtered in the RetireJS Analyzer; otherwise null
    • getReportDirectory

      public String getReportDirectory()
      Returns the directory to write the reports to specified on the command line.
      Returns:
      the path to the reports directory.
    • getReportFormat

      public String[] getReportFormat()
      Returns the output format specified on the command line. Defaults to HTML if no format was specified.
      Returns:
      the output format name.
    • getProjectName

      public String getProjectName()
      Returns the application name specified on the command line.
      Returns:
      the application name.
    • printVersionInfo

      public void printVersionInfo()

      Prints the manifest information to standard output.

      • Implementation-Title: ${pom.name}
      • Implementation-Version: ${pom.version}
    • isUpdateOnly

      public boolean isUpdateOnly()
      Checks if the update only flag has been set.
      Returns:
      true if the update only flag has been set; otherwise false.
    • isPurge

      public boolean isPurge()
      Checks if the purge NVD flag has been set.
      Returns:
      true if the purge nvd flag has been set; otherwise false.
    • getDatabaseDriverName

      public String getDatabaseDriverName()
      Returns the database driver name if specified; otherwise null is returned.
      Returns:
      the database driver name if specified; otherwise null is returned
    • getIntegerValue

      public Integer getIntegerValue(String argument)
      Returns the argument value.
      Parameters:
      argument - the argument
      Returns:
      the value of the argument
    • hasOption

      public Boolean hasOption(String option)
      Checks if the option is present. If present it will return true; otherwise false.
      Parameters:
      option - the option to check
      Returns:
      true if auto-update is allowed; otherwise null
    • getFailOnCVSS

      public float getFailOnCVSS()
      Returns the CVSS value to fail on.
      Returns:
      11 if nothing is set. Otherwise it returns the int passed from the command line arg
    • getFloatArgument

      public float getFloatArgument(String option, float defaultValue)
      Returns the float argument for the given option.
      Parameters:
      option - the option
      defaultValue - the value if the option is not present
      Returns:
      the value of the argument if present; otherwise the defaultValue