Giter Site home page Giter Site logo

grpc-client-cli's People

Contributors

bli22ard avatar dependabot[bot] avatar jhaygood86 avatar vadimi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

grpc-client-cli's Issues

[Question] How to add metadata to requests?

I would like to make an authorized request to a gRPC service, which requires me to send a JWT token
in the request metadata.
I don't see an option to add metadata in help, is this supported?

--insecure does not work

I was trying to connect to a server using a custom CA:

grpc-client-cli.exe --tls --insecure -V some-service.example.com:443

and it still failed as if I hadn't passed --insecure:


Method:
Status: 14 Unavailable

Request Headers:

Request duration: 43.8533ms
Request size: 0 bytes
Response size: 0 bytes

rpc error: code = Unavailable desc = last connection error: connection error: desc = "transport: authentication handshake failed: x509: certificate signed by unknown authority"

A quick check of the code suggests that the command-line flag value is passed into WithConnCred but is not stored into GrpcConnFactorySettings in the returned closure, so the value is lost. Nothing else in this file appears to set GrpcConnFactorySettings.insecure either.

Looking at #19 suggest this has never worked? I'm surprised I'm the first one to hit this.

Include default google protobuf

In my protobuf files I have imports like this:

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

When I try to call the tool it answers with:

$ grpc-client-cli --address localhost:9101 --proto path/my.proto 
error parsing proto files: my.proto:7:8: open path/google/api/annotations.proto: no such file or directory

It could have an option to automatically include that.
Those come from:

Handful of CVEs detected in vulnerability scanner

We use grpc-client-cli in our containers, and our security vulnerability scanner that we run on our CI/CD pipeline is showing errors:

`
tools/grpc-client-cli (gobinary)

Total: 3 (HIGH: 3, CRITICAL: 0)

┌───────────────────┬────────────────┬──────────┬────────────────────────────────────┬───────────────────────────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Installed Version │ Fixed Version │ Title │
├───────────────────┼────────────────┼──────────┼────────────────────────────────────┼───────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ golang.org/x/net │ CVE-2021-44716 │ HIGH │ v0.0.0-20210813160813-60bc85c4be6d │ 0.0.0-20211209124913-491a49abca63 │ golang: net/http: limit growth of header canonicalization │
│ │ │ │ │ │ cache │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2021-44716
│ ├────────────────┤ │ ├───────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ │ CVE-2022-27664 │ │ │ 0.0.0-20220906165146-f3363e06e74c │ golang: net/http: handle server errors after sending GOAWAY │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-27664
├───────────────────┼────────────────┤ ├────────────────────────────────────┼───────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ golang.org/x/text │ CVE-2022-32149 │ │ v0.3.7 │ 0.3.8 │ golang: golang.org/x/text/language: ParseAcceptLanguage │
│ │ │ │ │ │ takes a long time to parse complex tags │
│ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2022-32149
└───────────────────┴────────────────┴──────────┴────────────────────────────────────┴───────────────────────────────────┴─────────────────────────────────────────────────────────────┘
`

M1 support

Hi guys, are there any plans for m1(arm) support?

Seems like custom Headers are not sent

Hello

I'm testing a demo service. It exposes a method to register new users. It returns an ID inside the JSON response and a token inside an extra Header called "token" (nothing in production so it's safe to show).

sudo tcpdump -A -i any port 50051 | grep token
    tcpdump: data link type LINUX_SLL2
    tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
    listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
    .Your id is 687.............token..b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoia2FsaSIsImV4cCI6MTY5MDY2MDEwMn0.UyNVRd-jCCvcf_oCoNA1M2-Fi0i0_vtGUNqIsz1QxRA'.............

I need to send the token back:

echo '{"id":"678"}' | grpc-client-cli --service demoApp --method getInfo --header "token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoia2FsaSIsImV4cCI6MTY5MDY2MDEwMn0.UyNVRd-jCCvcf_oCoNA1M2-Fi0i0_vtGUNqIsz1QxRA'" 192.168.0.100:50051
{
  "message": "Authorization Error.Missing 'token' header"
}

Seems like the token is never sent over the network. I tested various forms without success:

-H "token: b'xxxyyy'"
-H "token: xxxyyy"
-H "token: 'xxxyyy'"
-H "Authorization: xxxyyy"
...

I tried to send an unique string to see if it's transmitted:

echo '{"a":"b"}' | grpc-client-cli --service demoApp --method getInfo --header "myuniquestring: value123" 192.168.0.100:50051

sudo tcpdump -A -i any port 50051 | grep myuniquestring

The header is never transmitted. Maybe i'm missing something obvious.

I looked into the source code to find out what's the problem without any success.

Is there any additional information i can submit to debug this issue?

how to use protoimports

grpc-client-cli \
		--proto /Users/me/Projects/my-apis/src/proto/my/protobuf/scorn/v1 \
		--protoimports /Users/me/Projects/my-apis/src/proto/my/protobuf/common/v1 \
		services.mine.io:443 

exits with an error

error parsing proto files: scorn-sync.proto:7:8: open /Users/me/Projects/my-apis/src/proto/my/protobuf/scorn/v1/my/protobuf/common/v1/common.proto: no such file or directory

Inside scorn/v1, we have a proto file with import

import "my/protobuf/common/v1/common.proto";

So my question is , what is the correct parameter here?

Imports does not work

I my proto files:

import "google/protobuf/Empty.proto";
...

I run in terminal (on linux, libprotoc 3.12.4):

grpc-client-cli --proto /path/to/proto/files localhost:9000

And got:

