Fix some bugs (#788)

* fix config restore

* fix panic on middleware

Co-authored-by: AlteredCoder <AlteredCoder>
This commit is contained in:
AlteredCoder 2021-05-07 18:40:01 +02:00 committed by GitHub
parent ab4878d4e6
commit fd830b4293
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View file

@ -417,6 +417,9 @@ func NewConfigCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var err error
if err := csConfig.LoadHub(); err != nil {
log.Fatalf(err.Error())
}
if err = cwhub.GetHubIdx(csConfig.Hub); err != nil {
log.Fatalf("Failed to get Hub index : %v", err)
log.Infoln("Run 'sudo cscli hub update' to get the hub index")

View file

@ -9,7 +9,6 @@ import (
"strings"
"github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)
@ -49,7 +48,6 @@ func HashSHA512(str string) string {
func (a *APIKey) MiddlewareFunc() gin.HandlerFunc {
return func(c *gin.Context) {
defer types.CatchPanic("crowdsec/middlewaresV1/api_key/MiddlewareFunc")
val, ok := c.Request.Header[APIKeyHeader]
if !ok {
c.JSON(http.StatusForbidden, gin.H{"message": "access forbidden"})

View file

@ -13,7 +13,6 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/database"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/gin-gonic/gin"
"github.com/go-openapi/strfmt"
log "github.com/sirupsen/logrus"
@ -45,7 +44,6 @@ func IdentityHandler(c *gin.Context) interface{} {
}
func (j *JWT) Authenticator(c *gin.Context) (interface{}, error) {
defer types.CatchPanic("crowdsec/middlewaresV1/jwt/Authenticator")
var loginInput models.WatcherAuthRequest
var scenarios string
var err error