Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
github.com/findkim/consul-mock-api
Consul Mock HTTP API helpers
package somepkg
import (
"testing"
"github.com/hashicorp/consul/api"
mockconsul "github.com/mkeeler/consul-mock-api"
)
func TestTokenList(t *testing.T) {
m := mockconsul.NewConsul(t)
// http.Get will add both of the headers but we don't want to care about them.
m.SetFilteredHeaders([]string{
"Accept-Encoding",
"User-Agent",
})
// set up an expectation for a GET /v1/acl/tokens
m.ACLTokenList(200, []*api.ACLTokenListEntry{
CreateIndex: 1,
ModifyIndex: 2,
AccessorID: "cd45b25a-07cf-4a60-ae71-2a227eaace8e",
Description: "fake token",
NodeIdentities: []*api.ACLNodeIdentity{
{
NodeName: "foo",
Datacenter: "dc1",
},
},
}).Once() // expect this call to be made exactly once
cfg := api.DefaultConfig()
cfg.Address = m.URL()
client, err := api.NewClient(cfg)
if err != nil {
t.Fatalf("error when creating a new HTTP client: %v", err)
}
tokens, _, err := client.ACL().TokenList(nil)
if err != nil {
t.Fatalf("error when retrieving token list: %v", err)
}
if len(tokens) != 1 {
t.Fatalf("wrong number of token returned - expected: 1, got: %d", len(tokens))
}
// no need to do anything if using Go 1.14 as the expectations will be checked
// and the test HTTP server will be closed automatically. If not using Go 1.14 then
// you should defer m.Close() after its creation
}
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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.