error parsing proto files: [File name] .../google/protobuf/Empty.proto: no such file or director

It is possible to add support for imported local & remote proto files or am I doing smth wrong?

--service option does not seem to work

I tried using the --service option and passed both the long and short service. I get an error that the service name is invalid. When I run without the --service option it asks to pick a service. I copied the exact name from there but It still doesn't work.

Trying to do something like this

grpc-client-cli localhost:5000 -s TestService -m hello

the result is not camelCase

message Test{
	string test_test = 1;
}

//  result
{
	"test_test": "test"
}

It should be

{
	"testTest": "test"
}

according to https://developers.google.com/protocol-buffers/docs/proto3#json

Generates JSON objects. Message field names are mapped to lowerCamelCase and become JSON object keys. If the json_name field option is specified, the specified value will be used as the key instead. Parsers accept both the lowerCamelCase name (or the one specified by the json_name option) and the original proto field name. null is an accepted value for all field types and treated as the default value of the corresponding field type.

json_name option is not working too.

Netflix Eureka integration

I already have the code (locally), but wouldn't mind coming up with a good design to integrate it upstream.

essential idea is that your grpc target is in URI format like this: eureka://service-name/
Some options that would be needed is the Eureka endpoint (though defaulting to http://localhost:8167/eureka/ should be fine, the ability to use a different endpoint would be required)

I'm thinking this: grpc-client-cli eureka://service-name/,registry=http://registry:8167

I'm very open to suggestions to improve this, but it'd be nice to have this upstream (versus just on my laptop)

Enhance -format option - allow splitting of input and output

Split from #24

  1. Add new -inputformat and -outputformat
  2. Make sure -format is still supported as a shortcut to -inputformat and -outputformat being the same (the branch I created will need to be updated for that)

Discussion from #24

Collaborator Author
netdragonboberb commented 26 days ago

Hi @vadimi I tested, and when I did -format text I also got text output. Can we have -inputformat and -outputformat?
e.g.
grpc-client-cli -s com.xx.xx.SuperService -m SuperMethod x.x.x.x:xxxx -inputformat text -outputformat json -i dump.txt
@netdragonboberb
Collaborator Author
netdragonboberb commented 26 days ago •

@vadimi I may be able to do this. I think I just edit the caller to newResultPrinter and then add the new options?
@netdragonboberb
Collaborator Author
netdragonboberb commented 26 days ago •

@vadimi I started it here https://github.com/netdragonboberb/grpc-client-cli/tree/bb/proto-combined then I got stuck because no matter what I did, the output is still in text when I do -outformat json I even see "Output format: json" in the print message I created. If both informat and outformat match, it works as expected. Can you tell what I'm doing wrong? (I'm just tackling non-streaming for now)

You can see a diff here https://github.com/netdragonboberb/grpc-client-cli/pull/3/files
@vadimi
Owner
vadimi commented 26 days ago

hey @netdragonboberb, yeah -informat and -outformat are looking good as options.

the reason you're still getting text instead of json is caller.NewServiceCaller(a.connFact, a.opts.InFormat). ServiceCaller performs marshalling and unmarshalling as well, and it uses a.opts.InFormat, you'd need to add another parameter to NewServiceCaller that will accept a.opts.OutFormat

Handle input in protobuf debug format

@jhaygood86 and I talked about adding functionality to handle protobuf debug format like the following from a dump from Java. It's quite a bit of work to convert it. Perhaps either auto-detect of through a flag, or a seperate command line parameter to convert it and dump the converted output (would probably be the easiest). This will be tracked against for adding it.

object1 { object_uid: "e0166542-24be-4077-88fa-a8755df766d1" values { valuea { currency_code: "USD" units: 100 } valueb { currency_code: "USD" units: 85 } } }

Usage of this as a library

Is there a way to use this as a library within a go module rather than using it on the command line ?
If yes can you point me to the documentation of the same ?

Windows path delimiter causing "error parsing proto files: open products.proto: The system cannot find the file specified."

The tool seems not be able to handle backslashes in paths on Windows:

This is not working

PS C:\Users\User> grpc-client-cli --proto "E:\src\CompanyName\ERP.Prototype.Backend\Prototype\ERP.Backend.gRPC\Protos\products.proto" localhost:5140
error parsing proto files: open products.proto: The system cannot find the file specified.

This does work:

PS C:\Users\User> grpc-client-cli --proto "E:/src/CompanyName/ERP.Prototype.Backend/Prototype/ERP.Backend.gRPC/Protos/products.proto" localhost:5140
? Choose a service:  [Use arrows to move, type to filter]
→ products.ProductService

Expected behaviour:
Since backslashes are the normal path delimiter in windows, I expect the client to be able to open the file.
As a minimal solution, the error message could be more helpful by e.g. repeating the path, so the user might see that the grpc-client has problems with backslashes. Or just add a static hint when the file is not found.

support tls connections

We need to add options to the cli to support tls connections: --tls. Mutual tls also needs to be supported.

  • grpc tls connection
  • eureka secure port usage

oneof not displayed when you type '?' after choosing the method

If you put a oneof in your request data, it is not displayed when you go to the service, choose the method, and click '?'

I'm not sure if it's specific to the message (doubt it) so I gave a sample of the actual message with names changed.

message SampleRequest {
MyEntity entity = 1;
oneof inputs_oneof {
MyInputs current_bill_inputs = 2;
MyInputs ytd_inputs = 3;
}
int64 foo = 4;
repeated MyData data_rows = 5;
}

Example:
Message json (type ? to see defaults): ?
{"entity":null,"foo":"0","data_rows":[]}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.