internal

package
v0.66.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package internal contains miscellaneous functions and objects useful within syft but should not be used externally.

Index

Constants

View Source
const (
	// ApplicationName is the non-capitalized name of the application (do not change this)
	ApplicationName = "syft"

	// JSONSchemaVersion is the current schema version output by the JSON encoder
	// This is roughly following the "SchemaVer" guidelines for versioning the JSON schema. Please see schema/json/README.md for details on how to increment.
	JSONSchemaVersion = "6.1.0"
)

Variables

View Source
var (
	ArchiveMIMETypeSet = strset.New(

		[]string{

			"application/x-archive",
			"application/x-cpio",
			"application/x-shar",
			"application/x-iso9660-image",
			"application/x-sbx",
			"application/x-tar",

			"application/x-bzip2",
			"application/gzip",
			"application/x-lzip",
			"application/x-lzma",
			"application/x-lzop",
			"application/x-snappy-framed",
			"application/x-xz",
			"application/x-compress",
			"application/zstd",

			"application/x-7z-compressed",
			"application/x-ace-compressed",
			"application/x-astrotite-afa",
			"application/x-alz-compressed",
			"application/vnd.android.package-archive",
			"application/x-freearc",
			"application/x-arj",
			"application/x-b1",
			"application/vnd.ms-cab-compressed",
			"application/x-cfs-compressed",
			"application/x-dar",
			"application/x-dgc-compressed",
			"application/x-apple-diskimage",
			"application/x-gca-compressed",
			"application/java-archive",
			"application/x-lzh",
			"application/x-lzx",
			"application/x-rar-compressed",
			"application/x-stuffit",
			"application/x-stuffitx",
			"application/x-gtar",
			"application/x-ms-wim",
			"application/x-xar",
			"application/zip",
			"application/x-zoo",
		}...,
	)

	ExecutableMIMETypeSet = strset.New(
		[]string{
			"application/x-executable",
			"application/x-mach-binary",
			"application/x-elf",
			"application/x-sharedlib",
			"application/vnd.microsoft.portable-executable",
			"application/x-executable",
		}...,
	)
)

Functions

func CloseAndLogError added in v0.15.2

func CloseAndLogError(closer io.Closer, location string)

CloseAndLogError closes the given io.Closer and reports any errors found as a warning in the log

func HasAnyOfPrefixes added in v0.15.0

func HasAnyOfPrefixes(input string, prefixes ...string) bool

HasAnyOfPrefixes returns an indication if the given string has any of the given prefixes.

func IsArchive added in v0.31.0

func IsArchive(mimeType string) bool

func IsErrPath added in v0.23.0

func IsErrPath(err error) bool

func IsErrPathPermission added in v0.23.0

func IsErrPathPermission(err error) bool

func IsExecutable added in v0.31.0

func IsExecutable(mimeType string) bool

func IsPipedInput added in v0.27.0

func IsPipedInput() (bool, error)

IsPipedInput returns true if there is no input device, which means the user **may** be providing input via a pipe.

func IsTerminal added in v0.39.0

func IsTerminal() bool

IsTerminal returns true if there is a terminal present.

func MatchNamedCaptureGroups added in v0.15.0

func MatchNamedCaptureGroups(regEx *regexp.Regexp, content string) map[string]string

MatchNamedCaptureGroups takes a regular expression and string and returns all of the named capture group results in a map. This is only for the first match in the regex. Callers shouldn't be providing regexes with multiple capture groups with the same name.

func StringInSlice added in v0.60.0

func StringInSlice(a string, list []string) bool

func Tprintf

func Tprintf(tmpl string, data map[string]interface{}) string

Tprintf renders a string from a given template string and field values

func TruncateMiddleEllipsis added in v0.19.0

func TruncateMiddleEllipsis(input string, maxLen int) string

Types

type ErrPath added in v0.23.0

type ErrPath struct {
	Context string
	Path    string
	Err     error
}

func (ErrPath) Error added in v0.23.0

func (e ErrPath) Error() string

type StringSet

type StringSet map[string]struct{}

StringSet represents a set of string types.

func NewStringSet

func NewStringSet(start ...string) StringSet

NewStringSet creates a new empty StringSet.

func (StringSet) Add

func (s StringSet) Add(i string)

Add a string to the set.

func (StringSet) Contains

func (s StringSet) Contains(i string) bool

Contains indicates if the given string is contained within the set.

func (StringSet) Remove

func (s StringSet) Remove(i string)

Remove a string from the set.

func (StringSet) ToSlice

func (s StringSet) ToSlice() []string

ToSlice returns a sorted slice of strings that are contained within the set.

Directories

Path Synopsis
Package bus provides access to a singleton instance of an event bus (provided by the calling application).
Package bus provides access to a singleton instance of an event bus (provided by the calling application).
Package log contains the singleton object and helper functions for facilitating logging within the syft library.
Package log contains the singleton object and helper functions for facilitating logging within the syft library.
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
ui
Package version contains all build time metadata (version, build time, git commit, etc).
Package version contains all build time metadata (version, build time, git commit, etc).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL