Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use exit codes between 0 and 255 (inclusive) #4511

Merged
merged 2 commits into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions cli/src/main/java/org/owasp/dependencycheck/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public int run(String[] args) {
} catch (FileNotFoundException ex) {
System.err.println(ex.getMessage());
cli.printHelp();
return -1;
return 1;
} catch (ParseException ex) {
System.err.println(ex.getMessage());
cli.printHelp();
return -2;
return 2;
}
final String verboseLog = cli.getStringArgument(CliParser.ARGUMENT.VERBOSE_LOG);
if (verboseLog != null) {
Expand All @@ -134,19 +134,19 @@ public int run(String[] args) {
final String connStr = cli.getStringArgument(CliParser.ARGUMENT.CONNECTION_STRING);
if (connStr != null) {
LOGGER.error("Unable to purge the database when using a non-default connection string");
exitCode = -3;
exitCode = 3;
} else {
try {
populateSettings(cli);
} catch (InvalidSettingException ex) {
LOGGER.error(ex.getMessage());
LOGGER.debug(ERROR_LOADING_PROPERTIES_FILE, ex);
exitCode = -4;
exitCode = 4;
return exitCode;
}
try (Engine engine = new Engine(Engine.Mode.EVIDENCE_PROCESSING, settings)) {
if (!engine.purge()) {
exitCode = -7;
exitCode = 7;
return exitCode;
}
} finally {
Expand All @@ -162,17 +162,17 @@ public int run(String[] args) {
} catch (InvalidSettingException ex) {
LOGGER.error(ex.getMessage());
LOGGER.debug(ERROR_LOADING_PROPERTIES_FILE, ex);
exitCode = -4;
exitCode = 4;
return exitCode;
}
try {
runUpdateOnly();
} catch (UpdateException ex) {
LOGGER.error(ex.getMessage(), ex);
exitCode = -8;
exitCode = 8;
} catch (DatabaseException ex) {
LOGGER.error(ex.getMessage(), ex);
exitCode = -9;
exitCode = 9;
} finally {
settings.cleanup();
}
Expand All @@ -182,7 +182,7 @@ public int run(String[] args) {
} catch (InvalidSettingException ex) {
LOGGER.error(ex.getMessage(), ex);
LOGGER.debug(ERROR_LOADING_PROPERTIES_FILE, ex);
exitCode = -4;
exitCode = 4;
return exitCode;
}
try {
Expand All @@ -196,17 +196,17 @@ public int run(String[] args) {
} catch (DatabaseException ex) {
LOGGER.error(ex.getMessage());
LOGGER.debug("database exception", ex);
exitCode = -11;
exitCode = 11;
} catch (ReportException ex) {
LOGGER.error(ex.getMessage());
LOGGER.debug("report exception", ex);
exitCode = -12;
exitCode = 12;
} catch (ExceptionCollection ex) {
if (ex.isFatal()) {
exitCode = -13;
exitCode = 13;
LOGGER.error("One or more fatal errors occurred");
} else {
exitCode = -14;
exitCode = 14;
}
for (Throwable e : ex.getExceptions()) {
if (e.getMessage() != null) {
Expand Down Expand Up @@ -336,7 +336,7 @@ private int determineReturnCode(Engine engine, float cvssFailScore) {
+ "equal to '%.1f': %n%s%n%nSee the dependency-check report for more details.%n%n", cvssFailScore, ids)
);

retCode = 1;
retCode = 15;
}

return retCode;
Expand Down