Skip to content

Commit

Permalink
Develop (#49)
Browse files Browse the repository at this point in the history
* Adding update analysis queue and exchange (#41)

* Adding update analysis queue and exchange

* Removing unnecessary typing form exchanges

* Removing update exchange and queues

* add language Swift (#43)

* Adding owasp dependency check tool (#46)

* main (#48)

* Horusec-Swift (#44)

* Adding update analysis queue and exchange (#41)

* Adding update analysis queue and exchange

* Removing unnecessary typing form exchanges

* Removing update exchange and queues

* add language Swift (#43)

Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com>
Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com>

* Develop (#47)

* Adding update analysis queue and exchange (#41)

* Adding update analysis queue and exchange

* Removing unnecessary typing form exchanges

* Removing update exchange and queues

* add language Swift (#43)

* Adding owasp dependency check tool (#46)

Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com>
Co-authored-by: wilian <wilian.silva@zup.com.br>

* Remove migrations folder (#45)

Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com>
Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com>

* Adding length enums and fix lint

Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com>
Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 17, 2021
1 parent 09e050a commit 57cf6f2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
8 changes: 6 additions & 2 deletions libs/semver/internal/utils/str/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@

package str

import "strconv"
import (
"strconv"

"github.com/ZupIT/horusec-devkit/pkg/enums/ozzovalidation"
)

func ParseUIntOrDefault(s string) uint {
value, err := strconv.ParseUint(s, 10, 64)
value, err := strconv.ParseUint(s, ozzovalidation.Length10, ozzovalidation.Length64)
if err != nil {
return 0
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/enums/ozzovalidation/values.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ozzovalidation

const (
Length0 = 0
Length1 = 1
Length5 = 5
Length6 = 6
Length10 = 10
Length64 = 64
Length255 = 255
Length500 = 500
)
4 changes: 3 additions & 1 deletion pkg/services/http/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"net/http"
"time"

"github.com/ZupIT/horusec-devkit/pkg/enums/ozzovalidation"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
Expand Down Expand Up @@ -47,7 +49,7 @@ type Router struct {
func NewHTTPRouter(corsOptions *cors.Options, defaultPort string) IRouter {
router := &Router{
port: env.GetEnvOrDefault(enums.HorusecPort, defaultPort),
timeout: time.Duration(env.GetEnvOrDefaultInt(enums.HorusecRouterTimeout, 10)) * time.Second,
timeout: time.Duration(env.GetEnvOrDefaultInt(enums.HorusecRouterTimeout, ozzovalidation.Length10)) * time.Second,
corsOptions: corsOptions,
router: chi.NewRouter(),
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/utils/jwt/entities/jwt_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/go-ozzo/ozzo-validation/v4/is"
"github.com/google/uuid"

"github.com/ZupIT/horusec-devkit/pkg/enums/ozzovalidation"
)

type JWTClaims struct {
Expand All @@ -30,8 +32,10 @@ type JWTClaims struct {

func (j *JWTClaims) Validate() error {
return validation.ValidateStruct(j,
validation.Field(&j.Username, validation.Required, validation.Length(1, 255)),
validation.Field(&j.Email, validation.Required, validation.Length(1, 255)),
validation.Field(&j.Username, validation.Required,
validation.Length(ozzovalidation.Length1, ozzovalidation.Length255)),
validation.Field(&j.Email, validation.Required,
validation.Length(ozzovalidation.Length1, ozzovalidation.Length255)),
validation.Field(&j.Subject, validation.Required, is.UUID, validation.NotIn(uuid.Nil)),
)
}

0 comments on commit 57cf6f2

Please sign in to comment.