You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/08/10 15:31:25 UTC

[GitHub] [incubator-eventmesh] github-code-scanning[bot] commented on a diff in pull request #1140: [ISSUE #1139] add plugin module

github-code-scanning[bot] commented on code in PR #1140:
URL: https://github.com/apache/incubator-eventmesh/pull/1140#discussion_r942599892


##########
eventmesh-server-go/plugin/naming/nacos/registry/registry.go:
##########
@@ -0,0 +1,106 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package registry
+
+import (
+	"github.com/gogf/gf/util/gconv"
+	"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
+	"github.com/nacos-group/nacos-sdk-go/v2/vo"
+	"github.com/pkg/errors"
+	"net"
+	"strconv"
+)
+
+const (
+	DefaultClusterName = "DEFAULT"
+	DefaultGroupName   = "DEFAULT_GROUP"
+)
+const (
+	defaultWeight = 100
+)
+
+// Registry register service
+type Registry struct {
+	// Provider: public for user custom
+	Provider naming_client.INamingClient
+	cfg      *Config
+	host     string
+	port     int
+}
+
+// newRegistry 新建实例
+func newRegistry(provider naming_client.INamingClient, cfg *Config) *Registry {
+	return &Registry{
+		Provider: provider,
+		cfg:      cfg,
+	}
+}
+
+// Register registry service, application can invoke this method to register service to remote registry-server
+func (r *Registry) Register(_ string) error {
+	host, portRaw, err := net.SplitHostPort(r.cfg.Address)
+	if err != nil {
+		return err
+	}
+	port, err := strconv.ParseInt(portRaw, 10, 64)
+	if err != nil {
+		return err
+	}
+	r.host = host
+	r.port = int(port)

Review Comment:
   ## Incorrect conversion between integer types
   
   Incorrect conversion of a 64-bit integer from [strconv.ParseInt](1) to a lower bit size type int without an upper bound check.
   
   [Show more details](https://github.com/apache/incubator-eventmesh/security/code-scanning/5)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org