From 0866a2763fcca87ca04c8b024b20c5dfb3ebe5ad Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Tue, 19 Feb 2019 12:58:04 +0000 Subject: [PATCH 1/3] Remove unnecessary event (presumably copy-pasted) --- src/modules/discovery/apiserver.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/modules/discovery/apiserver.py b/src/modules/discovery/apiserver.py index b3ec74c..02035c5 100644 --- a/src/modules/discovery/apiserver.py +++ b/src/modules/discovery/apiserver.py @@ -5,11 +5,6 @@ from ...core.types import Hunter from ...core.events import handler from ...core.events.types import OpenPortEvent, Service, Event -class ReadOnlyKubeletEvent(Service, Event): - """The read-only port on the kubelet serves health probing endpoints, and is relied upon by many kubernetes componenets""" - def __init__(self): - Service.__init__(self, name="Kubelet API (readonly)") - class ApiServer(Service, Event): """The API server is in charge of all operations on the cluster.""" From 765899ca4a850a17ac03b2dd0b597710093cd139 Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Tue, 19 Feb 2019 13:01:12 +0000 Subject: [PATCH 2/3] Need script to run test because of odd config import --- runtest.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 runtest.py diff --git a/runtest.py b/runtest.py new file mode 100644 index 0000000..d6fc3d8 --- /dev/null +++ b/runtest.py @@ -0,0 +1,23 @@ +import argparse +import pytest + +parser = argparse.ArgumentParser(description='Kube-Hunter tests') +parser.add_argument('--list', action="store_true", help="displays all tests in kubehunter (add --active flag to see active tests)") +parser.add_argument('--internal', action="store_true", help="set hunting of all internal network interfaces") +parser.add_argument('--pod', action="store_true", help="set hunter as an insider pod") +parser.add_argument('--quick', action="store_true", help="Prefer quick scan (subnet 24)") +parser.add_argument('--cidr', type=str, help="set an ip range to scan, example: 192.168.0.0/16") +parser.add_argument('--mapping', action="store_true", help="outputs only a mapping of the cluster's nodes") +parser.add_argument('--remote', nargs='+', metavar="HOST", default=list(), help="one or more remote ip/dns to hunt") +parser.add_argument('--active', action="store_true", help="enables active hunting") +parser.add_argument('--log', type=str, metavar="LOGLEVEL", default='INFO', help="set log level, options are: debug, info, warn, none") +parser.add_argument('--report', type=str, default='plain', help="set report type, options are: plain, yaml") + +config = parser.parse_args() + +def main(): + pytest.main(['.']) + + +if __name__ == '__main__': + main() \ No newline at end of file From 6dd87e12f86a9ce71336ec5bd83acaec09b0ff65 Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Tue, 19 Feb 2019 13:01:27 +0000 Subject: [PATCH 3/3] Add test runner to Travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 379701b..e1c8004 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,9 @@ before_script: - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - pip install pytest script: - - true # add other tests here + - python runtest.py notifications: on_success: change on_failure: change # `always` will be the setting once code changes slow down