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.
github.com/ido50/requests
high-level HTTP client for Go.
requests
is a high-level, API-centric HTTP client for Go projects. It is meant
to provide a more comfortable mechanism to perform requests to HTTP APIs (rather
than making general requests), and to prevent common mistakes made when using
net/http
directly.
With requests
, one must not need to remember to read HTTP responses in full (so
Go can reuse TCP connections), nor to close response bodies. Handling of JSON
data - be it in requests or responses - is made easier by way of built-in
encoders/decoders. An automatic retry mechanism is also included.
The library allows a "DRY" (Dont Repeat Yourself) approach to REST API usage by introducing API-specific dependencies into the client object. For example, authorization headers and response handlers can be set in the client object, and all generated requests will automatically include them.
go get -u github.com/ido50/requests
package main
import (
"fmt"
"net/http"
"time"
"github.com/ido50/requests"
)
const apiURL = "https://my.api.com/v2"
type RequestBody struct {
Title string `json:"title"`
Tags []string `json:"tags"`
Publish bool `json:"publish"`
}
type ResponseBody struct {
ID int64 `json:"id"`
Date time.Time `json:"date"`
}
func main() {
client := requests.
NewClient(apiURL).
Accept("application/json").
BasicAuth("user", "pass").
RetryLimit(3)
var res ResponseBody
err := client.
NewRequest("POST", "/articles").
JSONBody(RequestBody{
Title: "Test Title",
Tags: []string{"test", "stories"},
Publish: true,
}).
ExpectedStatus(http.StatusCreated).
Into(&res).
Run()
if err != nil {
panic(err)
}
fmt.Printf("Created article %d on %s\n", res.ID, res.Date.Format(time.RFC3339))
}
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.