Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select server config at runtime #963

Merged
merged 10 commits into from
Feb 17, 2021
Merged

Conversation

mssalvatore
Copy link
Collaborator

@mssalvatore mssalvatore commented Feb 9, 2021

What does this PR do?

Allows the server config file to be selected at runtime, instead of hard coded in EnvironmentConfig.

Because AppImages are stored in a read_only squashfs, the server config file can not be stored within the source directory of Monkey Island.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the documentation framework updated to reflect the changes?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by modifying monkey_island/linux/run.sh to use --config and specify a different server config file than the default.

  • If applicable, add screenshots or log transcripts of the feature working

@mssalvatore mssalvatore force-pushed the select-server-config-at-runtime branch 2 times, most recently from de8ba4f to 891700c Compare February 10, 2021 13:41
@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #963 (737d1bb) into appimage (0fcbc76) will increase coverage by 0.02%.
The diff coverage is 70.58%.

Impacted file tree graph

@@             Coverage Diff              @@
##           appimage     #963      +/-   ##
============================================
+ Coverage     19.07%   19.10%   +0.02%     
============================================
  Files           338      337       -1     
  Lines         11484    11487       +3     
============================================
+ Hits           2191     2195       +4     
+ Misses         9293     9292       -1     
Impacted Files Coverage Δ
monkey/monkey_island.py 0.00% <0.00%> (ø)
.../monkey_island/cc/environment/set_server_config.py 0.00% <0.00%> (ø)
monkey/monkey_island/cc/main.py 0.00% <0.00%> (ø)
...key_island/cc/environment/environment_singleton.py 71.87% <70.00%> (+2.90%) ⬆️
monkey/monkey_island/cc/consts.py 100.00% <100.00%> (ø)
...monkey_island/cc/environment/environment_config.py 100.00% <100.00%> (+4.00%) ⬆️
...y_island/cc/environment/server_config_generator.py 100.00% <100.00%> (+60.00%) ⬆️

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 0fcbc76...737d1bb. Read the comment docs.


def create_default_config_file(path):
default_config_path = f"{path}.default"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now server_config.json.default file is no longer being used? Why I don't see it being deleted from the codebase?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's there for the convenience of developers. I can remove it or rename it to server_config.json.develop

Copy link
Contributor

@VakarisZ VakarisZ Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it convenient? The purpose of this file was to contain default value of server_config.json. We needed this whole process of config file deployment in order not to have server_config.json in our git, but have it on runtime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it convenient?

As a developer, doing cp server_config.json.default server_config.json in a new development environment is less error prone than editing the file by hand.

The purpose of this file was to contain default value of server_config.json.

Default for whom? Naming it something like .develop or .standard is more useful than default.

We needed this whole process of config file deployment in order not to have server_config.json in our git, but have it on runtime.

That functionality still works. It's just using server_config.json.standard by default if the specified server_config.json doesn't exist.

Copy link
Contributor

@VakarisZ VakarisZ Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a developer, doing cp server_config.json.default server_config.json in a new development environment is less error prone than editing the file by hand.

How it worked before was that server_config.json was automatically created, which is even less error prone.

That functionality still works. It's just using server_config.json.standard by default if the specified server_config.json doesn't exist.

Then we're back at square one: why do we need server_config.json.default ? I think the downside of using standard config for development is that in our statistics we won't be able to distinguish our own monkey usage from client monkey usage, but that doesn't sound like a big problem. If we think this is a problem, we need our codebase to use develop config by default and change this behavior to "use standard instead" during release process. To phrase it differently, we want to use develop by default and change it to whatever as part of our release process.

Copy link
Contributor

@VakarisZ VakarisZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments that start with a bullet point doesn't have to be fixed. Code looks mergeable, but I left some important questions.

The `get_from_json()` and `get_from_dict()` static methods were really
just used for testing. The `EnvironmentConfig` class needs to store its
file path so it can wite to the file if needed. In practical usage,
`EnvironmentConfig` objects are initialized from files, so a simpler
interface is for its constructor to take a file path.
@mssalvatore mssalvatore force-pushed the select-server-config-at-runtime branch from 891700c to 52f80e8 Compare February 12, 2021 14:46
@mssalvatore mssalvatore force-pushed the select-server-config-at-runtime branch from e700e67 to 737d1bb Compare February 17, 2021 15:13
@VakarisZ VakarisZ merged commit 6113f50 into appimage Feb 17, 2021
@mssalvatore mssalvatore deleted the select-server-config-at-runtime branch February 20, 2021 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants