Skip to content

Commit

Permalink
validate uri
Browse files Browse the repository at this point in the history
addresses review comment ava-labs/icm-services#344 (comment)
  • Loading branch information
feuGeneA committed Jul 22, 2024
1 parent 367b5a0 commit 9271981
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"log"
"net/http"
"net/url"
"os"
"runtime"
"strconv"
Expand Down Expand Up @@ -463,14 +464,19 @@ func createDeciderClient(host string, port *uint16) (*grpc.ClientConn, error) {
host = "localhost"
}

uri := strings.Join(
[]string{host, strconv.FormatUint(uint64(*port), 10)},
":",
)

_, err := url.ParseRequestURI(uri)
if err != nil {
return nil, fmt.Errorf("Invalid URI: %w", err)
}

client, err := grpc.NewClient(
strings.Join(
[]string{host, strconv.FormatUint(uint64(*port), 10)},
":",
),
grpc.WithTransportCredentials(
insecure.NewCredentials(),
),
uri,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return nil, fmt.Errorf(
Expand Down

0 comments on commit 9271981

Please sign in to comment.