patch to resolve issue #137 - the output path can be a file name if the format is not ALL

Former-commit-id: 05c638b21f09842781e105259ff58819e4bd3e8c
This commit is contained in:
Jeremy Long
2014-11-09 19:52:42 -05:00
parent d90e7820cd
commit e6806fdf2b
3 changed files with 37 additions and 10 deletions

View File

@@ -167,15 +167,28 @@ public class ReportGenerator {
*/
public void generateReports(String outputDir, String outputFormat) throws IOException, Exception {
final String format = outputFormat.toUpperCase();
final String pathToCheck = outputDir.toLowerCase();
if (format.matches("^(XML|HTML|VULN|ALL)$")) {
if ("XML".equalsIgnoreCase(format)) {
generateReports(outputDir, Format.XML);
if (pathToCheck.endsWith(".xml")) {
generateReport("XmlReport", outputDir);
} else {
generateReports(outputDir, Format.XML);
}
}
if ("HTML".equalsIgnoreCase(format)) {
generateReports(outputDir, Format.HTML);
if (pathToCheck.endsWith(".html") || pathToCheck.endsWith(".htm")) {
generateReport("HtmlReport", outputDir);
} else {
generateReports(outputDir, Format.HTML);
}
}
if ("VULN".equalsIgnoreCase(format)) {
generateReports(outputDir, Format.VULN);
if (pathToCheck.endsWith(".html") || pathToCheck.endsWith(".htm")) {
generateReport("VulnReport", outputDir);
} else {
generateReports(outputDir, Format.VULN);
}
}
if ("ALL".equalsIgnoreCase(format)) {
generateReports(outputDir, Format.ALL);