Skip to content

Commit

Permalink
fix: update config struct to not decode password/key (#1538)
Browse files Browse the repository at this point in the history
* fix: update config struct to not decode password/key
* test: update tests to confirm no secrets in output

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
---------

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
  • Loading branch information
spiffcs authored Feb 3, 2023
1 parent b6a496f commit 9995950
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/config/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package config
import "github.com/spf13/viper"

type attest struct {
Key string `yaml:"key" json:"key" mapstructure:"key"`
Password string `yaml:"password" json:"password" mapstructure:"password"`
// IMPORTANT: do not show the attestation key/password in any YAML/JSON output (sensitive information)
Key string `yaml:"-" json:"-" mapstructure:"key"`
Password string `yaml:"-" json:"-" mapstructure:"password"`
}

func (cfg attest) loadDefaultValues(v *viper.Viper) {
Expand Down
14 changes: 14 additions & 0 deletions test/cli/packages_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ func TestPackagesCmdFlags(t *testing.T) {
assertSuccessfulReturnCode,
},
},
{
name: "password and key not in config output",
args: []string{"packages", "-vvv", "-o", "json", coverageImage},
env: map[string]string{
"SYFT_ATTEST_PASSWORD": "secret_password",
"SYFT_ATTEST_KEY": "secret_key_path",
},
assertions: []traitAssertion{
assertNotInOutput("secret_password"),
assertNotInOutput("secret_key_path"),
assertPackageCount(34),
assertSuccessfulReturnCode,
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit 9995950

Please sign in to comment.