FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ROX-22101: call gogo proto.MarshalToString through compatibility laye… · stackrox/stackrox@26dcff3 · GitHub

Commit 26dcff3

Browse files
authored
ROX-22101: call gogo proto.MarshalToString through compatibility layer (#9221)
1 parent b5d50cc commit 26dcff3

22 files changed

Lines changed: 50 additions & 58 deletions

File tree

‎central/compliance/checks/common/rbac.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package common
33
import (
44
"strings"
55

6-
"github.com/gogo/protobuf/proto"
76
"github.com/stackrox/rox/central/compliance/framework"
87
"github.com/stackrox/rox/generated/storage"
98
"github.com/stackrox/rox/pkg/k8srbac"
9+
"github.com/stackrox/rox/pkg/protocompat"
1010
setPkg "github.com/stackrox/rox/pkg/set"
1111
)
1212

@@ -89,7 +89,7 @@ func CheckDeploymentsDoNotHaveClusterAccess(ctx framework.ComplianceContext, pr
8989
framework.ForEachDeployment(ctx, func(ctx framework.ComplianceContext, deployment *storage.Deployment) {
9090
// Check deployment
9191
if !isKubeSystem(deployment) && clusterEvaluator.ForSubject(k8srbac.GetSubjectForDeployment(deployment)).Grants(pr) {
92-
framework.Failf(ctx, "deployment has cluster access to %s, this should be scoped down where possible.", proto.MarshalTextString(pr))
92+
framework.Failf(ctx, "deployment has cluster access to %s, this should be scoped down where possible.", protocompat.MarshalTextString(pr))
9393
} else {
9494
framework.Pass(ctx, "No deployments have been launched with cluster admin level access.")
9595
}

‎central/cve/edgefields/searcher.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55
"strconv"
66

7-
"github.com/gogo/protobuf/proto"
87
v1 "github.com/stackrox/rox/generated/api/v1"
98
"github.com/stackrox/rox/generated/storage"
109
"github.com/stackrox/rox/pkg/logging"
10+
"github.com/stackrox/rox/pkg/protocompat"
1111
"github.com/stackrox/rox/pkg/search"
1212
"github.com/stackrox/rox/pkg/search/scoped"
1313
)
@@ -130,7 +130,7 @@ func getCVEEdgeQuery(q *v1.Query) {
130130
search.NewQueryBuilder().AddBools(search.ClusterCVEFixable, val).ProtoQuery())
131131
}
132132
default:
133-
log.Errorf("Unhandled query type: %T; query was %s", q, proto.MarshalTextString(q))
133+
log.Errorf("Unhandled query type: %T; query was %s", q, protocompat.MarshalTextString(q))
134134
}
135135
}
136136

