Active hunters cannot be registered in tests since it requires config.active to be set.
This cannot be done since import kube_hunter causes a default configuration to be loaded.
In order to make things right, we need to get rid of this side-effect behavior and instantiate the handler object with configuration as argument (i.e., dependency injection).
We also need to get rid of referencing config as global variable but rather pass it as argument to hunters and other consumers.
We may use dependency-injector for this mission.
Why is this needed
It is needed to make code more testable and using best practices.
What would you like to be added
Active hunters cannot be registered in tests since it requires
config.active
to be set. This cannot be done since importkube_hunter
causes a default configuration to be loaded. In order to make things right, we need to get rid of this side-effect behavior and instantiate thehandler
object with configuration as argument (i.e., dependency injection). We also need to get rid of referencingconfig
as global variable but rather pass it as argument to hunters and other consumers. We may usedependency-injector
for this mission.Why is this needed
It is needed to make code more testable and using best practices.