From 51b13f8221da35097e91bd1c20e4aea0dd087daa Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 9 Apr 2021 08:56:01 -0400 Subject: [PATCH] rename Contents to FileContents in app config and documentation Signed-off-by: Alex Goodman --- README.md | 10 +++++----- cmd/power_user_tasks.go | 4 ++-- internal/config/application.go | 2 +- internal/config/{contents.go => file_contents.go} | 14 +++++++------- .../snapshot/TestJSONPresenter.golden | 2 +- test/cli/power_user_cmd_test.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) rename internal/config/{contents.go => file_contents.go} (57%) diff --git a/README.md b/README.md index 5401f13f7..af0d17357 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/power_user_tasks.go b/cmd/power_user_tasks.go index da7cc97ea..37b0ba896 100644 --- a/cmd/power_user_tasks.go +++ b/cmd/power_user_tasks.go @@ -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 } diff --git a/internal/config/application.go b/internal/config/application.go index c78b21abf..9e0d58b0b 100644 --- a/internal/config/application.go +++ b/internal/config/application.go @@ -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"` } diff --git a/internal/config/contents.go b/internal/config/file_contents.go similarity index 57% rename from internal/config/contents.go rename to internal/config/file_contents.go index 5c660013c..3b3eb4ca9 100644 --- a/internal/config/contents.go +++ b/internal/config/file_contents.go @@ -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() } diff --git a/internal/presenter/poweruser/test-fixtures/snapshot/TestJSONPresenter.golden b/internal/presenter/poweruser/test-fixtures/snapshot/TestJSONPresenter.golden index 76c0d521f..0e92c7967 100644 --- a/internal/presenter/poweruser/test-fixtures/snapshot/TestJSONPresenter.golden +++ b/internal/presenter/poweruser/test-fixtures/snapshot/TestJSONPresenter.golden @@ -206,7 +206,7 @@ "scope": "" } }, - "contents": { + "file-contents": { "cataloger": { "enabled": false, "scope": "" diff --git a/test/cli/power_user_cmd_test.go b/test/cli/power_user_cmd_test.go index fb7c8cf48..2f7dcbbe9 100644 --- a/test/cli/power_user_cmd_test.go +++ b/test/cli/power_user_cmd_test.go @@ -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