Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
go.krak3n.codes/gofig/parsers/yaml
This parser loads yaml
formatted configuration from an io.ReadCloser
.
Click the Playground badge above to see the example running in the Go Playground.
package main
import (
"fmt"
"io/ioutil"
"go.krak3n.codes/gofig"
"go.krak3n.codes/gofig/parsers/yaml"
)
// Config is a struct to unpack configuration into.
type Config struct {
Foo struct {
Bar struct {
Baz string `gofig:"baz"`
} `gofig:"bar"`
} `gofig:"foo"`
Fizz struct {
Buzz map[string]string `gofig:"buzz"`
} `gofig:"fizz"`
A struct {
B map[string][]int `gofig:"b"`
} `gofig:"a"`
C struct {
D map[string]map[string][]int `gofig:"d"`
} `gofig:"c"`
}
const blob string = `
foo:
bar:
baz: bar
fizz:
buzz:
hello: world
bill: ben`
func main() {
var cfg Config
// Initialise gofig with the struct config values will be placed into
gfg, err := gofig.New(&cfg)
gofig.Must(err)
// Create a parser
parser := yaml.New()
// write some data to a config file
path, err := create()
gofig.Must(err)
// Parse in order
gofig.Must(gfg.Parse(
gofig.FromFile(parser, path),
gofig.FromString(parser, blob)))
fmt.Println(fmt.Sprintf("%+v", cfg))
}
const contents = `
a:
b:
c: [1,2,3]
c:
d:
e:
f: [1,2,3]`
func create() (string, error) {
f, err := ioutil.TempFile("", "yaml")
if err != nil {
return "", err
}
if _, err := f.Write([]byte(contents)); err != nil {
return "", err
}
return f.Name(), nil
}
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.