Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Removed automatic import of handler object #506

Merged
merged 2 commits into from
May 12, 2022

Conversation

danielsagi
Copy link
Contributor

@danielsagi danielsagi commented May 12, 2022

Description

fixes #505 .
fixed #502

Thanks for everyone for commenting about this critical one!
Right after the Arp and Dns spoofing hunters were moved to run as plugins #500 . A new feature for specifying thread count was merged #433 .
While both of those changes worked fine by themselves, together they introduced a new problem.
In order to control the thread count, a get_config had to be called in the handler.py module, right before instantiation.
Now, when initializing the plugins, an import from the package kube_hunter.core.events.types had to be called.

The problem arose when the package ..events did an import by itself from the handler.py module, thus initializing the handler before config was set.

After taking a deep look into this, I realised we don't need this automatic import, and were better off importing this manually by adding the .handler explicitly to each import.

Another issue arose after that, which I'm sure I don't need to explain to those who are familiar with python, it's a bad habit to call an imported object with the same name as it's father module.

Solution

  1. handler.py was renamed to event_handler.py
  2. removed automatic import of handler object from the events package
  3. All related imports was changed to match new module name

This should fix everything. and the upstream version would follow as 0.6.8

Contribution checklist

  • I have read the Contributing Guidelines.
  • The commits refer to an active issue in the repository.
  • I have added automated testing to cover this case.

…med handler.py to event_handler.py to solve name collision
@CLAassistant
Copy link

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.

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #506 (e6d1bb3) into main (9ce385a) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #506      +/-   ##
==========================================
- Coverage   65.32%   65.26%   -0.06%     
==========================================
  Files          44       44              
  Lines        2457     2456       -1     
==========================================
- Hits         1605     1603       -2     
- Misses        852      853       +1     
Impacted Files Coverage Δ
kube_hunter/core/events/__init__.py 100.00% <ø> (ø)
kube_hunter/core/events/event_handler.py 86.66% <ø> (ø)
kube_hunter/core/types/hunters.py 65.21% <100.00%> (ø)
kube_hunter/modules/discovery/apiserver.py 89.39% <100.00%> (ø)
kube_hunter/modules/discovery/dashboard.py 55.55% <100.00%> (ø)
kube_hunter/modules/discovery/etcd.py 75.00% <100.00%> (ø)
kube_hunter/modules/discovery/hosts.py 54.01% <100.00%> (ø)
kube_hunter/modules/discovery/kubectl.py 46.42% <100.00%> (ø)
kube_hunter/modules/discovery/kubelet.py 46.00% <100.00%> (ø)
kube_hunter/modules/discovery/ports.py 88.88% <100.00%> (ø)
... and 14 more

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 9ce385a...e6d1bb3. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants