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

View File

@ -188,11 +188,11 @@ func catalogFileClassificationsTask() (powerUserTask, error) {
} }
func catalogContentsTask() (powerUserTask, error) { func catalogContentsTask() (powerUserTask, error) {
if !appConfig.Contents.Cataloger.Enabled { if !appConfig.FileContents.Cataloger.Enabled {
return nil, nil 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 { if err != nil {
return nil, err return nil, err
} }

View File

@ -38,7 +38,7 @@ type Application struct {
Package packages `yaml:"package" json:"package" mapstructure:"package"` Package packages `yaml:"package" json:"package" mapstructure:"package"`
FileMetadata FileMetadata `yaml:"file-metadata" json:"file-metadata" mapstructure:"file-metadata"` FileMetadata FileMetadata `yaml:"file-metadata" json:"file-metadata" mapstructure:"file-metadata"`
FileClassification fileClassification `yaml:"file-classification" json:"file-classification" mapstructure:"file-classification"` 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"` Secrets secrets `yaml:"secrets" json:"secrets" mapstructure:"secrets"`
} }

View File

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

View File

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

View File

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