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

Password setup and bootstrap v4 migration #688

Merged
merged 42 commits into from
Jun 25, 2020
Merged

Password setup and bootstrap v4 migration #688

merged 42 commits into from
Jun 25, 2020

Conversation

VakarisZ
Copy link
Contributor

What is this?

Fixes #596
Migrates UI to bootstrap v4.

Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Have you successfully tested your changes locally?
  • Is the TravisCI build passing?

Proof that it works

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

return []

# Username:test Password:test
CONFIG_WITH_CREDENTIALS = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making tests scattered all around the codebase might've been a mistake: where should common code between tests go?

Copy link
Contributor

Choose a reason for hiding this comment

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

Under common?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have IslandTestCase for example which is common to a lot of tests and works fine ¯_(ツ)_/¯

Copy link
Contributor

@ShayNehmad ShayNehmad left a comment

Choose a reason for hiding this comment

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

Some minor comments, and a few usage questions:

  1. Do we support changing the password? If so, how?
  2. Do we support multiple users+password combos? If so, how?

The testing is very extensive and the design seems "lean and mean" to fit it! TDD paying dividends. 🤩

Also, like we've discussed, adding some short usage documentation with images/gifs will be useful (even on the open doc framework branch) , since this is the first screen that users are met with.

Comment on lines 27 to 28
# TODO change this to propper registration?
User(1, 'monkey', self.hash_secret(self._instance_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good question.
On the one hand, forcing people to use that machine ID seems worse than them choosing their own password, on the other, might be a tiny bit more secure (the time in between setting up the machine and logging in), but that's really a stretch.

Let's delete this user and use the same login method across all our instances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instance ID is public knowledge, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, instance-id requires either running code on the machine or having access to the ec2 dashboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've seen amazon support asking for it on a forum. Maybe it's not public knowledge, but it's not a secret either.

return []

# Username:test Password:test
CONFIG_WITH_CREDENTIALS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have IslandTestCase for example which is common to a lot of tests and works fine ¯_(ツ)_/¯

monkey/monkey_island/cc/resources/auth/user_store.py Outdated Show resolved Hide resolved
Comment on lines +81 to +82
default:
return page_component;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there a default case on a boolean value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On component init these are set to undefined. It becomes boolean once the component gets response from server.


@staticmethod
def get_config_file_path() -> str:
return os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc/server_config.json')
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bug, should be os.path.join(MONKEY_ISLAND_ABS_PATH, 'cc', 'server_config.json')...

Or even better change MONKEY_ISLAND_ABS_PATH from a string to a Path (from pathlib) and then use

MONKEY_ISLAND_ABS_PATH.joinpath("cc").joinpath("server_config.json")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bug, but I agree.

@@ -7,7 +8,7 @@

class TestAwsEnvironment(IslandTestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

We're changing the AWS env behaviour to be default, so this test might become redundant - if so delete it : )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

Comment on lines 99 to 103
if platform.system() == "Windows":
server_file_path = MONKEY_ISLAND_ABS_PATH + "\cc/server_config.json"
else:
server_file_path = MONKEY_ISLAND_ABS_PATH + "/cc/server_config.json"
self.assertEqual(EnvironmentConfig.get_config_file_path(), server_file_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Path equality should be done with pathlib and not strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree: if test code is exactly the same as production then we'll get exactly the same results. This tests if we use pathlib correctly and if it's interface didn't change.


class User(object):
def __init__(self, user_id, username, secret):
self.id = user_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we ever using the UserId?

Copy link
Contributor Author

@VakarisZ VakarisZ Jun 22, 2020

Choose a reason for hiding this comment

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

No, but I think JWT interface requires it and that's why it was added in the first place.

return cred_dict

def to_auth_user(self) -> User:
return User(1, self.username, self.password_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the UserId const 1 ?

@VakarisZ VakarisZ changed the title Password setup Password setup and bootstrap v4 migration Jun 19, 2020
@VakarisZ
Copy link
Contributor Author

Migrating to bootstrap v4 I had to use json-schema-b4 fork, that uses bootstrap v4 with font awesome. I couldn't find a way to include all css of font awesome through react-font-awesome package nor through font-awesome npm package, that's why I had to download the whole font awesome files and include them into the project manually. We could do CDN but I'd rather keep files local. We could also make these files into a fork/submodule?

@VakarisZ
Copy link
Contributor Author

  1. Do we support changing the password? If so, how?
  2. Do we support multiple users+password combos? If so, how?
    Also, like we've discussed, adding some short usage documentation with images/gifs will be useful (even on the open doc framework branch) , since this is the first screen that users are met with.
  1. Yes. The exactly same way we did before: trough manual hash computation :D Or even better way available now: delete credentials and re-run island :)
  2. No
  3. Registration process should be intuitive. What's not intuitive is how to change credentials and that should be covered in docs for sure.

@ShayNehmad
Copy link
Contributor

Migrating to bootstrap v4 I had to use json-schema-b4 fork, that uses bootstrap v4 with font awesome. I couldn't find a way to include all css of font awesome through react-font-awesome package nor through font-awesome npm package, that's why I had to download the whole font awesome files and include them into the project manually. We could do CDN but I'd rather keep files local. We could also make these files into a fork/submodule?

We can't do a CDN. No need to fork fontawesome (we're not planning on changing it). What's not working with npm install --save @fortawesome/fontawesome-free?

@VakarisZ
Copy link
Contributor Author

We can't do a CDN. No need to fork fontawesome (we're not planning on changing it). What's not working with npm install --save @fortawesome/fontawesome-free?

I changed it by removing a big portion of unused code.
Icons are not being displayed, because react-json-schema-bs4 expects styles from all.css that are not included in @fortawesome/fontawesome-free

@codecov
Copy link

codecov bot commented Jun 23, 2020

Codecov Report

Merging #688 into develop will increase coverage by 1.82%.
The diff coverage is 89.65%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #688      +/-   ##
===========================================
+ Coverage    58.06%   59.89%   +1.82%     
===========================================
  Files          139      147       +8     
  Lines         4483     4787     +304     
===========================================
+ Hits          2603     2867     +264     
- Misses        1880     1920      +40     
Impacted Files Coverage Δ
...em_info/windows_cred_collector/pypykatz_handler.py 78.00% <ø> (ø)
...fo/windows_cred_collector/test_pypykatz_handler.py 100.00% <ø> (ø)
monkey/monkey_island/cc/environment/password.py 62.50% <25.00%> (-20.84%) ⬇️
monkey/monkey_island/cc/services/config.py 28.57% <33.33%> (ø)
monkey/monkey_island/cc/resources/auth/auth.py 48.14% <40.00%> (ø)
monkey/monkey_island/cc/environment/aws.py 52.63% <42.85%> (-47.37%) ⬇️
monkey/monkey_island/cc/environment/standard.py 87.50% <66.66%> (+1.78%) ⬆️
monkey/monkey_island/cc/models/__init__.py 90.90% <66.66%> (ø)
...key_island/cc/environment/environment_singleton.py 71.87% <71.87%> (ø)
monkey/monkey_island/cc/environment/__init__.py 77.90% <82.69%> (+4.83%) ⬆️
... and 26 more

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 b0a5c9e...8a31ff2. Read the comment docs.

Lets Go!
</Button>
<a href='#' onClick={this.setNoAuth} className={'no-auth-link'}>
I want anyone to access the island
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps change this to a button as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nahh, this should be a link with small text that no one clicks :)

@VakarisZ VakarisZ merged commit 6cc4c85 into develop Jun 25, 2020
@VakarisZ VakarisZ deleted the password_setup branch December 8, 2020 11:34
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.

Force password creation on first island launch.
3 participants