Commit Graph

2955 Commits

Author SHA1 Message Date
VakarisZ d52e80a3f3 Improved the readability IslandConfigOptions test 2021-05-24 14:03:49 +03:00
VakarisZ 2afdfa297b Improved IslandConfigOptions readability by removing defaults and added a unit test for constructor 2021-05-24 13:37:02 +03:00
Shreya d33c5d68d8 Use `os.path.expandvars()` on server config argument 2021-05-24 15:17:22 +05:30
VakarisZ 3098ac1459 Fixed a failing environment setup in unit tests 2021-05-24 12:25:10 +03:00
VakarisZ 5f88f6f04b Moved a comment to a proper place 2021-05-24 12:13:33 +03:00
VakarisZ 0f49579148 Added typehints to IslandConfigOptions 2021-05-24 11:34:55 +03:00
VakarisZ 8afe93747f Improved monkey_island.py setup readability by extracting workflows of server_config setup by cmd_arguments and setup of server_config using defaults 2021-05-24 11:10:16 +03:00
VakarisZ 70b9a9f6b7 Refactored config_loader.py and server_config_handler.py into a single file, with server config write/read operations 2021-05-24 11:05:15 +03:00
Shreya 43d919a3eb Create default server_config.json when running unit tests 2021-05-21 20:09:17 +05:30
Shreya 23b04920b2 Remove unit test related to code removed in the previous commit 2021-05-21 19:18:08 +05:30
Shreya 9705c73978 Remove code in environment_config.py which was calling `write_default_server_config_to_file()`
This was causing an error in the unit tests, and is handled in monkey_island.py (commit 3de620e3).
2021-05-21 18:57:40 +05:30
shreyamalviya b4708fc2cb Import Windows specific modules only on Windows systems 2021-05-21 14:56:14 +05:30
shreyamalviya dc129c017b Fix unit test in test_consts.py 2021-05-21 14:55:04 +05:30
shreyamalviya 37b7815e00 Move `is_windows_os()` to separate file 2021-05-21 14:55:04 +05:30
shreyamalviya 2fb77fcb39 Get default directory depending on OS 2021-05-21 14:55:04 +05:30
VakarisZ 409a3c5234 Refactored code duplication by adding a parameter for create_data_dir 2021-05-21 14:55:04 +05:30
VakarisZ 8ce506ac6f Refactored windows permission handling into a separate file 2021-05-21 14:55:04 +05:30
shreyamalviya 8c575b9d35 Import Windows specific modules only on Windows 2021-05-21 14:55:04 +05:30
shreyamalviya e7a26aa2d1 Rename `set_data_dir_security_to_read_by_owner()` to
`set_data_dir_security_to_read_and_write_by_owner`
2021-05-21 14:55:04 +05:30
shreyamalviya 3201672248 Move `is_windows_os` to data_dir_generator.py and add user write
permissions to newly created data directory
2021-05-21 14:55:04 +05:30
shreyamalviya a1beee95f3 Change data_dir permissions on Windows 2021-05-21 14:55:04 +05:30
Shreya af42c01aa9 Replace missed out function name 2021-05-21 14:55:04 +05:30
Shreya d8927a5c55 Create constant SERVER_CONFIG_FILENAME 2021-05-21 14:55:04 +05:30
Shreya 805e5e6c22 Restructure code for creating default data directory and server config 2021-05-21 14:55:04 +05:30
Shreya 9eedac4eb2 Move `create_data_dir()` from monkey_island.py to monkey_island/cc/setup.py 2021-05-21 14:55:04 +05:30
Shreya 808e86df1a Create data_dir before logger is set up 2021-05-21 14:55:04 +05:30
Shreya 82463416f8 Create data dir if `--server-config` is passed, "data_dir" field exists, but the dir doesn't exist 2021-05-21 14:55:04 +05:30
Shreya 76d82cecea Create `data_dir` if no `--server-config` is passed during Monkey Island initialisation 2021-05-21 14:55:04 +05:30
VakarisZ 66b3fb1d47 Added boilerplate methods for mongodb launch. 2021-05-21 12:10:24 +03:00
VakarisZ 2621458b37 Refactored tests to test config file parsing and IslandConfig param extraction 2021-05-21 11:49:33 +03:00
VakarisZ 9cffb9e9d1 Refactored `SetupParams` into IslandConfigOptions and altered setup workflow to use it 2021-05-21 11:26:02 +03:00
VakarisZ a17c01c7ee Improved readability in arg_parser.py 2021-05-21 11:20:54 +03:00
VakarisZ 411345d603 Refactored "main" method in island to use setup params 2021-05-20 14:02:47 +03:00
VakarisZ df5cec6323 Added a simple unit test for setup_param_factory.py 2021-05-20 13:55:51 +03:00
VakarisZ 9f469a8ec0 Added tests for refactored config file parser 2021-05-20 13:55:51 +03:00
VakarisZ 8c210fc21f Improved setup_param_factory.py further, by extracting loading server config file out of the factory 2021-05-20 13:55:51 +03:00
VakarisZ 9055381873 Moved island setup param related code into cc/setup folder 2021-05-20 13:55:51 +03:00
VakarisZ d768d60f9f Extracted island setup parameter extraction into a separate workflow/DTO 2021-05-20 13:55:51 +03:00
VakarisZ 8bb6e2f21f Added mongodb parameters to appimage server config and develop server config 2021-05-20 13:55:51 +03:00
VakarisZ e97882369c Added init files to test directories so that conftest files could import fixtures 2021-05-20 10:30:10 +03:00
VakarisZ 0ab91ef27d Altered mongomock fixture to be a module-scoped, in an attempt to fix fixture import error 2021-05-20 10:22:20 +03:00
VakarisZ 99bbe36c62 Moved a unit test into unit_tests folder 2021-05-20 09:58:58 +03:00
VakarisZ 30008d47a8 Created a separate directory for unit tests and moved them into that directory 2021-05-19 09:42:15 +03:00
VakarisZ 4f25e1b6c8 Refactored to use fixtures without enum, to be consistent with other UT code 2021-05-19 09:42:15 +03:00
VakarisZ c85ac0f610 Moved unit test files and profiling test decorator into test directory away from production code 2021-05-19 09:42:15 +03:00
VakarisZ 832453fdb5
Merge pull request #1177 from guardicore/unit_test_fixture_refactoring
Unit test fixture refactoring
2021-05-19 09:38:17 +03:00
VakarisZ 8bbf4bae36 Renamed mock_data_dir to data_for_tests 2021-05-19 09:27:26 +03:00
VakarisZ 8b438b3a75 Improved tests of environment config: file saving tests no longer coupled with file contents 2021-05-18 15:40:53 +03:00
VakarisZ a4a0aba0fe Refactored UT's fixtures to be on separate files and renamed folders/fixture to be more precise 2021-05-18 15:39:42 +03:00
VakarisZ 58b04ecb91 Added unit test of random password generator 2021-05-18 10:03:59 +03:00
Shreya fc82b2a9dc Replace "remote_user_pwd" with "random_password" 2021-05-17 22:51:14 +05:30
Shreya 636a201d19 Set default password length to 32 in `get_random_password()` 2021-05-17 22:48:01 +05:30
Shreya 51b996ce18 Generate password randomly when creating a new user for Create User PBA and exploit MS08_67 using https://docs.python.org/3.7/library/secrets.html#secrets.token_urlsafe 2021-05-17 19:10:40 +05:30
Mike Salvatore 3205d8344c Merge branch 'environment-config-section' into develop 2021-05-13 08:02:55 -04:00
Mike Salvatore f0bd6e10d3 island: Remove duplicate deployment from server_config.json.develop 2021-05-13 07:59:32 -04:00
VakarisZ c40465d6fd
Merge pull request #1160 from guardicore/no-global-data-dir
No global data dir
2021-05-13 13:02:54 +03:00
Mike Salvatore b8d4452e70 island: Rename RunLocalMonkeyService -> LocalMonkeyRunService 2021-05-12 12:09:46 -04:00
Mike Salvatore 79eb7442ae island: Move the specifics of saving pba files to pba service 2021-05-12 11:53:10 -04:00
Mike Salvatore 253588b3ac island: Move PBA filename paths to config_value_paths.py 2021-05-12 11:53:07 -04:00
Mike Salvatore 2485c85d59 island: Don't use `shell=True` when running local monkey 2021-05-12 08:42:12 -04:00
Mike Salvatore f86bc7f943 island: Move run_local_monkey() to its own service 2021-05-12 08:35:46 -04:00
Mike Salvatore db14285934 island: Add `dir_is_empty()` to clarify intent of `test_remove_pba_files()` 2021-05-12 08:10:01 -04:00
Mike Salvatore e3449d17c7 Remove file that was accidentally added 2021-05-12 08:07:04 -04:00
Mike Salvatore 2d422f157e island: Add `umask 377` to create_certificate.sh
By setting the umask to 377 in create_certificate.sh, we ensure that the
TLS key file that is created is readable only by the user that created
it, and not world readable (as is the default on some linux distros).
2021-05-11 19:22:43 -04:00
Mike Salvatore b4dfba294b island: Pass data_dir to main() 2021-05-11 14:56:50 -04:00
Mike Salvatore c832738a8a island: Remove all references to data_dir in EnvironmentConfig 2021-05-11 14:41:00 -04:00
Mike Salvatore fb3e66f75e island: Add "environment" section to server_config.json
Put the environment config inside its own "environment" object in the
server_config.json to provide a logical separation between the
environment config, logger config, data directory, etc.
2021-05-11 14:41:00 -04:00
Mike Salvatore 9476441526 island: Remove circular dep btw ConfigService and PostBreachFilesService 2021-05-11 14:40:53 -04:00
Mike Salvatore ea82e86df5 island: Add tests for PostBreachFilesService 2021-05-11 14:40:53 -04:00
Mike Salvatore 4364a48561 island: Simplify remove_PBA_files() 2021-05-11 14:40:53 -04:00
Mike Salvatore 5742e85ff5 island: Consolidate duplicate delete post breach file functionality 2021-05-11 14:40:53 -04:00
Mike Salvatore 71029cb7f9 island: Decouple FileUpload resource from environment_singleton 2021-05-11 14:40:53 -04:00
Mike Salvatore ca65330e86 island: Create custom PBA directory on PostBreachFilesService init 2021-05-11 14:40:53 -04:00
Mike Salvatore be0f7ac881 island: Decouple PBAFileDownload from environment_singleton 2021-05-11 14:40:53 -04:00
Mike Salvatore 4190797ca2 island: Add PostBreachFilesService.get_custom_pba_directory() 2021-05-11 14:40:53 -04:00
Mike Salvatore ee19eed596 island: Decouple PostBreachFilesService from environment_singleton 2021-05-11 14:40:53 -04:00
Mike Salvatore a7f2e023b8 island: Wrap services/post_breach_files.py functions in a static class 2021-05-11 14:40:53 -04:00
Mike Salvatore ba86ba0395 island: Decouple Database service from services.post_breach_files
Since Database.reset_db() calls ConfigService.init_config() which calls
ConfigService.reset_config() which calls
services.post_breach_files.remove_PBA_files(), it is redundant to call
remove_PBA_files() from Database.reset_db(). Removing this call has the
added benefit of reducing the coupling between the Database service and
services.post_breach_files
2021-05-11 14:40:53 -04:00
Mike Salvatore f048cf313c island: Pass data_dir to LocalRun instead of using global singleton 2021-05-11 14:40:53 -04:00
Mike Salvatore 0b21dac261 Merge branch 'untangle-logger-config' into develop 2021-05-11 14:40:39 -04:00
Mike Salvatore b13839d7ba island: Add debug log level to server_config.json.develop 2021-05-11 14:01:43 -04:00
Mike Salvatore 08668f3eae island: Handle lower case log levels in server config 2021-05-11 13:40:58 -04:00
Mike Salvatore 5ea241f120 island: Simplify logic in add_default_values_to_config() 2021-05-11 13:29:53 -04:00
Mike Salvatore de7865aa21 island: Add tests for default server config values 2021-05-11 13:25:22 -04:00
Mike Salvatore 990244c3ac island: Return config dict from load_server_config()
As the number of configuration items will increase in the future, return
the config dict instead of individual config properties.
2021-05-11 13:18:24 -04:00
Mike Salvatore 5847674d92 island: Add unit test for load_server_config() 2021-05-11 13:14:07 -04:00
Mike Salvatore f7bef76f39 island: Move load_server_config() to config_loader.py
Because `monkey_island.py` has the same name as the `monkey_island`
module, pytest can't import monkey_island.py and run any tests against
its code.
2021-05-11 13:00:44 -04:00
Shreya 83a235bb5d Rename unit test functions in test_island_logger.py 2021-05-11 19:08:28 +05:30
Shreya 5f8145e3d1 Add tests for console logging (test_island_logger.py) 2021-05-11 19:06:38 +05:30
Shreya c5ba48db53 Modify/add unit tests (test_island_logger.py) 2021-05-11 18:57:24 +05:30
Shreya e8c1c81edf Move `DEFAULT_LOG_LEVEL` and add function `load_server_config` to monkey_island.py 2021-05-11 18:16:45 +05:30
Shreya 3c7687a405 Catch and print errors instead of creating a default server config 2021-05-11 18:08:07 +05:30
Shreya 805ab989b9 Remove "__author__" field 2021-05-11 17:58:07 +05:30
Shreya 8dc84ee0f7 Assume configured data directory exists when configuring the logger 2021-05-11 17:56:49 +05:30
Mike Salvatore b5c9828ddc island: Remove errant space in manual run windows command
Fixes #1153
2021-05-10 11:52:31 -04:00
Shreya 6d04e7cbb4 Fix unit tests and modify code based on failed tests (tests/monkey_island/cc/server_utils/test_island_logger.py) 2021-05-10 14:52:07 +05:30
Shreya f84e4aed2c Set log filename in config before expanding its paths 2021-05-10 14:04:07 +05:30
Shreya 785f2ef77d Replace `json_setup_logging()` with `setup_logging()` to configure logger 2021-05-10 13:49:33 +05:30
Shreya ab89590389 Remove `--logger-config` command-line argument, add "log_level" to server_config.json 2021-05-10 13:05:06 +05:30
Mike Salvatore 69af8a8662 island: Remove MongoClient() call from BootloaderHttpServer 2021-05-07 08:12:09 -04:00