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/TV4/logrus-stackdriver-formatter
logrus formatter for Stackdriver.
In addition to supporting level-based logging to Stackdriver, for Error, Fatal and Panic levels it will append error context for Error Reporting.
go get -u github.com/TV4/logrus-stackdriver-formatter
package main
import (
"github.com/sirupsen/logrus"
stackdriver "github.com/TV4/logrus-stackdriver-formatter"
)
var log = logrus.New()
func init() {
log.Formatter = stackdriver.NewFormatter(
stackdriver.WithService("your-service"),
stackdriver.WithVersion("v0.1.0"),
)
log.Level = logrus.DebugLevel
log.Info("ready to log!")
}
Here's a sample entry (prettified) from the example:
{
"serviceContext": {
"service": "test-service",
"version": "v0.1.0"
},
"message": "unable to parse integer: strconv.ParseInt: parsing \"text\": invalid syntax",
"severity": "ERROR",
"context": {
"reportLocation": {
"filePath": "github.com/TV4/logrus-stackdriver-formatter/example_test.go",
"lineNumber": 21,
"functionName": "ExampleLogError"
}
}
}
If you'd like to add additional context like the httpRequest
, here's a convenience function for creating a HTTP logger:
func httpLogger(logger *logrus.Logger, r *http.Request) *logrus.Entry {
return logger.WithFields(logrus.Fields{
"httpRequest": map[string]interface{}{
"method": r.Method,
"url": r.URL.String(),
"userAgent": r.Header.Get("User-Agent"),
"referrer": r.Header.Get("Referer"),
},
})
}
Then, in your HTTP handler, create a new context logger and all your log entries will have the HTTP request context appended to them:
func handler(w http.ResponseWriter, r *http.Request) {
httplog := httpLogger(log, r)
// ...
httplog.Infof("Logging with HTTP request context")
}
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.