diff --git a/.golangci.yml b/.golangci.yml index 94e639e3b..6bb95ab6c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -25,7 +25,7 @@ linters: - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - bidichk # Checks for dangerous unicode character sequences - bodyclose # Checks whether HTTP response body is closed successfully - # - copyloopvar # Detects places where loop variables are copied + - copyloopvar # Detects places where loop variables are copied - decorder # Check declaration order and count of types, constants, variables and functions - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection @@ -35,7 +35,6 @@ linters: - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - - exportloopref # checks for pointers to enclosing loop variables # - forcetypeassert # finds forced type assertions - gci # Gci control golang package import order and make it always deterministic. - gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid. diff --git a/bundle/client/coap/main.go b/bundle/client/coap/main.go index bb0fed732..a6407e91c 100644 --- a/bundle/client/coap/main.go +++ b/bundle/client/coap/main.go @@ -194,7 +194,7 @@ func updateResource(co *client.Conn, href string, contentFormat int) { if err != nil { updateError(err) } - resp, err := co.Post(context.Background(), href, message.MediaType(contentFormat), bytes.NewReader(b.Bytes())) + resp, err := co.Post(context.Background(), href, message.MediaType(contentFormat), bytes.NewReader(b.Bytes())) //nolint:gosec if err != nil { updateError(err) } @@ -210,7 +210,7 @@ func createResource(co *client.Conn, href string, contentFormat int) { if err != nil { createError(err) } - req, err := co.NewPostRequest(context.Background(), href, message.MediaType(contentFormat), os.Stdin) + req, err := co.NewPostRequest(context.Background(), href, message.MediaType(contentFormat), os.Stdin) //nolint:gosec if err != nil { createError(err) } diff --git a/bundle/client/grpc/main.go b/bundle/client/grpc/main.go index 11659f814..bc83d0dc4 100644 --- a/bundle/client/grpc/main.go +++ b/bundle/client/grpc/main.go @@ -108,7 +108,7 @@ func updateResource(ctx context.Context, client pbGW.GrpcGatewayClient, deviceID resp, err := client.UpdateResource(ctx, &pbGW.UpdateResourceRequest{ ResourceId: commands.NewResourceID(deviceID, href), Content: &pbGW.Content{ - ContentType: message.MediaType(contentFormat).String(), + ContentType: message.MediaType(contentFormat).String(), //nolint:gosec Data: data, }, }) @@ -133,7 +133,7 @@ func createResource(ctx context.Context, client pbGW.GrpcGatewayClient, deviceID resp, err := client.CreateResource(ctx, &pbGW.CreateResourceRequest{ ResourceId: commands.NewResourceID(deviceID, href), Content: &pbGW.Content{ - ContentType: message.MediaType(contentFormat).String(), + ContentType: message.MediaType(contentFormat).String(), //nolint:gosec Data: data, }, }) diff --git a/cloud2cloud-connector/service/deviceSubscription.go b/cloud2cloud-connector/service/deviceSubscription.go index f80f8647c..55cc07ec2 100644 --- a/cloud2cloud-connector/service/deviceSubscription.go +++ b/cloud2cloud-connector/service/deviceSubscription.go @@ -108,7 +108,7 @@ func (s *SubscriptionManager) handleResourcesPublished(ctx context.Context, d Su for _, endpoint := range link.GetEndpoints() { endpoints = append(endpoints, &commands.EndpointInformation{ Endpoint: endpoint.URI, - Priority: int64(endpoint.Priority), + Priority: endpoint.Priority, }) } href := pkgHttpUri.CanonicalHref(trimDeviceIDFromHref(link.DeviceID, link.Href)) @@ -120,7 +120,7 @@ func (s *SubscriptionManager) handleResourcesPublished(ctx context.Context, d Su Interfaces: link.Interfaces, DeviceId: link.DeviceID, Anchor: link.Anchor, - Policy: &commands.Policy{BitFlags: int32(link.Policy.BitMask)}, + Policy: &commands.Policy{BitFlags: commands.ToPolicyBitFlags(link.Policy.BitMask)}, Title: link.Title, SupportedContentTypes: link.SupportedContentTypes, EndpointInformations: endpoints, diff --git a/cloud2cloud-connector/service/publishResource.go b/cloud2cloud-connector/service/publishResource.go index 8646814fe..4b36a8089 100644 --- a/cloud2cloud-connector/service/publishResource.go +++ b/cloud2cloud-connector/service/publishResource.go @@ -14,7 +14,7 @@ func publishResource(ctx context.Context, raClient raService.ResourceAggregateCl for _, endpoint := range link.GetEndpoints() { endpoints = append(endpoints, &commands.EndpointInformation{ Endpoint: endpoint.URI, - Priority: int64(endpoint.Priority), + Priority: endpoint.Priority, }) } href := pkgHttpUri.CanonicalHref(trimDeviceIDFromHref(link.DeviceID, link.Href)) @@ -26,7 +26,7 @@ func publishResource(ctx context.Context, raClient raService.ResourceAggregateCl Interfaces: link.Interfaces, DeviceId: link.DeviceID, Anchor: link.Anchor, - Policy: &commands.Policy{BitFlags: int32(link.Policy.BitMask)}, + Policy: &commands.Policy{BitFlags: commands.ToPolicyBitFlags(link.Policy.BitMask)}, Title: link.Title, SupportedContentTypes: link.SupportedContentTypes, EndpointInformations: endpoints, diff --git a/coap-gateway/coapconv/coapconv.go b/coap-gateway/coapconv/coapconv.go index 7ff762d5c..95186a25b 100644 --- a/coap-gateway/coapconv/coapconv.go +++ b/coap-gateway/coapconv/coapconv.go @@ -89,7 +89,7 @@ func CoapCodeToStatus(code codes.Code, operation Operation) commands.Status { func MakeMediaType(coapContentFormat int32, contentType string) (message.MediaType, error) { if coapContentFormat >= 0 { - return message.MediaType(coapContentFormat), nil + return message.MediaType(coapContentFormat), nil //nolint:gosec } switch contentType { case message.TextPlain.String(): @@ -174,7 +174,7 @@ func NewContent(opts message.Options, body io.Reader) *commands.Content { data, coapContentFormat := GetContentData(opts, body) return &commands.Content{ - ContentType: getContentFormatString(coapContentFormat), + ContentType: GetContentFormatString(coapContentFormat), CoapContentFormat: coapContentFormat, Data: data, } @@ -192,10 +192,9 @@ func GetContentData(opts message.Options, body io.Reader) (data []byte, contentF return data, contentFormat } -func getContentFormatString(coapContentFormat int32) string { +func GetContentFormatString(coapContentFormat int32) string { if coapContentFormat != -1 { - mt := message.MediaType(coapContentFormat) - return mt.String() + return message.MediaType(coapContentFormat).String() //nolint:gosec } return "" } @@ -416,7 +415,7 @@ func NewNotifyResourceChangedRequestsFromBatchResourceDiscovery(deviceID, connec resourceChangedReq := &commands.NotifyResourceChangedRequest{ ResourceId: commands.NewResourceID(deviceID, r.Href()), Content: &commands.Content{ - ContentType: getContentFormatString(ct), + ContentType: GetContentFormatString(ct), CoapContentFormat: ct, Data: data, }, diff --git a/coap-gateway/coapconv/getEncoder.go b/coap-gateway/coapconv/getEncoder.go index 72d15b16e..ae8b35b5a 100644 --- a/coap-gateway/coapconv/getEncoder.go +++ b/coap-gateway/coapconv/getEncoder.go @@ -16,7 +16,7 @@ func GetAccept(opts message.Options) message.MediaType { if err != nil { return message.AppOcfCbor } - return message.MediaType(ct) + return message.MediaType(ct) //nolint:gosec } // GetEncoder returns encoder by accept diff --git a/coap-gateway/service/observation/deviceObserver.go b/coap-gateway/service/observation/deviceObserver.go index cd99da812..4dd94539a 100644 --- a/coap-gateway/service/observation/deviceObserver.go +++ b/coap-gateway/service/observation/deviceObserver.go @@ -363,7 +363,7 @@ func createDiscoveryResourceObserver(ctx context.Context, deviceID string, coapC err := resourcesObserver.addResource(ctx, &commands.Resource{ DeviceId: resourcesObserver.deviceID, Href: resources.ResourceURI, - Policy: &commands.Policy{BitFlags: int32(schema.Observable)}, + Policy: &commands.Policy{BitFlags: commands.ToPolicyBitFlags(schema.Observable)}, }, interfaces.OC_IF_B, etags) if err != nil { resourcesObserver.CleanObservedResources(ctx) diff --git a/coap-gateway/service/observation/deviceObserver_test.go b/coap-gateway/service/observation/deviceObserver_test.go index 45563cc49..9c10c91b8 100644 --- a/coap-gateway/service/observation/deviceObserver_test.go +++ b/coap-gateway/service/observation/deviceObserver_test.go @@ -321,7 +321,7 @@ func testValidateResourceLinks(ctx context.Context, t *testing.T, deviceID strin ResourceTypes: []string{device.ResourceType}, Interfaces: []string{interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Observable | schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Observable | schema.Discoverable), }, }, { @@ -330,7 +330,7 @@ func testValidateResourceLinks(ctx context.Context, t *testing.T, deviceID strin ResourceTypes: []string{platform.ResourceType}, Interfaces: []string{interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Observable | schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Observable | schema.Discoverable), }, }, } diff --git a/coap-gateway/service/resourceDirectory.go b/coap-gateway/service/resourceDirectory.go index 6deccec75..7a8d9d937 100644 --- a/coap-gateway/service/resourceDirectory.go +++ b/coap-gateway/service/resourceDirectory.go @@ -94,7 +94,7 @@ func parsePublishedResources(data io.ReadSeeker, deviceID string) (wkRd, error) return w, nil } -func PublishResourceLinks(ctx context.Context, raClient raService.ResourceAggregateClient, links schema.ResourceLinks, deviceID string, ttl int32, connectionID string, sequence uint64) ([]*commands.Resource, error) { +func PublishResourceLinks(ctx context.Context, raClient raService.ResourceAggregateClient, links schema.ResourceLinks, deviceID string, ttl int, connectionID string, sequence uint64) ([]*commands.Resource, error) { var validUntil time.Time if ttl > 0 { validUntil = time.Now().Add(time.Second * time.Duration(ttl)) @@ -118,7 +118,7 @@ func PublishResourceLinks(ctx context.Context, raClient raService.ResourceAggreg } func observeResources(ctx context.Context, client *session, w wkRd, sequenceNumber uint64) (coapCodes.Code, error) { - publishedResources, err := PublishResourceLinks(ctx, client.server.raClient, w.Links, w.DeviceID, int32(w.TimeToLive), client.RemoteAddr().String(), sequenceNumber) + publishedResources, err := PublishResourceLinks(ctx, client.server.raClient, w.Links, w.DeviceID, w.TimeToLive, client.RemoteAddr().String(), sequenceNumber) if err != nil { return coapCodes.BadRequest, fmt.Errorf("unable to publish resources for device %v: %w", w.DeviceID, err) } diff --git a/coap-gateway/service/service.go b/coap-gateway/service/service.go index 4975f0e78..2fefdcc2e 100644 --- a/coap-gateway/service/service.go +++ b/coap-gateway/service/service.go @@ -337,7 +337,7 @@ func New(ctx context.Context, config Config, fileWatcher *fsnotify.Watcher, logg ownerCache: ownerCache, subscriptionsCache: subscriptionsCache, - messagePool: pool.New(uint32(config.APIs.COAP.MessagePoolSize), 1024), + messagePool: pool.New(config.APIs.COAP.MessagePoolSize, 1024), logger: logger, tracerProvider: tracerProvider, } diff --git a/device-provisioning-service/service/cloudConfiguration.go b/device-provisioning-service/service/cloudConfiguration.go index cfd486305..466d127de 100644 --- a/device-provisioning-service/service/cloudConfiguration.go +++ b/device-provisioning-service/service/cloudConfiguration.go @@ -40,7 +40,7 @@ func (RequestHandle) ProcessCloudConfiguration(ctx context.Context, req *mux.Mes }, Gateways: coapGateways, ProviderName: cloudCfg.AuthorizationProvider, - SelectedGateway: int32(selectedGateway), + SelectedGateway: int32(selectedGateway), //nolint:gosec }, }) return msg, err diff --git a/device-provisioning-service/service/config.go b/device-provisioning-service/service/config.go index 9f4542a98..e95cf4ad1 100644 --- a/device-provisioning-service/service/config.go +++ b/device-provisioning-service/service/config.go @@ -259,9 +259,9 @@ func HTTPConfigToProto(cfg pkgHttpClient.Config) (*pb.HttpConfig, error) { } return &pb.HttpConfig{ - MaxIdleConns: uint32(cfg.MaxIdleConns), - MaxConnsPerHost: uint32(cfg.MaxConnsPerHost), - MaxIdleConnsPerHost: uint32(cfg.MaxIdleConnsPerHost), + MaxIdleConns: uint32(cfg.MaxIdleConns), //nolint:gosec + MaxConnsPerHost: uint32(cfg.MaxConnsPerHost), //nolint:gosec + MaxIdleConnsPerHost: uint32(cfg.MaxIdleConnsPerHost), //nolint:gosec IdleConnTimeout: cfg.IdleConnTimeout.Nanoseconds(), Timeout: cfg.Timeout.Nanoseconds(), Tls: tls, diff --git a/device-provisioning-service/service/service.go b/device-provisioning-service/service/service.go index e2373f97c..04cf3e6bf 100644 --- a/device-provisioning-service/service/service.go +++ b/device-provisioning-service/service/service.go @@ -176,7 +176,7 @@ func New(ctx context.Context, config Config, fileWatcher *fsnotify.Watcher, logg ctx: ctx, cancel: cancel, - messagePool: pool.New(uint32(config.APIs.COAP.MessagePoolSize), 1024), + messagePool: pool.New(config.APIs.COAP.MessagePoolSize, 1024), store: store, logger: logger, authHandler: optCfg.authHandler, diff --git a/grpc-gateway/pb/README.md b/grpc-gateway/pb/README.md index e61e136bf..50e2e0945 100644 --- a/grpc-gateway/pb/README.md +++ b/grpc-gateway/pb/README.md @@ -1262,7 +1262,7 @@ If true - show UI element, if false - hide UI element | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | endpoint | [string](#string) | | | -| priority | [int64](#int64) | | | +| priority | [uint64](#uint64) | | | diff --git a/grpc-gateway/pb/doc.html b/grpc-gateway/pb/doc.html index 4f8ab66b5..4dd4ac4d6 100644 --- a/grpc-gateway/pb/doc.html +++ b/grpc-gateway/pb/doc.html @@ -3621,7 +3621,7 @@

