aquasecurity / kube-hunter

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

Fix broken logging #309

Closed iyehuda closed 4 years ago

iyehuda commented 4 years ago

Description

Remove unnecessary imports from kube_hunter/__init__.py that cause hook registration before main file execution. This made the event loop handler indirectly configure the root logger, which in turn prevented the main file configuring it with user parameters.

I opened #308 for further work in this subject.

Contribution Guidelines

Please Read through the Contribution Guidelines.

Fixed Issues

Fixes #292

"BEFORE" and "AFTER" output

To verify that the change works as desired, please include an output of terminal before and after the changes under headings "BEFORE" and "AFTER".

BEFORE

Running kube-hunter would not print log messages, no matter what --log parameter is set.

AFTER

Running kube-hunter sets log level to --log parameter.

Contribution checklist

Notes

Tested it manually. Integration tests need to be created to automatically test it.

lizrice commented 4 years ago

Codecov Report

Merging #309 into master will decrease coverage by 0.04%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
- Coverage   59.80%   59.76%   -0.05%     
==========================================
  Files          39       38       -1     
  Lines        1928     1926       -2     
==========================================
- Hits         1153     1151       -2     
  Misses        775      775              

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 e75c0ff...cc64141. Read the comment docs.

iyehuda commented 4 years ago

Codecov Report

Merging #309 into master will decrease coverage by 0.04%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
- Coverage   59.80%   59.76%   -0.05%     
==========================================
  Files          39       38       -1     
  Lines        1928     1926       -2     
==========================================
- Hits         1153     1151       -2     
  Misses        775      775              

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 e75c0ff...cc64141. Read the comment docs.

@lizrice it looks like the codecov/project check failed because two LOC were removed...

codecov-io commented 4 years ago

Codecov Report

Merging #309 into master will increase coverage by 0.84%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
+ Coverage   59.80%   60.64%   +0.84%     
==========================================
  Files          39       38       -1     
  Lines        1928     1926       -2     
==========================================
+ Hits         1153     1168      +15     
+ Misses        775      758      -17     
Impacted Files Coverage Δ
kube_hunter/modules/hunting/apiserver.py 71.61% <0.00%> (+1.98%) :arrow_up:
kube_hunter/modules/discovery/ports.py 88.46% <0.00%> (+11.53%) :arrow_up:
kube_hunter/core/types.py 100.00% <0.00%> (+18.60%) :arrow_up:

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 e75c0ff...67dcb3d. Read the comment docs.

iyehuda commented 4 years ago

Added some tests to improve coverage

iyehuda commented 4 years ago

Closing in favor of #310