
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
git.luolix.top/danielb42/whiteflag
A sane flag-package for gophers who just need some CLI flags in Golang projects, not command-structuring frameworks for space ships. If you waved a white flag on the usual whoppers, whiteflag
is here to assist.
FlagPresent()
to check for specified flags, and GetBool|Int|String()
to access their values (these functions can be utilized directly without further setup of each flag)-h/--help
prints basic generated Usage/Help text (see examples)Please have a look at the comprehensive example source file.
The following snippet would print "gopher" when called with -p gopher
.
package main
import wf "github.com/danielb42/whiteflag"
func main() {
if wf.FlagPresent("p") {
println(wf.GetString("p"))
}
}
The next snippet will print the sum of two integers given through -x
and -y
. For y
we specify a default value. Let's also associate long flags to the short flags so we could equivalently run the snippet with --first
and --second
. Aliasing flags makes them known to the Usage/Help text generation.
package main
import wf "github.com/danielb42/whiteflag"
func main() {
wf.Alias("x", "first", "The first number.")
wf.Alias("y", "second", "The second number.")
wf.SetIntDefault("y", 42)
// we don't do a FlagPresent() check on x und y before Get'ting them so
// the program will exit if x is not specified, thus making x 'required'.
// For a missing y flag, the default value of 42 would be used.
x := wf.GetInt("x")
y := wf.GetInt("y")
sum := x + y
println("sum of x and y:", sum)
}
For the snippet above the following Usage/Help text would be available through -h/--help
:
Usage: ./example <flags>
Flags:
-x --first The first number.
-y --second The second number.
MIT
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 researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.