Add security notifications to inform about vulnerabilities (#1924)

Add security notifications in SCM-Manager to inform running instances about known security issues. These alerts can be core or plugin specific and will be shown to every user in the header.

Co-authored-by: Matthias Thieroff <matthias.thieroff@cloudogu.com>
Co-authored-by: Philipp Ahrendt <philipp.ahrendt@cloudogu.com>
Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com>
This commit is contained in:
Eduard Heimbuch
2022-01-19 11:58:55 +01:00
committed by GitHub
parent 07fa753f80
commit 63ec4e6172
42 changed files with 1379 additions and 420 deletions

View File

@@ -43,6 +43,7 @@ import sonia.scm.NotFoundException;
import sonia.scm.ScmConstraintViolationException;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ContextResolver;
@@ -111,13 +112,16 @@ public class RestDispatcher {
}
private Integer getStatus(Exception ex) {
if (ex instanceof WebApplicationException) {
return ((WebApplicationException) ex).getResponse().getStatus();
}
return statusCodes
.entrySet()
.stream()
.filter(e -> e.getKey().isAssignableFrom(ex.getClass()))
.map(Map.Entry::getValue)
.findAny()
.orElse(handleUnknownException(ex));
.orElseGet(() -> handleUnknownException(ex));
}
private Integer handleUnknownException(Exception ex) {