EndpointInformation

priority - int64 + uint64

diff --git a/grpc-gateway/pb/service.swagger.json b/grpc-gateway/pb/service.swagger.json index 71f8df8d9..257209969 100644 --- a/grpc-gateway/pb/service.swagger.json +++ b/grpc-gateway/pb/service.swagger.json @@ -1637,7 +1637,7 @@ }, "priority": { "type": "string", - "format": "int64" + "format": "uint64" } } }, diff --git a/grpc-gateway/service/createAndDeleteResource_test.go b/grpc-gateway/service/createAndDeleteResource_test.go index 70318c623..63b07ddc4 100644 --- a/grpc-gateway/service/createAndDeleteResource_test.go +++ b/grpc-gateway/service/createAndDeleteResource_test.go @@ -126,7 +126,7 @@ func createSwitchResourceExpectedEvents(t *testing.T, deviceID, subID, correlati ResourceTypes: []string{types.BINARY_SWITCH}, Interfaces: []string{interfaces.OC_IF_A, interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Discoverable | schema.Observable), + BitFlags: commands.ToPolicyBitFlags(schema.Discoverable | schema.Observable), }, }, }, diff --git a/pkg/net/coap/service/config.go b/pkg/net/coap/service/config.go index eeae3dfd4..6587a57f4 100644 --- a/pkg/net/coap/service/config.go +++ b/pkg/net/coap/service/config.go @@ -22,7 +22,7 @@ type Config struct { Addr string `yaml:"address" json:"address"` Protocols []Protocol `yaml:"protocols" json:"protocols"` MaxMessageSize uint32 `yaml:"maxMessageSize" json:"maxMessageSize"` - MessagePoolSize int `yaml:"messagePoolSize" json:"messagePoolSize"` + MessagePoolSize uint32 `yaml:"messagePoolSize" json:"messagePoolSize"` MessageQueueSize int `yaml:"messageQueueSize" json:"messageQueueSize"` BlockwiseTransfer BlockwiseTransferConfig `yaml:"blockwiseTransfer" json:"blockwiseTransfer"` TLS TLSConfig `yaml:"tls" json:"tls"` @@ -61,9 +61,6 @@ func (c *Config) Validate() error { if c.MaxMessageSize <= 64 { return fmt.Errorf("maxMessageSize('%v')", c.MaxMessageSize) } - if c.MessagePoolSize < 0 { - return fmt.Errorf("messagePoolSize('%v')", c.MessagePoolSize) - } if len(c.Protocols) == 0 { return fmt.Errorf("protocols('%v')", c.Protocols) } diff --git a/pkg/net/coap/service/service.go b/pkg/net/coap/service/service.go index fd1aa1bd0..b0e7df78c 100644 --- a/pkg/net/coap/service/service.go +++ b/pkg/net/coap/service/service.go @@ -96,7 +96,7 @@ func New(ctx context.Context, config Config, router *mux.Router, fileWatcher *fs return nil, err } serviceOpts := Options{ - MessagePool: pool.New(uint32(config.MessagePoolSize), 1024), + MessagePool: pool.New(config.MessagePoolSize, 1024), OnInactivityConnection: makeOnInactivityConnection(logger), } for _, o := range opt { diff --git a/pkg/net/grpc/server/makeDefaultOptions.go b/pkg/net/grpc/server/makeDefaultOptions.go index 868ac95d2..417b8e3ab 100644 --- a/pkg/net/grpc/server/makeDefaultOptions.go +++ b/pkg/net/grpc/server/makeDefaultOptions.go @@ -157,7 +157,7 @@ func defaultMessageProducer(ctx context.Context, ctxLogger context.Context, msg } tags := grpc_ctxtags.Extract(ctx) newTags := grpc_ctxtags.NewTags() - newTags.Set(log.DurationMSKey, math.Float32frombits(uint32(duration.Integer))) + newTags.Set(log.DurationMSKey, math.Float32frombits(uint32(duration.Integer))) //nolint:gosec newTags.Set(log.ProtocolKey, "GRPC") for k, v := range tags.Values() { if strings.EqualFold(k, grpcPrefixKey+"."+requestKey+"."+log.StartTimeKey) { diff --git a/pkg/security/certManager/general/certManager_test.go b/pkg/security/certManager/general/certManager_test.go index 995985636..3101e880b 100644 --- a/pkg/security/certManager/general/certManager_test.go +++ b/pkg/security/certManager/general/certManager_test.go @@ -178,18 +178,18 @@ func TestCertManagerWithExpiredCA(t *testing.T) { defer mng.Close() pool := mng.GetCertificateAuthorities() require.NotNil(t, pool) - require.Len(t, pool.Subjects(), 1) + require.Len(t, pool.Subjects(), 1) //nolint:staticcheck time.Sleep(time.Second * 2) pool = mng.GetCertificateAuthorities() require.NotNil(t, pool) - require.Empty(t, pool.Subjects()) + require.Empty(t, pool.Subjects()) //nolint:staticcheck caPem, _ = getCA(t, time.Now(), time.Second*100) err = os.WriteFile(caFile.Name(), caPem, os.FileMode(os.O_RDWR)) require.NoError(t, err) time.Sleep(time.Second * 1) pool = mng.GetCertificateAuthorities() require.NotNil(t, pool) - require.Len(t, pool.Subjects(), 1) + require.Len(t, pool.Subjects(), 1) //nolint:staticcheck } // Check when cert expires diff --git a/resource-aggregate/commands/eventContentToContent.go b/resource-aggregate/commands/eventContentToContent.go index 20ea9491f..7ce76557d 100644 --- a/resource-aggregate/commands/eventContentToContent.go +++ b/resource-aggregate/commands/eventContentToContent.go @@ -25,7 +25,7 @@ func EventContentToContent(ec EventContent) (*Content, error) { if c != nil { contentType := c.GetContentType() if contentType == "" && c.GetCoapContentFormat() >= 0 { - contentType = message.MediaType(c.GetCoapContentFormat()).String() + contentType = message.MediaType(c.GetCoapContentFormat()).String() //nolint:gosec } content = &Content{ Data: c.GetData(), diff --git a/resource-aggregate/commands/resouces.go b/resource-aggregate/commands/resouces.go index a82ec198b..9e37114f6 100644 --- a/resource-aggregate/commands/resouces.go +++ b/resource-aggregate/commands/resouces.go @@ -1,5 +1,7 @@ package commands +import "github.com/plgd-dev/device/v2/schema" + func (c *Content) Clone() *Content { if c == nil { return nil @@ -74,3 +76,7 @@ func CloneResourcesMap(resources map[string]*Resource) map[string]*Resource { } return c } + +func ToPolicyBitFlags(bm schema.BitMask) int32 { + return int32(bm) //nolint:gosec +} diff --git a/resource-aggregate/commands/resourceconv.go b/resource-aggregate/commands/resourceconv.go index 8e81851a0..3f44a808c 100644 --- a/resource-aggregate/commands/resourceconv.go +++ b/resource-aggregate/commands/resourceconv.go @@ -10,7 +10,7 @@ import ( func (e *EndpointInformation) ToSchema() schema.Endpoint { return schema.Endpoint{ URI: e.GetEndpoint(), - Priority: uint64(e.GetPriority()), + Priority: e.GetPriority(), } } @@ -67,7 +67,7 @@ func SchemaEndpointsToRAEndpointInformations(ra []schema.Endpoint) []*EndpointIn for _, e := range ra { r = append(r, &EndpointInformation{ Endpoint: e.URI, - Priority: int64(e.Priority), + Priority: e.Priority, }) } return r @@ -78,7 +78,7 @@ func SchemaPolicyToRAPolicy(ra *schema.Policy) *Policy { return nil } return &Policy{ - BitFlags: int32(ra.BitMask), + BitFlags: ToPolicyBitFlags(ra.BitMask), } } diff --git a/resource-aggregate/commands/resources.pb.go b/resource-aggregate/commands/resources.pb.go index 5217d02c8..14a0b1771 100644 --- a/resource-aggregate/commands/resources.pb.go +++ b/resource-aggregate/commands/resources.pb.go @@ -456,7 +456,7 @@ type EndpointInformation struct { unknownFields protoimpl.UnknownFields Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - Priority int64 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"` + Priority uint64 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"` } func (x *EndpointInformation) Reset() { @@ -498,7 +498,7 @@ func (x *EndpointInformation) GetEndpoint() string { return "" } -func (x *EndpointInformation) GetPriority() int64 { +func (x *EndpointInformation) GetPriority() uint64 { if x != nil { return x.Priority } @@ -562,7 +562,7 @@ var file_resource_aggregate_pb_resources_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x2a, 0xe2, 0x01, 0x0a, + 0x28, 0x04, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x2a, 0xe2, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x42, 0x41, 0x44, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x02, 0x12, 0x10, 0x0a, diff --git a/resource-aggregate/events/resourceStateSnapshotTaken.go b/resource-aggregate/events/resourceStateSnapshotTaken.go index f1d99c2aa..d830fe360 100644 --- a/resource-aggregate/events/resourceStateSnapshotTaken.go +++ b/resource-aggregate/events/resourceStateSnapshotTaken.go @@ -421,7 +421,7 @@ func convertContent(content *commands.Content, supportedContentType string) (new contentType := content.GetContentType() coapContentFormat := int32(-1) if content.GetCoapContentFormat() >= 0 && contentType == "" { - contentType = message.MediaType(content.GetCoapContentFormat()).String() + contentType = message.MediaType(content.GetCoapContentFormat()).String() //nolint:gosec } if len(supportedContentType) == 0 { supportedContentType = contentType @@ -463,11 +463,11 @@ func convertContent(content *commands.Content, supportedContentType string) (new data, err := encode(m) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "cannot encode content data to %v: %v", message.MediaType(coapContentFormat).String(), err) + return nil, status.Errorf(codes.InvalidArgument, "cannot encode content data to %v: %v", message.MediaType(coapContentFormat).String(), err) //nolint:gosec } return &commands.Content{ CoapContentFormat: coapContentFormat, - ContentType: message.MediaType(coapContentFormat).String(), + ContentType: message.MediaType(coapContentFormat).String(), //nolint:gosec Data: data, }, nil } diff --git a/resource-aggregate/pb/resources.proto b/resource-aggregate/pb/resources.proto index 8f9fb6b27..af00a4a16 100644 --- a/resource-aggregate/pb/resources.proto +++ b/resource-aggregate/pb/resources.proto @@ -41,7 +41,7 @@ message Content { message EndpointInformation { string endpoint = 1; - int64 priority = 2; + uint64 priority = 2; } enum Status { diff --git a/test/virtual-device/virtualDevice.go b/test/virtual-device/virtualDevice.go index 54b23096a..55ff77a2c 100644 --- a/test/virtual-device/virtualDevice.go +++ b/test/virtual-device/virtualDevice.go @@ -39,7 +39,7 @@ func CreateDeviceResourceLinks(deviceID string, numResources int, tdEnabled bool ResourceTypes: []string{fmt.Sprintf("res-type-%v", i)}, Interfaces: []string{interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Observable | schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Observable | schema.Discoverable), }, }) } @@ -49,7 +49,7 @@ func CreateDeviceResourceLinks(deviceID string, numResources int, tdEnabled bool ResourceTypes: []string{device.ResourceType}, Interfaces: []string{interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Observable | schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Observable | schema.Discoverable), }, }) resources = append(resources, &commands.Resource{ @@ -58,7 +58,7 @@ func CreateDeviceResourceLinks(deviceID string, numResources int, tdEnabled bool ResourceTypes: []string{platform.ResourceType}, Interfaces: []string{interfaces.OC_IF_BASELINE}, Policy: &commands.Policy{ - BitFlags: int32(schema.Observable | schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Observable | schema.Discoverable), }, }) @@ -69,7 +69,7 @@ func CreateDeviceResourceLinks(deviceID string, numResources int, tdEnabled bool ResourceTypes: []string{thingDescription.ResourceType}, Interfaces: []string{interfaces.OC_IF_BASELINE, interfaces.OC_IF_R}, Policy: &commands.Policy{ - BitFlags: int32(schema.Discoverable), + BitFlags: commands.ToPolicyBitFlags(schema.Discoverable), }, }) } diff --git a/tools/mongodb/standby-tool/main.go b/tools/mongodb/standby-tool/main.go index 8d40f1f4e..c01e79cae 100644 --- a/tools/mongodb/standby-tool/main.go +++ b/tools/mongodb/standby-tool/main.go @@ -502,7 +502,7 @@ func (app *App) updateSecondaryMemberConfig(member string, config primitive.M) ( if memberMap["host"] == member { memberMap["hidden"] = false memberMap["priority"] = float64(app.Config.ReplicaSet.Secondary.Priority) - memberMap["votes"] = int32(app.Config.ReplicaSet.Secondary.Votes) + memberMap["votes"] = int32(app.Config.ReplicaSet.Secondary.Votes) //nolint:gosec memberMap["secondaryDelaySecs"] = int32(0) } newMembers = append(newMembers, memberMap) @@ -682,7 +682,7 @@ func getValue(v primitive.M, keys ...string) (interface{}, bool) { if !ok { return nil, false } - return getValue(sub, keys[1:]...) + return getValue(sub, keys[1:]...) //nolint:gosec } func (app *App) getStatus(ctx context.Context, client *mongo.Client) (primitive.M, error) {