aquasecurity / kube-hunter

Hunt for security weaknesses in Kubernetes clusters
Apache License 2.0
4.66k stars 579 forks source link

Multiple Subscriptions Mechanism #448

Closed danielsagi closed 3 years ago

danielsagi commented 3 years ago

Multiple Subscriptions

A continuation for this old PR #271 When an hunter needs several prerequisites to exist in the cluster, We need to register for multiple events. This new mechanism allows us to execute once for every new combination of specified required events. For example: let a C hunter be registered to event A and B

  1. event A was published 3 times
  2. event B was published once.
  3. event B was published again

The hunter will execute 2 times:

This allows us to run specific hunters multiple times with updated data, only when a minimum set of different events are published.

Practical Changes

This PR Adds:

Example can be seen in added Tests

Fixed Issues

144

Contribution checklist

codecov[bot] commented 3 years ago

Codecov Report

Merging #448 (dd61318) into main (1a26653) will increase coverage by 0.36%. The diff coverage is 90.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #448      +/-   ##
==========================================
+ Coverage   63.67%   64.04%   +0.36%     
==========================================
  Files          42       42              
  Lines        2296     2350      +54     
==========================================
+ Hits         1462     1505      +43     
- Misses        834      845      +11     
Impacted Files Coverage Δ
kube_hunter/core/events/handler.py 90.54% <89.33%> (-0.55%) :arrow_down:
kube_hunter/core/events/types.py 83.60% <100.00%> (+0.99%) :arrow_up:
kube_hunter/modules/hunting/apiserver.py 70.41% <0.00%> (-1.93%) :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 1a26653...dd61318. Read the comment docs.