Class CliParser
java.lang.Object
org.owasp.dependencycheck.CliParser
A utility to parse command line arguments for the DependencyCheck.
- Author:
- Jeremy Long
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA collection of static final strings that represent the possible command line arguments. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBooleanArgument(String argument) Returns the argument boolean value.Returns the database driver name if specified; otherwise null is returned.String[]Retrieves the list of excluded file patterns specified by the 'exclude' argument.floatReturns the CVSS value to fail on.getFileArgument(String option) Returns the argument value for the given option.floatgetFloatArgument(String option, float defaultValue) Returns the float argument for the given option.getIntegerValue(String argument) Returns the argument value.Returns the application name specified on the command line.Returns the directory to write the reports to specified on the command line.String[]Returns the output format specified on the command line.String[]Retrieves the list of retire JS content filters used to exclude JS files by content.String[]Retrieves the file command line parameter(s) specified for the 'scan' argument.getStringArgument(String option) Returns the argument value for the given option.getStringArgument(String option, String key) Returns the argument value for the given option.String[]getStringArguments(String option) Returns the argument value for the given option.intReturns the symbolic link depth (how deeply symbolic links will be followed).Checks if the option is present.booleanisDisabled(String disableFlag, String setting) Utility method to determine if one of the disable options has been set.booleanDetermines if the 'help' command line argument was passed in.booleanDetermines if the 'version' command line argument was passed in.booleanReturns true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false is returned.booleanReturns true if the disableNodeAudit command line argument was specified.booleanReturns true if the disablePnpmAudit command line argument was specified.booleanisPurge()Checks if the purge NVD flag has been set.Returns whether or not the retireJS analyzer should exclude non-vulnerable JS from the report.booleanDetermines if the 'scan' command line argument was passed in.booleanChecks if the update only flag has been set.booleanReturns true if the disableYarnAudit command line argument was specified.voidParses the arguments passed in and captures the results for later use.voidDisplays the command line help message to the standard output.voidPrints the manifest information to standard output.
-
Constructor Details
-
CliParser
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
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 optionsetting- 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
-
getStringArgument
-
getStringArgument
-
getStringArguments
-
getFileArgument
-
printHelp
public void printHelp()Displays the command line help message to the standard output. -
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
Retrieves the list of excluded file patterns specified by the 'exclude' argument.- Returns:
- the excluded file patterns
-
getRetireJsFilters
Retrieves the list of retire JS content filters used to exclude JS files by content.- Returns:
- the retireJS filters
-
isRetireJsFilterNonVulnerable
Returns whether or not the retireJS analyzer should exclude non-vulnerable JS from the report.- Returns:
trueif non-vulnerable JS should be filtered in the RetireJS Analyzer; otherwisenull
-
getReportDirectory
Returns the directory to write the reports to specified on the command line.- Returns:
- the path to the reports directory.
-
getReportFormat
Returns the output format specified on the command line. Defaults to HTML if no format was specified.- Returns:
- the output format name.
-
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:
trueif the update only flag has been set; otherwisefalse.
-
isPurge
public boolean isPurge()Checks if the purge NVD flag has been set.- Returns:
trueif the purge nvd flag has been set; otherwisefalse.
-
getDatabaseDriverName
Returns the database driver name if specified; otherwise null is returned.- Returns:
- the database driver name if specified; otherwise null is returned
-
getIntegerValue
-
hasOption
-
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
Returns the float argument for the given option.- Parameters:
option- the optiondefaultValue- the value if the option is not present- Returns:
- the value of the argument if present; otherwise the defaultValue
-