mirror of
https://github.com/anchore/syft.git
synced 2025-11-20 18:03:16 +01:00
* add detection of ELF security features Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix linting Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update json schema with file executable data Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * update expected fixure when no tty present Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * more detailed differ Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * use json differ Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * remove json schema addition Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * regenerate json schema Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix mimtype set ref Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package options
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
|
|
"github.com/scylladb/go-set/strset"
|
|
|
|
intFile "github.com/anchore/syft/internal/file"
|
|
"github.com/anchore/syft/syft/file"
|
|
)
|
|
|
|
type fileConfig struct {
|
|
Metadata fileMetadata `yaml:"metadata" json:"metadata" mapstructure:"metadata"`
|
|
Content fileContent `yaml:"content" json:"content" mapstructure:"content"`
|
|
Executable fileExecutable `yaml:"executable" json:"executable" mapstructure:"executable"`
|
|
}
|
|
|
|
type fileMetadata struct {
|
|
Selection file.Selection `yaml:"selection" json:"selection" mapstructure:"selection"`
|
|
Digests []string `yaml:"digests" json:"digests" mapstructure:"digests"`
|
|
}
|
|
|
|
type fileContent struct {
|
|
SkipFilesAboveSize int64 `yaml:"skip-files-above-size" json:"skip-files-above-size" mapstructure:"skip-files-above-size"`
|
|
Globs []string `yaml:"globs" json:"globs" mapstructure:"globs"`
|
|
}
|
|
|
|
type fileExecutable struct {
|
|
Globs []string `yaml:"globs" json:"globs" mapstructure:"globs"`
|
|
}
|
|
|
|
func defaultFileConfig() fileConfig {
|
|
return fileConfig{
|
|
Metadata: fileMetadata{
|
|
Selection: file.FilesOwnedByPackageSelection,
|
|
Digests: []string{"sha1", "sha256"},
|
|
},
|
|
Content: fileContent{
|
|
SkipFilesAboveSize: 250 * intFile.KB,
|
|
},
|
|
Executable: fileExecutable{
|
|
Globs: nil,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (c *fileConfig) PostLoad() error {
|
|
digests := strset.New(c.Metadata.Digests...).List()
|
|
sort.Strings(digests)
|
|
c.Metadata.Digests = digests
|
|
|
|
switch c.Metadata.Selection {
|
|
case file.NoFilesSelection, file.FilesOwnedByPackageSelection, file.AllFilesSelection:
|
|
return nil
|
|
}
|
|
return fmt.Errorf("invalid file metadata selection: %q", c.Metadata.Selection)
|
|
}
|