cyberark / KubiScan

A tool to scan Kubernetes cluster for risky permissions
GNU General Public License v3.0
1.31k stars 130 forks source link

Added a Static Scan For KubiScan #78

Open regevnoam1 opened 2 weeks ago

regevnoam1 commented 2 weeks ago

Implemented Changes

Major Enhancements: Combined File Support: Added support for processing combined JSON/YAML files, enabling the tool to handle aggregated input files that consolidate various Kubernetes resource definitions.

Minor Fixes:

Command-Line Switch Improvements: Fixed the -rp -d switch functionality. CVE File Update: Updated the CVE file to prevent from the program to crash.

Usage Example

To utilize the new combined file support, run the following command: python3 ./KubiScan.py -f /path/to/file/KubiScan/filename.json -rr (or filename.yaml -rr)

Added Images in which format you should create the json or yaml file. image image (1)

regevnoam1 commented 2 weeks ago

Code Snippet template for creating the static file:

For JSON:

echo "[" > combined.json
kubectl get roles --all-namespaces -o json >> combined.json
echo "," >> combined.json
kubectl get rolebindings --all-namespaces -o json >> combined.json
echo "," >> combined.json
kubectl get clusterroles -o json >> combined.json
echo "," >> combined.json
kubectl get clusterrolebindings -o json >> combined.json
echo "," >> combined.json
kubectl get secrets --all-namespaces -o json >> combined.json
echo "," >> combined.json
kubectl get pods --all-namespaces -o json >> combined.json
echo "]" >> combined.json

For YAML:


echo "---" > combined.yaml
kubectl get roles --all-namespaces -o yaml>> combined.yaml
echo "---" >> combined.yaml
kubectl get rolebindings --all-namespaces -o yaml>> combined.yaml
echo "---" >> combined.yaml
kubectl get clusterroles -o yaml>> combined.yaml
echo "---" >> combined.yaml
kubectl get clusterrolebindings -o yaml>> combined.yaml
echo "---" >> combined.yaml
kubectl get secrets --all-namespaces -o yaml>> combined.yaml
echo "---" >> combined.yaml
kubectl get pods --all-namespaces -o yaml>> combined.yaml