All Projects → aquasecurity → Fanal

aquasecurity / Fanal

Licence: apache-2.0
Static Analysis Library for Containers

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Fanal

Nyxo App
The repository for Nyxo React Native app, a personal sleep tracker and sleep coach
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Discordircd
A node.js script that allows you to connect to discord with your irc client.
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Tardis
TARDIS - Temperature And Radiative Diffusion In Supernovae
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Request Action
A GitHub Action to send arbitrary requests to GitHub's REST API
Stars: ✭ 110 (-2.65%)
Mutual labels:  hacktoberfest
Hello World
Add any Program in any language you like or add a hello world Program ❣️ if you like give us ⭐
Stars: ✭ 1,464 (+1195.58%)
Mutual labels:  hacktoberfest
Abaplint
Standalone linter for ABAP
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Panoramagl
PanoramaGL Android
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Prospect Mail
Prospect is an Outlook mail desktop client powered by Electron
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Hermes
Client-side messaging channel for sending data from one browser tab to another
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Git Client Plugin
Jenkins git client plugin
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
React Forms
React library for rendering forms.
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Elgg
A social networking engine in PHP/MySQL
Stars: ✭ 1,510 (+1236.28%)
Mutual labels:  hacktoberfest
Zpm
ZPM — Zsh Plugin Manager
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Default
The home of the default HACS repositories.
Stars: ✭ 110 (-2.65%)
Mutual labels:  hacktoberfest
Nextjs Headless Wordpress
🔥 Nextjs Headless WordPress
Stars: ✭ 110 (-2.65%)
Mutual labels:  hacktoberfest
Make Pull Request
Use this as learning repo on how to create successful pull requests. Very basic tasks on Python, HTML, CSS, JavaScript, JAVA.
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Lab Workshops
Materials for workshops on text mining, machine learning, and data visualization
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Js Vault
List of tricky Javascript interview questions
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest
Svelte Firebase
A template to help you start developing SPAs with Svelte and Firebase.
Stars: ✭ 111 (-1.77%)
Mutual labels:  hacktoberfest
Inkscape Applytransforms
An Inkscape extension which removes all matrix transforms by applying them recursively to shapes
Stars: ✭ 112 (-0.88%)
Mutual labels:  hacktoberfest

fanal

Static Analysis Library for Containers

GoDoc Test Go Report Card License: Apache-2.0

Feature

  • Detect OS
  • Extract OS packages
  • Extract libraries used by an application
    • Bundler, Composer, npm, Yarn, Pipenv, Poetry, Cargo

Example

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)
}

Notes

When using latest tag, that image will be cached. After latest tag is updated, you need to clear cache.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].