Merge pull request #642 from guardicore/bugfix/monkey_depth_fix

Fixed monkey ignoring depth restrictions
This commit is contained in:
Shay Nehmad 2020-05-10 15:53:40 +03:00 committed by GitHub
commit f070517137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -18,6 +18,17 @@ install:
- pip install coverage # for code coverage - pip install coverage # for code coverage
- pip install -r monkey/infection_monkey/requirements.txt # for unit tests - pip install -r monkey/infection_monkey/requirements.txt # for unit tests
# node + npm + eslint
- node --version
- npm --version
# Install NVM, see https://github.com/nvm-sh/nvm#installing-and-updating
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- nvm install node
- nvm use node
- npm i -g eslint
- node --version
- npm --version
before_script: before_script:
# Set the server config to `testing`. This is required for for the UTs to pass. # Set the server config to `testing`. This is required for for the UTs to pass.
- python monkey/monkey_island/cc/set_server_config.py testing - python monkey/monkey_island/cc/set_server_config.py testing
@ -49,12 +60,9 @@ script:
# Check JS code. The npm install must happen AFTER the flake8 because the node_modules folder will cause a lot of errors. # Check JS code. The npm install must happen AFTER the flake8 because the node_modules folder will cause a lot of errors.
- cd monkey_island/cc/ui - cd monkey_island/cc/ui
- npm i - npm i
- npm i -g eslint - eslint ./src --quiet # Test for errors
- cd -
- cd monkey_island/cc/ui
- eslint ./src --quiet
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=490 - JS_WARNINGS_AMOUNT_UPPER_LIMIT=490
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT - eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # Test for max warnings
after_success: after_success:
# Upload code coverage results to codecov.io, see https://github.com/codecov/codecov-bash for more information # Upload code coverage results to codecov.io, see https://github.com/codecov/codecov-bash for more information

View File

@ -80,8 +80,12 @@ class InfectionMonkey(object):
self._default_tunnel = self._opts.tunnel self._default_tunnel = self._opts.tunnel
self._default_server = self._opts.server self._default_server = self._opts.server
if self._opts.depth: if self._opts.depth is not None:
WormConfiguration._depth_from_commandline = True WormConfiguration._depth_from_commandline = True
WormConfiguration.depth = self._opts.depth
LOG.debug(f"Setting propagation depth from command line")
LOG.debug(f"Set propagation depth to {WormConfiguration.depth}")
self._keep_running = True self._keep_running = True
self._network = NetworkScanner() self._network = NetworkScanner()
self._dropper_path = sys.argv[0] self._dropper_path = sys.argv[0]