forked from p15670423/monkey
Merge pull request #1166 from guardicore/small_bb_improvements
Small bb improvements
This commit is contained in:
commit
ce6b658a15
|
@ -1,20 +1,22 @@
|
||||||
# Automatic blackbox tests
|
# Automatic blackbox tests
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
1. Download google sdk: https://cloud.google.com/sdk/docs/
|
1. Download google sdk: https://cloud.google.com/sdk/docs/
|
||||||
2. Download service account key for MonkeyZoo project (if you deployed MonkeyZoo via terraform scripts then you already have it).
|
2. Download service account key for MonkeyZoo project (if you deployed MonkeyZoo via terraform scripts then you already have it).
|
||||||
GCP console -> IAM -> service accounts(you can use the same key used to authenticate terraform scripts).
|
GCP console -> IAM -> service accounts(you can use the same key used to authenticate terraform scripts).
|
||||||
Place the key in `envs/monkey_zoo/gcp_keys/gcp_key.json`.
|
Place the key in `envs/monkey_zoo/gcp_keys/gcp_key.json`.
|
||||||
3. Deploy the relevant branch + complied executables to the Island machine on GCP.
|
3. Deploy the relevant branch + complied executables to the Island machine on GCP.
|
||||||
|
|
||||||
### Running the tests
|
### Running the tests
|
||||||
In order to execute the entire test suite, you must know the external IP of the Island machine on GCP. You can find
|
In order to execute the entire test suite, you must know the external IP of the Island machine on GCP. You can find
|
||||||
this information in the GCP Console `Compute Engine/VM Instances` under _External IP_.
|
this information in the GCP Console `Compute Engine/VM Instances` under _External IP_.
|
||||||
|
|
||||||
#### Running in command line
|
#### Running in command line
|
||||||
|
Either run pytest from `/monkey` directory or set `PYTHONPATH` environment variable to
|
||||||
|
`/monkey` directory so that blackbox tests can import other monkey code.
|
||||||
Blackbox tests have following parameters:
|
Blackbox tests have following parameters:
|
||||||
- `--island=IP` Sets island's IP
|
- `--island=IP` Sets island's IP
|
||||||
- `--no-gcp` (Optional) Use for no interaction with the cloud (local test).
|
- `--no-gcp` (Optional) Use for no interaction with the cloud (local test).
|
||||||
- `--quick-performance-tests` (Optional) If enabled performance tests won't reset island and won't send telemetries,
|
- `--quick-performance-tests` (Optional) If enabled performance tests won't reset island and won't send telemetries,
|
||||||
instead will just test performance of endpoints in already present island state.
|
instead will just test performance of endpoints in already present island state.
|
||||||
|
|
||||||
Example run command:
|
Example run command:
|
||||||
|
@ -27,22 +29,22 @@ directory `monkey\envs\monkey_zoo\blackbox`.
|
||||||
|
|
||||||
### Running telemetry performance test
|
### Running telemetry performance test
|
||||||
|
|
||||||
**Before running performance test make sure browser is not sending requests to island!**
|
**Before running performance test make sure browser is not sending requests to island!**
|
||||||
|
|
||||||
To run telemetry performance test follow these steps:
|
To run telemetry performance test follow these steps:
|
||||||
0. Set `server_config.json` to "standard" (no password protection) setting.
|
0. Set `server_config.json` to "standard" (no password protection) setting.
|
||||||
1. Gather monkey telemetries.
|
1. Gather monkey telemetries.
|
||||||
1. Enable "Export monkey telemetries" in Configuration -> Internal -> Tests if you don't have
|
1. Enable "Export monkey telemetries" in Configuration -> Internal -> Tests if you don't have
|
||||||
exported telemetries already.
|
exported telemetries already.
|
||||||
2. Run monkey and wait until infection is done.
|
2. Run monkey and wait until infection is done.
|
||||||
3. All telemetries are gathered in `monkey/telem_sample`
|
3. All telemetries are gathered in `monkey/telem_sample`
|
||||||
2. Run telemetry performance test.
|
2. Run telemetry performance test.
|
||||||
1. Move directory `monkey/test_telems` to `envs/monkey_zoo/blackbox/tests/performance/test_telems`
|
1. Move directory `monkey/test_telems` to `envs/monkey_zoo/blackbox/tests/performance/test_telems`
|
||||||
2. (Optional) Use `envs/monkey_zoo/blackbox/tests/performance/utils/telem_parser.py` to multiply
|
2. (Optional) Use `envs/monkey_zoo/blackbox/tests/performance/utils/telem_parser.py` to multiply
|
||||||
telemetries gathered.
|
telemetries gathered.
|
||||||
1. Run `telem_parser.py` script with working directory set to `monkey\envs\monkey_zoo\blackbox`
|
1. Run `telem_parser.py` script with working directory set to `monkey\envs\monkey_zoo\blackbox`
|
||||||
2. Pass integer to indicate the multiplier. For example running `telem_parser.py 4` will replicate
|
2. Pass integer to indicate the multiplier. For example running `telem_parser.py 4` will replicate
|
||||||
telemetries 4 times.
|
telemetries 4 times.
|
||||||
3. If you're using pycharm check "Emulate terminal in output console" on debug/run configuraion.
|
3. If you're using pycharm check "Emulate terminal in output console" on debug/run configuraion.
|
||||||
3. Performance test will run as part of BlackBox tests or you can run it separately by adding
|
3. Performance test will run as part of BlackBox tests or you can run it separately by adding
|
||||||
`-k 'test_telem_performance'` option.
|
`-k 'test_telem_performance'` option.
|
||||||
|
|
|
@ -159,7 +159,8 @@ class TestMonkeyBlackbox:
|
||||||
return os.path.abspath(LOG_DIR_PATH)
|
return os.path.abspath(LOG_DIR_PATH)
|
||||||
|
|
||||||
def test_server_online(self, island_client):
|
def test_server_online(self, island_client):
|
||||||
assert island_client.get_api_status() is not None
|
if not island_client.get_api_status():
|
||||||
|
pytest.exit("BB tests couldn't reach the Island server, quiting.")
|
||||||
|
|
||||||
def test_ssh_exploiter(self, island_client):
|
def test_ssh_exploiter(self, island_client):
|
||||||
TestMonkeyBlackbox.run_exploitation_test(island_client, Ssh, "SSH_exploiter_and_keys")
|
TestMonkeyBlackbox.run_exploitation_test(island_client, Ssh, "SSH_exploiter_and_keys")
|
||||||
|
|
Loading…
Reference in New Issue