anchore / fangs

Apache License 2.0
5 stars 1 forks source link

Panic if `AddFlags` does not have a pointer receiver #38

Open kzantow opened 7 months ago

kzantow commented 7 months ago

If a user defines an AddFlags method which does not have a pointer receiver, it will not properly bind the flag to the value on the object but rather an ephemeral memory location. It also is simply not being called at the moment. An example of this causing a problem in syft where the --key flag was not bound can be seen here. Realistically, this is always a coding problem that needs to be fixed and we should panic if we find AddFlags methods that were incorrectly specified so a user can more quickly get these fixed; i.e. panic if methods seen like this:

func (o Attest) AddFlags(flags fangs.FlagSet) {
    ...
}

... instead of this:

func (o *Attest) AddFlags(flags fangs.FlagSet) {
    ...
}