aquasecurity / kube-hunter

Hunt for security weaknesses in Kubernetes clusters
Apache License 2.0
4.65k stars 578 forks source link

fix:kubectl discovery #543

Open sgaist opened 8 months ago

sgaist commented 8 months ago

Description

Please include a summary of the change and which issue is fixed. Also include relevant motivation and context. List any dependencies that are required for this change.

The kubectl discovery is not functional as the whole command is passed as a single string and thus cannot work with subprocess.check_output. This merge request fixes that and simplifies the version parsing as well.

Contribution Guidelines

Please Read through the Contribution Guidelines.

Fixed Issues

Please mention any issues fixed in the PR by referencing it properly in the commit message. As per the convention, use appropriate keywords such as fixes, closes, resolves to automatically refer the issue. Please consult official github documentation for details.

Fixes #534

"BEFORE" and "AFTER" output

To verify that the change works as desired, please include an output of terminal before and after the changes under headings "BEFORE" and "AFTER".

BEFORE

Any Terminal Output Before Changes. 2023-10-14 17:15:45,325 DEBUG kube_hunter.modules.discovery.kubectl Could not find kubectl client

AFTER

2023-10-14 17:35:55,474 DEBUG kube_hunter.modules.discovery.kubectl Found kubectl client: v1.28.2

Contribution checklist

Notes

Please mention if you have not checked any of the above boxes.

kubectl is required for the test to pass

CLAassistant commented 8 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.