rename Contents to FileContents in app config and documentation

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2021-04-09 08:56:01 -04:00
parent 44915b435f
commit 51b13f8221
No known key found for this signature in database
GPG key ID: 5CB45AE22BAB7EA7
6 changed files with 17 additions and 17 deletions

View file

@ -120,22 +120,22 @@ file-classification:
scope: "squashed"
# cataloging file contents is exposed through the power-user subcommand
contents:
file-contents:
cataloger:
# enable/disable cataloging of secrets
# SYFT_CONTENTS_CATALOGER_ENABLED env var
# SYFT_FILE_CONTENTS_CATALOGER_ENABLED env var
enabled: true
# the search space to look for secrets (options: all-layers, squashed)
# SYFT_CONTENTS_CATALOGER_SCOPE env var
# SYFT_FILE_CONTENTS_CATALOGER_SCOPE env var
scope: "squashed"
# skip searching a file entirely if it is above the given size (default = 1MB; unit = bytes)
# SYFT_CONTENTS_SKIP_FILES_ABOVE_SIZE env var
# SYFT_FILE_CONTENTS_SKIP_FILES_ABOVE_SIZE env var
skip-files-above-size: 1048576
# file globs for the cataloger to match on
# SYFT_CONTENTS_GLOBS env var
# SYFT_FILE_CONTENTS_GLOBS env var
globs: []
# cataloging file metadata is exposed through the power-user subcommand

View file

@ -188,11 +188,11 @@ func catalogFileClassificationsTask() (powerUserTask, error) {
}
func catalogContentsTask() (powerUserTask, error) {
if !appConfig.Contents.Cataloger.Enabled {
if !appConfig.FileContents.Cataloger.Enabled {
return nil, nil
}
contentsCataloger, err := file.NewContentsCataloger(appConfig.Contents.Globs, appConfig.Contents.SkipFilesAboveSize)
contentsCataloger, err := file.NewContentsCataloger(appConfig.FileContents.Globs, appConfig.FileContents.SkipFilesAboveSize)
if err != nil {
return nil, err
}

View file

@ -38,7 +38,7 @@ type Application struct {
Package packages `yaml:"package" json:"package" mapstructure:"package"`
FileMetadata FileMetadata `yaml:"file-metadata" json:"file-metadata" mapstructure:"file-metadata"`
FileClassification fileClassification `yaml:"file-classification" json:"file-classification" mapstructure:"file-classification"`
Contents contents `yaml:"contents" json:"contents" mapstructure:"contents"`
FileContents fileContents `yaml:"file-contents" json:"file-contents" mapstructure:"file-contents"`
Secrets secrets `yaml:"secrets" json:"secrets" mapstructure:"secrets"`
}

View file

@ -6,19 +6,19 @@ import (
"github.com/spf13/viper"
)
type contents struct {
type fileContents struct {
Cataloger catalogerOptions `yaml:"cataloger" json:"cataloger" mapstructure:"cataloger"`
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"`
}
func (cfg contents) loadDefaultValues(v *viper.Viper) {
v.SetDefault("contents.cataloger.enabled", true)
v.SetDefault("contents.cataloger.scope", source.SquashedScope)
v.SetDefault("contents.skip-files-above-size", 1*file.MB)
v.SetDefault("contents.globs", []string{})
func (cfg fileContents) loadDefaultValues(v *viper.Viper) {
v.SetDefault("file-contents.cataloger.enabled", true)
v.SetDefault("file-contents.cataloger.scope", source.SquashedScope)
v.SetDefault("file-contents.skip-files-above-size", 1*file.MB)
v.SetDefault("file-contents.globs", []string{})
}
func (cfg *contents) parseConfigValues() error {
func (cfg *fileContents) parseConfigValues() error {
return cfg.Cataloger.parseConfigValues()
}

View file

@ -206,7 +206,7 @@
"scope": ""
}
},
"contents": {
"file-contents": {
"cataloger": {
"enabled": false,
"scope": ""

View file

@ -55,7 +55,7 @@ func TestPowerUserCmdFlags(t *testing.T) {
name: "content-cataloger-wired-up",
args: []string{"power-user", "docker-archive:" + getFixtureImage(t, "image-secrets")},
env: map[string]string{
"SYFT_CONTENTS_GLOBS": "/api-key.txt",
"SYFT_FILE_CONTENTS_GLOBS": "/api-key.txt",
},
assertions: []traitAssertion{
assertInOutput(`"contents": "c29tZV9BcEkta0V5ID0gIjEyMzQ1QTdhOTAxYjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MCIK"`), // proof of the content cataloger