Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
git.xx.network/elixxir/grpc-web-go-client
THE IMPLEMENTATION IS LACKING
gRPC Web client written in Go.
The server is here.
Send an unary request.
client := grpcweb.NewClient("localhost:50051")
in, out := new(api.SimpleRequest), new(api.SimpleResponse)
in.Name = "ktr"
// You can get the endpoint from grpcweb.ToEndpoint function with descriptors.
// However, I write directly in this example.
req := grpcweb.NewRequest("/api.Example/Unary", in, out)
res, err := client.Unary(context.Background(), req)
if err != nil {
log.Fatal(err)
}
// hello, ktr
fmt.Println(res.Content.(*api.SimpleResponse).GetMessage())
Send a server-side streaming request.
req := grpcweb.NewRequest("/api.Example/ServerStreaming", in, out)
stream, err := client.ServerStreaming(context.Background(), req)
if err != nil {
log.Fatal(err)
}
for {
res, err := stream.Receive()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Content.(*api.SimpleResponse).GetMessage())
}
Send an client-side streaming request.
stream, err := client.ClientStreaming(context.Background())
if err != nil {
log.Fatal(err)
}
in, out := new(api.SimpleRequest), new(api.SimpleResponse)
in.Name = "ktr"
req := grpcweb.NewRequest("/api.Example/ClientStreaming", in, out)
for i := 0; i < 10; i++ {
err := stream.Send(req)
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
}
res, err := stream.CloseAndReceive()
if err != nil {
log.Fatal(err)
}
// ktr, you greet 10 times.
fmt.Println(res.Content.(*api.SimpleResponse).GetMessage())
Send a bidirectional streaming request.
in, out := new(api.SimpleRequest), new(api.SimpleResponse)
req := grpcweb.NewRequest("/api.Example/BidiStreaming", in, out)
stream := client.BidiStreaming(context.Background(), req)
go func() {
for {
res, err := stream.Receive()
if err == grpcweb.ErrConnectionClosed {
return
}
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Content.(*api.SimpleResponse).GetMessage())
}
}()
for i := 0; i < 2; i++ {
in.Name = fmt.Sprintf("ktr%d", i+1)
req := grpcweb.NewRequest("/api.Example/BidiStreaming", in, out)
err := stream.Send(req)
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
}
// wait a moment to get responses.
time.Sleep(10 * time.Second)
if err := stream.Close(); err != nil {
log.Fatal(err)
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.