fangs panics while generating a configuration summary when it encounters a custom pflag.Value where the implementation is a pointer to a struct, but the underlying value backing the implementation is not a pointer.
This behavior was first noticed in this issue in zarf. zarf vendors syft under zarf tools sbom to make it readily available to zarf users when operating in an airgapped environment.
When running zarf tools sbom config, the vendored syft cobra command calls fangs.SummarizeCommand which ascends the cobra command graph to the root then walks all config for the entire cobra command tree. zarf also vendors yq which has a custom pflag.Value implementation: unwrapScalarFlagStrc. This custom implementation backs the value with a plain bool and not a pointer, but fangs universally derefs the value field of any pflag.Value-implementing pointer struct type, causing it to panic when attempting to deref the pointer for this scalar.
A clean fix would be for fangs to check if a value is a pointer before attempting to deref.
fangspanics while generating a configuration summary when it encounters a custompflag.Valuewhere the implementation is a pointer to a struct, but the underlying value backing the implementation is not a pointer.This behavior was first noticed in this issue in
zarf.zarfvendorssyftunderzarf tools sbomto make it readily available tozarfusers when operating in an airgapped environment.When running
zarf tools sbom config, the vendoredsyftcobra command callsfangs.SummarizeCommandwhich ascends the cobra command graph to the root then walks all config for the entire cobra command tree.zarfalso vendorsyqwhich has a custompflag.Valueimplementation:unwrapScalarFlagStrc. This custom implementation backs the value with a plain bool and not a pointer, butfangsuniversally derefs thevaluefield of anypflag.Value-implementing pointer struct type, causing it to panic when attempting to deref the pointer for this scalar.A clean fix would be for
fangsto check if avalueis a pointer before attempting to deref.