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

vmmetadataexporter panics if CLI args not given #165

Open
ericwb opened this issue Feb 7, 2025 · 0 comments · May be fixed by #166
Open

vmmetadataexporter panics if CLI args not given #165

ericwb opened this issue Feb 7, 2025 · 0 comments · May be fixed by #166

Comments

@ericwb
Copy link
Contributor

ericwb commented Feb 7, 2025

See the following. I ran vmmetadataexporter without host, username, password

ericwb@ubuntu-24:~/workspace/vjailbreak/vm_metadata_export$ ./vmmetadataexporter 
panic: runtime error: slice bounds out of range [:4] with length 0

goroutine 1 [running]:
main.validateVCenter({0x0?, 0xc000096040?}, {0x0?, 0x0?}, {0x0?, 0xb95141?}, 0xc?)
	/home/ericwb/workspace/vjailbreak/vm_metadata_export/main.go:31 +0x1f2
main.main()
	/home/ericwb/workspace/vjailbreak/vm_metadata_export/main.go:105 +0x17d

The code sets a default value for host, username, password of "". However, the code then proceeds to do a slice assuming the host contains "https", causing the panic.

If host is required, I recommend showing the usage if not given. Or prompting the user for the information when not given.

ericwb added a commit to ericwb/vjailbreak that referenced this issue Feb 7, 2025
This change does more validation of the CLI args given to
vmmetadataexporter to avoid panics. If host isn't given, it
errors and exits. If username or password isn't given, it
prompts the user to input them.

This handles a variety of scenarios around giving or not giving
these three arguments. It is also a better solution around
handling a password, since a CLI password arg gets leaked to
the shell history and potentially other logs.

Fixes platform9#165

Signed-off-by: Eric Brown <[email protected]>
@ericwb ericwb linked a pull request Feb 7, 2025 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