From 8bb92815cbd0ec6ff713975def6eaeed0a938e70 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 29 Aug 2015 06:58:13 -0400 Subject: [PATCH] added argument to purge local NVD per issue #328 --- .../org/owasp/dependencycheck/CliParser.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java index 02cf78d31..33fb11fa7 100644 --- a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java +++ b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java @@ -394,6 +394,10 @@ public final class CliParser { final Option disableNexusAnalyzer = OptionBuilder.withLongOpt(ARGUMENT.DISABLE_NEXUS) .withDescription("Disable the Nexus Analyzer.").create(); + final Option purge = OptionBuilder.withLongOpt(ARGUMENT.PROJECT) + .withDescription("Purges the local NVD data cache") + .create(); + options.addOption(updateOnly) .addOption(cve12Base) .addOption(cve20Base) @@ -428,7 +432,8 @@ public final class CliParser { .addOption(nexusUrl) .addOption(nexusUsesProxy) .addOption(additionalZipExtensions) - .addOption(pathToMono); + .addOption(pathToMono) + .addOption(purge); } /** @@ -878,7 +883,7 @@ public final class CliParser { * @return true if auto-update is allowed; otherwise false */ public boolean isAutoUpdate() { - return (line == null) || !line.hasOption(ARGUMENT.DISABLE_AUTO_UPDATE); + return line != null && !line.hasOption(ARGUMENT.DISABLE_AUTO_UPDATE); } /** @@ -887,7 +892,16 @@ public final class CliParser { * @return true if the update only flag has been set; otherwise false. */ public boolean isUpdateOnly() { - return (line == null) || line.hasOption(ARGUMENT.UPDATE_ONLY); + return line != null && line.hasOption(ARGUMENT.UPDATE_ONLY); + } + + /** + * Checks if the purge NVD flag has been set. + * + * @return true if the purge nvd flag has been set; otherwise false. + */ + public boolean isPurge() { + return line != null && line.hasOption(ARGUMENT.PURGE_NVD); } /** @@ -969,6 +983,10 @@ public final class CliParser { * The long CLI argument name specifying that only the update phase should be executed; no scan should be run. */ public static final String UPDATE_ONLY = "updateonly"; + /** + * The long CLI argument name specifying that only the update phase should be executed; no scan should be run. + */ + public static final String PURGE_NVD = "purgelocalnvd"; /** * The long CLI argument name specifying the directory to write the reports to. */