‎central/detection/alertmanager/alert_manager_impl_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/gogo/protobuf/proto"
1110
ptypes "github.com/gogo/protobuf/types"
1211
alertMocks "github.com/stackrox/rox/central/alert/datastore/mocks"
1312
"github.com/stackrox/rox/central/detection"
@@ -183,11 +182,11 @@ func (suite *AlertManagerTestSuite) TestNotifyAndUpdateBatch() {
183182

184183
suite.alertsMock.EXPECT().SearchRawAlerts(suite.ctx,
185184
testutils.PredMatcher("query for dep 1", func(q *v1.Query) bool {
186-
return strings.Contains(proto.MarshalTextString(q), "Dep1")
185+
return strings.Contains(protocompat.MarshalTextString(q), "Dep1")
187186
})).Return([]*storage.Alert{resolvedAlerts[0]}, nil)
188187
suite.alertsMock.EXPECT().SearchRawAlerts(suite.ctx,
189188
testutils.PredMatcher("query for dep 2", func(q *v1.Query) bool {
190-
return strings.Contains(proto.MarshalTextString(q), "Dep2")
189+
return strings.Contains(protocompat.MarshalTextString(q), "Dep2")
191190
})).Return([]*storage.Alert{resolvedAlerts[1]}, nil)
192191

193192
// Only the first alert will get notified

‎central/detection/buildtime/detector_impl_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package buildtime
33
import (
44
"testing"
55

6-
"github.com/gogo/protobuf/proto"
76
"github.com/stackrox/rox/central/detection"
87
"github.com/stackrox/rox/central/policy/datastore/mocks"
98
"github.com/stackrox/rox/generated/storage"
109
"github.com/stackrox/rox/pkg/defaults/policies"
10+
"github.com/stackrox/rox/pkg/protocompat"
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
1313
"go.uber.org/mock/gomock"
@@ -68,7 +68,7 @@ func TestDetector(t *testing.T) {
6868
expectedAlerts: 1,
6969
},
7070
} {
71-
t.Run(proto.MarshalTextString(testCase.image), func(t *testing.T) {
71+
t.Run(protocompat.MarshalTextString(testCase.image), func(t *testing.T) {
7272
filter, getUnusedCategories := detection.MakeCategoryFilter(testCase.allowedCategories)
7373
alerts, err := detector.Detect(testCase.image, filter)
7474
require.NoError(t, err)

‎central/detection/lifecycle/manager_impl.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"time"
77

8-
"github.com/gogo/protobuf/proto"
98
"github.com/pkg/errors"
109
"github.com/stackrox/rox/central/activecomponent/updater/aggregator"
1110
deploymentDatastore "github.com/stackrox/rox/central/deployment/datastore"
@@ -311,7 +310,7 @@ func (m *managerImpl) checkAndUpdateBaseline(baselineKey processBaselineKey, ind
311310

312311
func (m *managerImpl) IndicatorAdded(indicator *storage.ProcessIndicator) error {
313312
if indicator.GetId() == "" {
314-
return fmt.Errorf("invalid indicator received: %s, id was empty", proto.MarshalTextString(indicator))
313+
return fmt.Errorf("invalid indicator received: %s, id was empty", protocompat.MarshalTextString(indicator))
315314
}
316315

317316
// Evaluate filter before even adding to the queue

‎central/group/datastore/datastore_impl.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package datastore
33
import (
44
"context"
55

6-
"github.com/gogo/protobuf/proto"
76
"github.com/hashicorp/go-multierror"
87
"github.com/pkg/errors"
98
groupFilter "github.com/stackrox/rox/central/group/datastore/filter"
@@ -14,6 +13,7 @@ import (
1413
"github.com/stackrox/rox/pkg/declarativeconfig"
1514
"github.com/stackrox/rox/pkg/errox"
1615
"github.com/stackrox/rox/pkg/postgres/pgutils"
16+
"github.com/stackrox/rox/pkg/protocompat"
1717
"github.com/stackrox/rox/pkg/sac"
1818
"github.com/stackrox/rox/pkg/sac/resources"
1919
"github.com/stackrox/rox/pkg/sync"
@@ -248,7 +248,7 @@ func (ds *dataStoreImpl) RemoveAllWithEmptyProperties(ctx context.Context) error
248248
id := group.GetProps().GetId()
249249
if id == "" {
250250
removeGroupErrs = multierror.Append(removeGroupErrs, errox.InvalidArgs.Newf("group %s has no ID"+
251-
" set and cannot be deleted", proto.MarshalTextString(group)))
251+
" set and cannot be deleted", protocompat.MarshalTextString(group)))
252252
continue
253253
}
254254
if err := ds.storage.Delete(ctx, id); err != nil {

‎central/group/datastore/validate.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package datastore
22

33
import (
4-
"github.com/gogo/protobuf/proto"
54
"github.com/pkg/errors"
65
"github.com/stackrox/rox/generated/storage"
6+
"github.com/stackrox/rox/pkg/protocompat"
77
"github.com/stackrox/rox/pkg/uuid"
88
)
99

@@ -36,13 +36,13 @@ func ValidateGroup(group *storage.Group, requireID bool) error {
3636
// - if no key is given, no value shall be given.
3737
func ValidateProps(props *storage.GroupProperties, requireID bool) error {
3838
if requireID && props.GetId() == "" {
39-
return errors.Errorf("group ID must be set in {%s}", proto.MarshalTextString(props))
39+
return errors.Errorf("group ID must be set in {%s}", protocompat.MarshalTextString(props))
4040
}
4141
if props.GetAuthProviderId() == "" {
42-
return errors.Errorf("authprovider ID must be set in {%s}", proto.MarshalTextString(props))
42+
return errors.Errorf("authprovider ID must be set in {%s}", protocompat.MarshalTextString(props))
4343
}
4444
if props.GetKey() == "" && props.GetValue() != "" {
45-
return errors.Errorf("cannot have a value without a key in {%s}", proto.MarshalTextString(props))
45+
return errors.Errorf("cannot have a value without a key in {%s}", protocompat.MarshalTextString(props))
4646
}
4747
if props.GetKey() == "" && props.GetValue() == "" &&
4848
props.GetTraits().GetMutabilityMode() == storage.Traits_ALLOW_MUTATE_FORCED {

‎central/group/service/service_impl.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/stackrox/rox/pkg/grpc/authz"
1616
"github.com/stackrox/rox/pkg/grpc/authz/perrpc"
1717
"github.com/stackrox/rox/pkg/grpc/authz/user"
18+
"github.com/stackrox/rox/pkg/protocompat"
1819
"github.com/stackrox/rox/pkg/sac/resources"
1920
"google.golang.org/grpc"
2021
)
@@ -100,7 +101,7 @@ func (s *serviceImpl) GetGroup(ctx context.Context, props *storage.GroupProperti
100101
return nil, err
101102
}
102103
if group == nil {
103-
return nil, errors.Wrapf(errox.NotFound, "group %q not found", proto.MarshalTextString(props))
104+
return nil, errors.Wrapf(errox.NotFound, "group %q not found", protocompat.MarshalTextString(props))
104105
}
105106
return group, nil
106107
}

‎central/networkpolicies/generator/generator_impl_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sort"
77
"testing"
88

9-
"github.com/gogo/protobuf/proto"
109
dDSMocks "github.com/stackrox/rox/central/deployment/datastore/mocks"
1110
nsDSMocks "github.com/stackrox/rox/central/namespace/datastore/mocks"
1211
networkBaselineMocks "github.com/stackrox/rox/central/networkbaseline/datastore/mocks"
@@ -202,15 +201,15 @@ func sortPolicies(policies []*storage.NetworkPolicy) {
202201
for _, policy := range policies {
203202
for _, ingressRule := range policy.Spec.Ingress {
204203
sort.Slice(ingressRule.From, func(i, j int) bool {
205-
return proto.MarshalTextString(ingressRule.From[i]) < proto.MarshalTextString(ingressRule.From[j])
204+
return protocompat.MarshalTextString(ingressRule.From[i]) < protocompat.MarshalTextString(ingressRule.From[j])
206205
})
207206
}
208207
sort.Slice(policy.Spec.Ingress, func(i, j int) bool {
209-
return proto.MarshalTextString(policy.Spec.Ingress[i]) < proto.MarshalTextString(policy.Spec.Ingress[j])
208+
return protocompat.MarshalTextString(policy.Spec.Ingress[i]) < protocompat.MarshalTextString(policy.Spec.Ingress[j])
210209
})
211210
}
212211
sort.Slice(policies, func(i, j int) bool {
213-
return proto.MarshalTextString(policies[i]) < proto.MarshalTextString(policies[j])
212+
return protocompat.MarshalTextString(policies[i]) < protocompat.MarshalTextString(policies[j])
214213
})
215214
}
216215

‎central/role/mapper/store_based_mapper_impl.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package mapper
33
import (
44
"context"
55

6-
"github.com/gogo/protobuf/proto"
76
"github.com/pkg/errors"
87
groupDataStore "github.com/stackrox/rox/central/group/datastore"
98
roleDataStore "github.com/stackrox/rox/central/role/datastore"
@@ -12,6 +11,7 @@ import (
1211
"github.com/stackrox/rox/pkg/auth/permissions"
1312
"github.com/stackrox/rox/pkg/grpc/authn"
1413
"github.com/stackrox/rox/pkg/logging"
14+
"github.com/stackrox/rox/pkg/protocompat"
1515
"github.com/stackrox/rox/pkg/set"
1616
)
1717

@@ -44,7 +44,7 @@ func (rm *storeBasedMapperImpl) recordUser(ctx context.Context, descriptor *perm
4444

4545
if err := rm.users.Upsert(ctx, user); err != nil {
4646
// Just log since we don't actually need the user information.
47-
log.Errorf("unable to log user: %s: %v", proto.MarshalTextString(user), err)
47+
log.Errorf("unable to log user: %s: %v", protocompat.MarshalTextString(user), err)
4848
}
4949
}
5050

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL