Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic if AddFlags does not have a pointer receiver #38

Open
kzantow opened this issue Jan 26, 2024 · 0 comments · May be fixed by #39
Open

Panic if AddFlags does not have a pointer receiver #38

kzantow opened this issue Jan 26, 2024 · 0 comments · May be fixed by #39

Comments

@kzantow
Copy link
Contributor

kzantow commented Jan 26, 2024

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) {
	...
}
@kzantow kzantow linked a pull request Jan 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant