aquasecurity / kube-hunter

Hunt for security weaknesses in Kubernetes clusters
Apache License 2.0
4.7k stars 581 forks source link

Added External Plugins Support #357

Closed danielsagi closed 4 years ago

danielsagi commented 4 years ago

Description

Officially added support for plugins to be loaded. By using Pluggy

The hook specifications are centered at: kube_hunter/plugins/hookspecs.py

In order to implement your plugin, use the hookimpl decorator from kube_hunter.plugins and implement one of the following:

To load your plugin module you should install your package like this:

from setuptools import setup

setup(
    name="kube-hunter-mypackage",
    install_requires="kube-hunter",
    entry_points={"kube_hunter": ["mypackage = my_module"]},
    py_modules=["my_module"],
)

Current functionality was not impacted.

Main changes in the code:

Contribution Guidelines

Please Read through the Contribution Guidelines.

Fixed Issues

closes #321

"BEFORE" and "AFTER" output

BEFORE

AFTER

Contribution checklist

Notes

codecov[bot] commented 4 years ago

Codecov Report

Merging #357 into master will increase coverage by 1.10%. The diff coverage is 91.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #357      +/-   ##
==========================================
+ Coverage   58.11%   59.22%   +1.10%     
==========================================
  Files          40       42       +2     
  Lines        2039     2060      +21     
==========================================
+ Hits         1185     1220      +35     
+ Misses        854      840      -14     
Impacted Files Coverage Δ
kube_hunter/conf/parser.py 76.00% <66.66%> (+76.00%) :arrow_up:
kube_hunter/plugins/__init__.py 100.00% <100.00%> (ø)
kube_hunter/plugins/hookspecs.py 100.00% <100.00%> (ø)
kube_hunter/core/events/handler.py 90.09% <0.00%> (-1.00%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 78e1672...b6b3dbc. Read the comment docs.