From 4734356172d01b924ffafb5fe0be84824bcf0146 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Thu, 7 Dec 2023 06:18:07 -0500 Subject: [PATCH] fix: allow api key in cli to be quoted (#6253) --- cli/src/main/java/org/owasp/dependencycheck/App.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/main/java/org/owasp/dependencycheck/App.java b/cli/src/main/java/org/owasp/dependencycheck/App.java index fd0ff0fb56c..12ed6ab6db1 100644 --- a/cli/src/main/java/org/owasp/dependencycheck/App.java +++ b/cli/src/main/java/org/owasp/dependencycheck/App.java @@ -649,7 +649,13 @@ protected void populateSettings(CliParser cli) throws InvalidSettingException { settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_ASSEMBLY_DOTNET_PATH, cli.getStringArgument(CliParser.ARGUMENT.PATH_TO_CORE)); - settings.setStringIfNotEmpty(Settings.KEYS.NVD_API_KEY, cli.getStringArgument(CliParser.ARGUMENT.NVD_API_KEY)); + String key = cli.getStringArgument(CliParser.ARGUMENT.NVD_API_KEY); + if (key != null) { + if ((key.startsWith("\"") && key.endsWith("\"") || (key.startsWith("'") && key.endsWith("'")))) { + key = key.substring(1, key.length() - 1); + } + settings.setStringIfNotEmpty(Settings.KEYS.NVD_API_KEY, key); + } settings.setIntIfNotNull(Settings.KEYS.NVD_API_DELAY, cli.getIntegerValue(CliParser.ARGUMENT.NVD_API_DELAY)); settings.setStringIfNotEmpty(Settings.KEYS.NVD_API_DATAFEED_URL, cli.getStringArgument(CliParser.ARGUMENT.NVD_API_DATAFEED_URL)); settings.setStringIfNotEmpty(Settings.KEYS.NVD_API_DATAFEED_USER, cli.getStringArgument(CliParser.ARGUMENT.NVD_API_DATAFEED_USER));