Skip to content

Commit

Permalink
fix: improve error messages for AssemblyAnalyzer (#5408)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong authored Feb 2, 2023
2 parents 53fcc3b + 031dd12 commit edbae1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public void prepareFileTypeAnalyzer(Engine engine) throws InitializationExceptio
+ "'exe' or 'dll' was scanned. The 'dotnet' executable could not be found on "
+ "the path; either disable the Assembly Analyzer or add the path to dotnet "
+ "core in the configuration.");
LOGGER.error("The dotnet 6.0 core runtime or SDK is required to analyze assemblies");
LOGGER.error("----------------------------------------------------");
return;
}
Expand All @@ -365,17 +366,18 @@ public void prepareFileTypeAnalyzer(Engine engine) throws InitializationExceptio
processReader.readAll();
final String error = processReader.getError();
if (p.exitValue() != 1 || !StringUtils.isBlank(error)) {
LOGGER.warn("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details.");
LOGGER.warn("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details.\n"
+ "dependency-check requires dotnet 6.0 core runtime or sdk to be installed to analyze assemblies.");
LOGGER.debug("GrokAssembly.dll is not working properly");
grokAssembly = null;
setEnabled(false);
throw new InitializationException("Could not execute .NET AssemblyAnalyzer");
throw new InitializationException("Could not execute .NET AssemblyAnalyzer, is the dotnet 6.0 runtime or sdk installed?");
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.warn("An error occurred with the .NET AssemblyAnalyzer;\n"
+ "dependency-check requires dotnet 6.0 core to be installed to analyze assemblies;\n"
+ "dependency-check requires dotnet 6.0 core runtime or sdk to be installed to analyze assemblies;\n"
+ "this can be ignored unless you are scanning .NET DLLs. Please see the log for more details.");
LOGGER.debug("Could not execute GrokAssembly {}", e.getMessage());
setEnabled(false);
Expand All @@ -386,7 +388,7 @@ public void prepareFileTypeAnalyzer(Engine engine) throws InitializationExceptio
+ "this can be ignored unless you are scanning .NET DLLs. Please see the log for more details.");
LOGGER.debug("Could not execute GrokAssembly {}", e.getMessage());
setEnabled(false);
throw new InitializationException("An error occurred with the .NET AssemblyAnalyzer", e);
throw new InitializationException("An error occurred with the .NET AssemblyAnalyzer, is the dotnet 6.0 runtime or sdk installed?", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void testWithSettingMono() throws Exception {
aanalyzer.prepare(null);
fail("Expected an InitializationException");
} catch (InitializationException ae) {
assertEquals("An error occurred with the .NET AssemblyAnalyzer", ae.getMessage());
assertEquals("An error occurred with the .NET AssemblyAnalyzer, is the dotnet 6.0 runtime or sdk installed?", ae.getMessage());
} finally {
System.setProperty(LOG_KEY, oldProp);
// Recover the logger
Expand Down

0 comments on commit edbae1c

Please sign in to comment.