Skip to content

Commit

Permalink
Remove go-playground/validator dependency from pkg/pki (#1817)
Browse files Browse the repository at this point in the history
See sigstore/sigstore-go#23.

It might seem silly, but this reduces the size of sigstore-go by over 1 MB.
We're already using asaskevich/govalidator elsewhere in Rekor, so no new
dependencies added.

If we wanted to remove go-playground/validator entirely from Rekor (which
would shrink rekor-cli by over 1 MB as well), we'd need additional work
to rekor-cli/app/ files pflags.go and validate.go.

Signed-off-by: Zach Steindler <[email protected]>
  • Loading branch information
steiza authored Nov 8, 2023
1 parent aac533d commit b681a14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions pkg/pki/pgp/pgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"io"
"net/http"

validator "github.com/go-playground/validator/v10"
"github.com/asaskevich/govalidator"

//TODO: https://github.com/sigstore/rekor/issues/286
"golang.org/x/crypto/openpgp" //nolint:staticcheck
Expand Down Expand Up @@ -295,9 +295,7 @@ func (k PublicKey) EmailAddresses() []string {
// Extract from cert
for _, entity := range k.key {
for _, identity := range entity.Identities {
validate := validator.New()
errs := validate.Var(identity.UserId.Email, "required,email")
if errs == nil {
if govalidator.IsEmail(identity.UserId.Email) {
names = append(names, identity.UserId.Email)
}
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/pki/x509/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"io"
"strings"

validator "github.com/go-playground/validator/v10"
"github.com/asaskevich/govalidator"
"github.com/sigstore/rekor/pkg/pki/identity"
"github.com/sigstore/sigstore/pkg/cryptoutils"
sigsig "github.com/sigstore/sigstore/pkg/signature"
Expand Down Expand Up @@ -184,10 +184,8 @@ func (k PublicKey) EmailAddresses() []string {
cert = k.certs[0]
}
if cert != nil {
validate := validator.New()
for _, name := range cert.EmailAddresses {
errs := validate.Var(name, "required,email")
if errs == nil {
if govalidator.IsEmail(name) {
names = append(names, strings.ToLower(name))
}
}
Expand Down

0 comments on commit b681a14

Please sign in to comment.