Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use pointers to interfaces #294

Merged
merged 4 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ require (
cloud.google.com/go/compute v1.6.1
github.com/GoogleCloudPlatform/opentelemetry-operations-go v1.0.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0
github.com/abcxyz/jvs v0.0.0-20220713181819-5cc3eb83dc6b
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220713181819-5cc3eb83dc6b
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220915004312-db26d444b9ae
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.3.0
github.com/lestrrat-go/jwx/v2 v2.0.3
Expand Down
14 changes: 6 additions & 8 deletions clients/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go v1.0.0/go.mod h1:geb4
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0 h1:38fNtfhHY6bs22b/D6+hDzO6JR0rDzpGPD36dY2uPL4=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0/go.mod h1:jE23wM1jvwSKgdGcoOkj5j9n1VWtncW36pL2bK1JU+0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/abcxyz/jvs v0.0.0-20220713181819-5cc3eb83dc6b h1:uhx0EiUkwUoy/1Hem9pwZpSI0cZuJ9BVlqjTvOYDAPg=
github.com/abcxyz/jvs v0.0.0-20220713181819-5cc3eb83dc6b/go.mod h1:6XWVLVHrfIBFXN76Fh072E8nd0RSmSyYr9MKArSRAr8=
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220713181819-5cc3eb83dc6b h1:CSIaB0wokXj9Jg/WWi5yGjD7dZh+U+0lmhcwE9HDpT0=
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220713181819-5cc3eb83dc6b/go.mod h1:NfOLJjKgctTBVl2JdDON861Ei6JGLSP6itlUn28Odc4=
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862 h1:DEU4U/AgVWsxWhrO9rBUytuuXL6tznVPDxx2q2DI6c0=
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862/go.mod h1:Sz/e+0vW0XIIeeIS4KDLIeh1Bb/CPAvQiZOdOTBiW4k=
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae h1:M3yMSghNGXElhcEOJBxqlO8QQRs3cVmM5ncDl69C00I=
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae/go.mod h1:m9PZgVFkkLDtncjzrcwXbvBhMwpOCvggWqsAwMxNtQg=
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220915004312-db26d444b9ae h1:kFhazhdgrLp52yDe4p3nLjGjeELbb/9YhjlckEAN6e4=
github.com/abcxyz/jvs/client-lib/go v0.0.0-20220915004312-db26d444b9ae/go.mod h1:MEmok7HO/fVqapbrQIBulDK805eHE0ZXvHgRCPFRV6s=
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9 h1:ROwNYAzdaFBjS9dTzmTjwgW84QaKQWxUFm3zlSbP77I=
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9/go.mod h1:Sz/e+0vW0XIIeeIS4KDLIeh1Bb/CPAvQiZOdOTBiW4k=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand All @@ -97,8 +97,6 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
4 changes: 2 additions & 2 deletions clients/go/pkg/audit/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type fakeJVS struct {
returnErr bool
}

func (j *fakeJVS) ValidateJWT(_ string) (*jwt.Token, error) {
func (j *fakeJVS) ValidateJWT(_ string) (jwt.Token, error) {
if j.returnErr {
return nil, fmt.Errorf("validate jwt error")
}
Expand All @@ -91,7 +91,7 @@ func (j *fakeJVS) ValidateJWT(_ string) (*jwt.Token, error) {
if err := t.Set(jwt.JwtIDKey, "123"); err != nil {
return nil, err
}
return &t, nil
return t, nil
}

func TestUnaryInterceptor(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion clients/go/pkg/auditopt/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func justificationFromConfig(ctx context.Context, cfg *api.Config) (audit.Option
// TODO(#299): allow overriding these values via JVS env var.
jvsconfig := &client.JVSConfig{
JVSEndpoint: cfg.Justification.PublicKeysEndpoint,
Version: 1,
Version: "1",
CacheTimeout: 5 * time.Minute,
}
jvsClient, err := client.NewJVSClient(ctx, jvsconfig)
Expand Down
6 changes: 3 additions & 3 deletions clients/go/pkg/justification/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
// Validator validates justification token generated by JVS.
type Validator interface {
// ValidateJWT validates justification token generated by JVS.
ValidateJWT(jvsToken string) (*jwt.Token, error)
ValidateJWT(jvsToken string) (jwt.Token, error)
}

// Processor populates an audit log request with justification.
Expand Down Expand Up @@ -71,7 +71,7 @@ func (p *Processor) Process(ctx context.Context, logReq *api.AuditLogRequest) er
return fmt.Errorf("failed to validate justification token: %w", err)
}

b, err := json.Marshal(*tok)
b, err := json.Marshal(tok)
if err != nil {
return fmt.Errorf("failed to encode justification token: %w", err)
}
Expand All @@ -93,7 +93,7 @@ func (p *Processor) Process(ctx context.Context, logReq *api.AuditLogRequest) er

logReq.Payload.Metadata.Fields[LogMetadataKey] = structpb.NewStructValue(&tokStruct)

justs, ok := (*tok).Get("justs")
justs, ok := tok.Get("justs")
if !ok {
logger.Warn("can't find 'justs' in claims")
} else {
Expand Down
4 changes: 2 additions & 2 deletions clients/go/pkg/justification/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ type fakeValidator struct {
justifications []*jvsapi.Justification
}

func (v *fakeValidator) ValidateJWT(jvsToken string) (*jwt.Token, error) {
func (v *fakeValidator) ValidateJWT(jvsToken string) (jwt.Token, error) {
if v.returnErr {
return nil, fmt.Errorf("failed to validate JWT")
}
Expand All @@ -159,5 +159,5 @@ func (v *fakeValidator) ValidateJWT(jvsToken string) (*jwt.Token, error) {
if err := tok.Set("justs", v.justifications); err != nil {
return nil, err
}
return &tok, nil
return tok, nil
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
cloud.google.com/go/bigquery v1.32.0
cloud.google.com/go/compute v1.6.1
cloud.google.com/go/logging v1.4.2
github.com/abcxyz/jvs v0.0.1
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae
github.com/abcxyz/lumberjack/clients/go v0.0.0-00010101000000-000000000000
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go v1.0.0/go.mod h1:geb4
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0 h1:38fNtfhHY6bs22b/D6+hDzO6JR0rDzpGPD36dY2uPL4=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0/go.mod h1:jE23wM1jvwSKgdGcoOkj5j9n1VWtncW36pL2bK1JU+0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/abcxyz/jvs v0.0.1 h1:hgX0lRUE/00skxnJet34DfhCVQHd8Abkv1iiVrV4c2s=
github.com/abcxyz/jvs v0.0.1/go.mod h1:rNyEfHM1lxOKHzrDGGqzvneJ5r3Bl/9W52rog8pQbs8=
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862 h1:DEU4U/AgVWsxWhrO9rBUytuuXL6tznVPDxx2q2DI6c0=
github.com/abcxyz/pkg v0.0.0-20220627210229-493bf5fec862/go.mod h1:Sz/e+0vW0XIIeeIS4KDLIeh1Bb/CPAvQiZOdOTBiW4k=
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae h1:M3yMSghNGXElhcEOJBxqlO8QQRs3cVmM5ncDl69C00I=
github.com/abcxyz/jvs v0.0.2-0.20220915004312-db26d444b9ae/go.mod h1:m9PZgVFkkLDtncjzrcwXbvBhMwpOCvggWqsAwMxNtQg=
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9 h1:ROwNYAzdaFBjS9dTzmTjwgW84QaKQWxUFm3zlSbP77I=
github.com/abcxyz/pkg v0.0.0-20220719233420-62c7b76c10e9/go.mod h1:Sz/e+0vW0XIIeeIS4KDLIeh1Bb/CPAvQiZOdOTBiW4k=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down