What happened:
syft reads any config.yaml in the current working directory as Syft configuration. If the config.yaml is not a valid syft config, then scanning fails.
What you expected to happen:
I expect config.yaml in the current working directory to not be read as Syft configuration.
Steps to reproduce the issue:
- Create directory
foo: mkdir foo
- Create a
config.yaml in the foo directory: touch foo/config.yaml
- Place invalid Syft config in the
config.yaml:
cat > foo/config.yaml << EOF
output:
example:
value: value
EOF
Note that is is important that the config file uses a Syft configuration value like output
4. Run syft in the foo directory: cd foo && syft packages .
5. Observe the error 'output[0]' expected type 'string', got unconvertible type 'map[string]interface {}', value: 'map[example:map[value:value]]'
Anything else we need to know?:
The problem occurs on https://github.com/anchore/syft/blob/main/internal/config/application.go#L226.
On line 226 we add the pwd as a config path. We then check to see if a .syft config file exists. If it does not, we move to check the other documented config files.
On line 236 we add .syft as a config path. Note that pwd is still in the search path for configs. When we then search for config files with the name config, it picks up ./config.yaml which was never intended as a syft configuration file.
Environment:
- Output of
syft version: latest syft from git
- OS (e.g:
cat /etc/os-release or similar): Falure observed on Linux and Macos
What happened:
syftreads anyconfig.yamlin the current working directory as Syft configuration. If theconfig.yamlis not a validsyftconfig, then scanning fails.What you expected to happen:
I expect
config.yamlin the current working directory to not be read as Syft configuration.Steps to reproduce the issue:
foo:mkdir fooconfig.yamlin thefoodirectory:touch foo/config.yamlconfig.yaml:Note that is is important that the config file uses a Syft configuration value like
output4. Run syft in the
foodirectory:cd foo && syft packages .5. Observe the error
'output[0]' expected type 'string', got unconvertible type 'map[string]interface {}', value: 'map[example:map[value:value]]'Anything else we need to know?:
The problem occurs on https://github.com/anchore/syft/blob/main/internal/config/application.go#L226.
On line 226 we add the
pwdas a config path. We then check to see if a.syftconfig file exists. If it does not, we move to check the other documented config files.On line 236 we add
.syftas a config path. Note thatpwdis still in the search path for configs. When we then search for config files with the nameconfig, it picks up./config.yamlwhich was never intended as asyftconfiguration file.Environment:
syft version: latest syft fromgitcat /etc/os-releaseor similar): Falure observed on Linux and Macos