discovery: Make kubectl.py able to find kubectl #511
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I was trying to get kube-hunter to display something about the remote k3s cluster with only port 6443 accessible.
While doing so I saw in the debug log output that it couldn't find kubectl, even though it's in $PATH
Doing so I eventually made conclusion that the arguments in subprocess check_output function in python 3.8.10 needs to be a
list. I do not know if this has changed in python. There might be better ways to change this. At least this change makes the code find the kubectl version.
Contribution Guidelines
Please Read through the Contribution Guidelines.
Fixed Issues
Fixes #512
"BEFORE" and "AFTER" output
BEFORE
Before the change the error in "--log debug" would look like:
AFTER
And if I add small code change to also print the exception error it
prints:
Contribution checklist
Notes
Haven't added any testing as I'm completely unfamiliar with Mock. Suggestion for what to test would be much appreciated!