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.
github.com/aquasecurity/fanal
This project has been moved into github.com/aquasecurity/trivy - all packages or their equivalents can be found there instead
Static Analysis Library for Containers
See cmd/fanal/
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"golang.org/x/xerrors"
"github.com/aquasecurity/fanal/cache"
"github.com/aquasecurity/fanal/analyzer"
_ "github.com/aquasecurity/fanal/analyzer/library/bundler"
_ "github.com/aquasecurity/fanal/analyzer/library/composer"
_ "github.com/aquasecurity/fanal/analyzer/library/npm"
_ "github.com/aquasecurity/fanal/analyzer/library/pipenv"
_ "github.com/aquasecurity/fanal/analyzer/library/poetry"
_ "github.com/aquasecurity/fanal/analyzer/library/yarn"
_ "github.com/aquasecurity/fanal/analyzer/library/cargo"
_ "github.com/aquasecurity/fanal/analyzer/os/alpine"
_ "github.com/aquasecurity/fanal/analyzer/os/amazonlinux"
_ "github.com/aquasecurity/fanal/analyzer/os/debianbase"
_ "github.com/aquasecurity/fanal/analyzer/os/suse"
_ "github.com/aquasecurity/fanal/analyzer/os/redhatbase"
_ "github.com/aquasecurity/fanal/analyzer/pkg/apk"
_ "github.com/aquasecurity/fanal/analyzer/pkg/dpkg"
_ "github.com/aquasecurity/fanal/analyzer/pkg/rpm"
"github.com/aquasecurity/fanal/extractor"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() (err error) {
ctx := context.Background()
tarPath := flag.String("f", "-", "layer.tar path")
clearCache := flag.Bool("clear", false, "clear cache")
flag.Parse()
if *clearCache {
if err = cache.Clear(); err != nil {
return xerrors.Errorf("error in cache clear: %w", err)
}
}
args := flag.Args()
var files extractor.FileMap
if len(args) > 0 {
files, err = analyzer.Analyze(ctx, args[0])
if err != nil {
return err
}
} else {
rc, err := openStream(*tarPath)
if err != nil {
return err
}
files, err = analyzer.AnalyzeFromFile(ctx, rc)
if err != nil {
return err
}
}
os, err := analyzer.GetOS(files)
if err != nil {
return err
}
fmt.Printf("%+v\n", os)
pkgs, err := analyzer.GetPackages(files)
if err != nil {
return err
}
fmt.Printf("Packages: %d\n", len(pkgs))
libs, err := analyzer.GetLibraries(files)
if err != nil {
return err
}
for filepath, libList := range libs {
fmt.Printf("%s: %d\n", filepath, len(libList))
}
return nil
}
func openStream(path string) (*os.File, error) {
if path == "-" {
if terminal.IsTerminal(0) {
flag.Usage()
os.Exit(64)
} else {
return os.Stdin, nil
}
}
return os.Open(path)
}
When using latest
tag, that image will be cached. After latest
tag is updated, you need to clear cache.
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.