Merge pull request #40 from pushbits/sast

Scan the code with SAST
This commit is contained in:
Raphael Eikenberg 2022-02-13 17:38:43 +01:00 committed by GitHub
commit 561ad9df59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 3222 additions and 19 deletions

View file

@ -35,7 +35,11 @@ func (h *ApplicationHandler) registerApplication(ctx *gin.Context, a *model.Appl
}
a.MatrixID = channelID
h.DB.UpdateApplication(a)
err = h.DB.UpdateApplication(a)
if success := successOrAbort(ctx, http.StatusInternalServerError, err); !success {
return err
}
return nil
}
@ -55,7 +59,6 @@ func (h *ApplicationHandler) createApplication(ctx *gin.Context, u *model.User,
if err := h.registerApplication(ctx, &application, u); err != nil {
err := h.DB.DeleteApplication(&application)
if success := successOrAbort(ctx, http.StatusInternalServerError, err); !success {
log.Printf("Cannot delete application with ID %d.", application.ID)
}

View file

@ -44,6 +44,8 @@ func (h *UserHandler) deleteApplications(ctx *gin.Context, u *model.User) error
}
for _, application := range applications {
application := application // See https://stackoverflow.com/a/68247837
if err := h.AH.deleteApplication(ctx, &application, u); err != nil {
return err
}
@ -59,6 +61,8 @@ func (h *UserHandler) updateChannels(ctx *gin.Context, u *model.User, matrixID s
}
for _, application := range applications {
application := application // See https://stackoverflow.com/a/68247837
err := h.DP.DeregisterApplication(&application, u)
if success := successOrAbort(ctx, http.StatusInternalServerError, err); !success {
return err
@ -68,6 +72,8 @@ func (h *UserHandler) updateChannels(ctx *gin.Context, u *model.User, matrixID s
u.MatrixID = matrixID
for _, application := range applications {
application := application // See https://stackoverflow.com/a/68247837
err := h.AH.registerApplication(ctx, &application, u)
if err != nil {
return err
@ -169,10 +175,10 @@ func (h *UserHandler) GetUsers(ctx *gin.Context) {
return
}
var externalUsers []*model.ExternalUser
externalUsers := make([]*model.ExternalUser, len(users))
for _, user := range users {
externalUsers = append(externalUsers, user.IntoExternalUser())
for i, user := range users {
externalUsers[i] = user.IntoExternalUser()
}
ctx.JSON(http.StatusOK, &externalUsers)