Added support for changelog

This commit is contained in:
Šesták Vít
2016-03-09 09:55:00 +01:00
parent 4994a603b6
commit b1f04c3987
6 changed files with 139 additions and 8 deletions

View File

@@ -104,9 +104,12 @@ class Notifications @Inject()(
parsedReports = dependencyCheckReportsParser.parseReports(successfulReports)
lds = LibDepStatistics(dependencies = parsedReports.groupedDependencies.toSet, libraries = libraries.toSet)
issuesExportResultFuture = exportToIssueTracker(lds, parsedReports.projectsReportInfo)
diffDbExportResultFuture = exportToDiffDb(lds, parsedReports.projectsReportInfo)
//mailExportResultFuture = diffDbExportResultFuture.flatMap(_ => exportToEmailDigest(lds, parsedReports.projectsReportInfo))
mailExportResultFuture = exportToEmail(lds, parsedReports.projectsReportInfo)
(missingTickets, newTicketIds, updatedTickets) <- issuesExportResultFuture
(missingEmails, newMessageIds, updatedEmails) <- mailExportResultFuture
(missingVulns, newVulnIds, updatedVulns) <- diffDbExportResultFuture
} yield Ok(
missingTickets.mkString("\n") + "\n\n" + newTicketIds.mkString("\n") + updatedTickets.toString +
"\n\n" +
@@ -130,6 +133,7 @@ class Notifications @Inject()(
}
}
// FIXME: In case of crash during export, one change might be exported multiple times. This can't be solved in e-mail exports, but it might be solved in issueTracker and diffDb exports.
private def exportToIssueTracker(lds: LibDepStatistics, p: ProjectsWithReports) = forService(issueTrackerServiceOption){ issueTrackerService =>
notifyVulnerabilities[String](lds, notificationService.issueTrackerExport, p) { (vulnerability, dependencies) =>
issueTrackerService.reportVulnerability(vulnerability)
@@ -138,6 +142,21 @@ class Notifications @Inject()(
}
}
private def exportToDiffDb(lds: LibDepStatistics, p: ProjectsWithReports) = {
notifyVulnerabilities[String](lds, notificationService.diffDbExport, p){ (vulnerability, dependencies) =>
//?save_new_vulnerability
val affectedProjects = dependencies.flatMap(_.projects)
val diff = new SetDiff(Set(), affectedProjects)
notificationService.changeAffectedProjects(vulnerability.name, diff.map(_.fullId)).map{_ =>
ExportedVulnerability[String](vulnerabilityName = vulnerability.name, ticket = vulnerability.name, ticketFormatVersion = 0)
}
}{ (vulnerability, diff, id) =>
notificationService.changeAffectedProjects(vulnerability.name, diff).map{_ =>
()
}
}
}
// Redirection to a specific position does not look intuituve now, so it has been disabled for now.
private def redirectToProject(project: String)(implicit th: DefaultRequest) = Redirect(routes.Notifications.listProjects()/*.withFragment("project-" + URLEncoder.encode(project, "utf-8")).absoluteURL()*/)