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/lsegal/dinit
DInit is a library to initialize structs using Dependenci Injection (DI).
go get -u github.com/lsegal/dinit
Use dinit.Init(val1, val2, ...)
where arguments are either struct values,
references, bare functions, or initializer functions that return struct values.
DInit will then call your functions in the appropriate order to ensure that
all functions have their arguments filled by the values provided in the
Init()
call.
For example, in the code below we have a log.Logger
object, a client
and
service
. The service
depends on log.Logger,
and client
depends on
both service
and log.Logger
. When we call their initializers, only 1
instance of client and server are created:
func newClient(l *log.Logger, svc lister) *client { /* ... */ }
func newService(l *log.Logger) *service { /* ... */ }
func main() {
l := log.New(os.Stdout, "", log.Lshortfile)
useClient := func(c *client) { c.PrintPeople() }
dinit.Init(newClient, useClient, newService, l)
// Output:
// main.go:40: Initializing service
// main.go:35: Initializing client
// main.go:30: Client asked for a list of people
// main.go:18: People: Sarah, Bob, André
}
You can see the full (runnable) example in examples/client_server/main.go
.
Copyright (c) 2018 Loren Segal. All rights reserved.
This project is licensed under the MIT license, see LICENSE
for details.
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.