From 8167146372dd546bdcdf3421e8bbb14dbff48dcd Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 8 Mar 2014 06:19:21 -0500 Subject: [PATCH] added validation for pathToMono argument Former-commit-id: 5a2a58c96ee91b0d0dbf7b5a658a776da8a7141f --- .../org/owasp/dependencycheck/cli/CliParser.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/cli/CliParser.java b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/cli/CliParser.java index ead23f78d..19b3f969e 100644 --- a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/cli/CliParser.java +++ b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/cli/CliParser.java @@ -84,8 +84,11 @@ public final class CliParser { */ private void validateArgs() throws FileNotFoundException, ParseException { if (isRunScan()) { - validatePathExists(getScanFiles(), "scan"); - validatePathExists(getReportDirectory(), "out"); + validatePathExists(getScanFiles(), ArgumentName.SCAN); + validatePathExists(getReportDirectory(), ArgumentName.OUT); + if (getPathToMono() != null) { + validatePathExists(getPathToMono(), ArgumentName.PATH_TO_MONO); + } if (!line.hasOption(ArgumentName.APP_NAME)) { throw new ParseException("Missing 'app' argument; the scan cannot be run without the an application name."); } @@ -121,14 +124,14 @@ public final class CliParser { * FileNotFoundException is thrown. * * @param path the paths to validate if they exists - * @param optType the option being validated (e.g. scan, out, etc.) + * @param argumentName the argument being validated (e.g. scan, out, etc.) * @throws FileNotFoundException is thrown if the path being validated does not exist. */ - private void validatePathExists(String path, String optType) throws FileNotFoundException { + private void validatePathExists(String path, String argumentName) throws FileNotFoundException { final File f = new File(path); if (!f.exists()) { isValid = false; - final String msg = String.format("Invalid '%s' argument: '%s'", optType, path); + final String msg = String.format("Invalid '%s' argument: '%s'", argumentName, path); throw new FileNotFoundException(msg); } }