mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-10 08:36:53 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user