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/boreq/guinea
Guinea is a command line interface library.
Programs very often organise the user interface in the form of subcommands. As
an example the go
command lets the user invoke multiple subcommands such as
go build
or go get
. This library lets you nest any numbers of subcommands
(which can be thought of as separate programs) in each other easily building
complex user interfaces.
This program implements a root command which displays the program version and two subcommands.
package main
import (
"fmt"
"github.com/boreq/guinea"
"os"
)
var rootCommand = guinea.Command{
Options: []guinea.Option{
guinea.Option{
Name: "version",
Type: guinea.Bool,
Description: "Display version",
},
},
Run: func(c guinea.Context) error {
if c.Options["version"].Bool() {
fmt.Println("v0.0.0-dev")
return nil
}
return guinea.ErrInvalidParms
},
Subcommands: map[string]*guinea.Command{
"display_text": &commandDisplayText,
"greet": &commandGreet,
},
ShortDescription: "an example program using the guinea library",
Description: `This program demonstrates the use of a CLI library.`,
}
var commandDisplayText = guinea.Command{
Run: func(c guinea.Context) error {
fmt.Println("Hello world!")
return nil
},
ShortDescription: "displays text on the screen",
Description: `This is a subcommand that displays "Hello world!" on the screen.`,
}
var commandGreet = guinea.Command{
Arguments: []guinea.Argument{
guinea.Argument{
Name: "person",
Multiple: false,
Description: "a person to greet",
},
},
Options: []guinea.Option{
guinea.Option{
Name: "times",
Type: guinea.Int,
Description: "Number of greetings",
Default: 1,
},
},
Run: func(c guinea.Context) error {
for i := 0; i < c.Options["times"].Int(); i++ {
fmt.Printf("Hello %s!\n", c.Arguments[0])
}
return nil
},
ShortDescription: "greets the specified person",
Description: `This is a subcommand that greets the specified person.`,
}
func main() {
if err := guinea.Run(&rootCommand); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
And here are the example invocations of the program:
$ ./main --help
$ ./main --version
$ ./main display_text
$ ./main hello --help
$ ./main hello boreq
$ ./main hello --times 10 boreq
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.