mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
Power user command support for directory scans (#467)
* Power-user directory source support Signed-off-by: Mikey Strauss <mikey@scribe-security.com> Signed-off-by: houdini91 <mdstrauss91@gmail.com> * Remove newline Signed-off-by: houdini91 <mdstrauss91@gmail.com> * Shared filetree (#1) * Shared directory resolver filetree Signed-off-by: houdini91 <mdstrauss91@gmail.com> * PR - change error ErrObserve to ErrPath Signed-off-by: houdini91 <mdstrauss91@gmail.com> * PR - share directory resolver * Use pointer to source struct Signed-off-by: houdini91 <mdstrauss91@gmail.com> * Fix Lint Signed-off-by: houdini91 <mdstrauss91@gmail.com>
This commit is contained in:
@@ -71,6 +71,29 @@ func TestPowerUserCmdFlags(t *testing.T) {
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "default-dir-results-w-pkg-coverage",
|
||||
args: []string{"power-user", "dir:test-fixtures/image-pkg-coverage"},
|
||||
assertions: []traitAssertion{
|
||||
assertNotInOutput(" command is deprecated"), // only the root command should be deprecated
|
||||
assertInOutput(`"type": "RegularFile"`), // proof of file-metadata data
|
||||
assertInOutput(`"algorithm": "sha256"`), // proof of file-metadata default digest algorithm of sha256
|
||||
assertInOutput(`"metadataType": "ApkMetadata"`), // proof of package artifacts data
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "defaut-secrets-dir-results-w-reveal-values",
|
||||
env: map[string]string{
|
||||
"SYFT_SECRETS_REVEAL_VALUES": "true",
|
||||
},
|
||||
args: []string{"power-user", "dir:test-fixtures/image-secrets"},
|
||||
assertions: []traitAssertion{
|
||||
assertInOutput(`"classification": "generic-api-key"`), // proof of the secrets cataloger finding something
|
||||
assertInOutput(`"12345A7a901b345678901234567890123456789012345678901234567890"`), // proof of the secrets cataloger finding the api key
|
||||
assertSuccessfulReturnCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/anchore/syft/syft/source"
|
||||
)
|
||||
|
||||
func catalogFixtureImage(t *testing.T, fixtureImageName string) (*pkg.Catalog, *distro.Distro, source.Source) {
|
||||
func catalogFixtureImage(t *testing.T, fixtureImageName string) (*pkg.Catalog, *distro.Distro, *source.Source) {
|
||||
imagetest.GetFixtureImage(t, "docker-archive", fixtureImageName)
|
||||
tarPath := imagetest.GetFixtureImageTarPath(t, fixtureImageName)
|
||||
|
||||
@@ -28,7 +28,7 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (*pkg.Catalog, *
|
||||
return pkgCatalog, actualDistro, theSource
|
||||
}
|
||||
|
||||
func catalogDirectory(t *testing.T, dir string) (*pkg.Catalog, *distro.Distro, source.Source) {
|
||||
func catalogDirectory(t *testing.T, dir string) (*pkg.Catalog, *distro.Distro, *source.Source) {
|
||||
theSource, cleanupSource, err := source.New("dir:"+dir, nil)
|
||||
t.Cleanup(cleanupSource)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user