Skip to content

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented Apr 28, 2022

What does this PR do?

Fixes #1636

Add any further explanations here.

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 CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

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

    Tested by setting long timeout, going to run page and making sure loading icon appears while request is loading
    Tested by going to report and making sure aws exporter doesn't crash

Copy link
Contributor

@ilija-lazoroski ilija-lazoroski left a comment

Choose a reason for hiding this comment

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

Good job! Just make sure it is tested on actual AWS instance.

Copy link
Collaborator

@mssalvatore mssalvatore left a comment

Choose a reason for hiding this comment

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

Just a few small suggestions.

@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #1919 (4a1b336) into develop (f65e009) will decrease coverage by 0.06%.
The diff coverage is 76.19%.

❗ Current head 4a1b336 differs from pull request most recent head 3a98fdb. Consider uploading reports for the commit 3a98fdb to get more accurate results

@@             Coverage Diff             @@
##           develop    #1919      +/-   ##
===========================================
- Coverage    55.43%   55.37%   -0.07%     
===========================================
  Files          449      448       -1     
  Lines        12816    12927     +111     
===========================================
+ Hits          7105     7158      +53     
- Misses        5711     5769      +58     
Impacted Files Coverage Δ
...ey/infection_monkey/utils/aws_environment_check.py 0.00% <0.00%> (ø)
monkey/monkey_island/cc/server_setup.py 0.00% <0.00%> (ø)
...onkey_island/cc/services/reporting/aws_exporter.py 0.00% <0.00%> (ø)
monkey/common/aws/aws_service.py 62.06% <50.00%> (ø)
monkey/monkey_island/cc/app.py 78.03% <50.00%> (+0.16%) ⬆️
monkey/common/utils/code_utils.py 76.92% <57.14%> (-23.08%) ⬇️
monkey/monkey_island/cc/services/remote_run_aws.py 58.97% <62.50%> (+5.12%) ⬆️
monkey/common/aws/aws_instance.py 98.33% <100.00%> (ø)
monkey/common/cmd/aws/aws_cmd_runner.py 46.42% <100.00%> (ø)
monkey/monkey_island/cc/resources/remote_run.py 33.33% <100.00%> (ø)
... and 6 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 fdf8198...3a98fdb. Read the comment docs.

Copy link
Collaborator

@mssalvatore mssalvatore left a comment

Choose a reason for hiding this comment

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

Given the complications that have arisen, I think an overall better approach is provide a function called get_aws_info() -> AWSInfo where AWSInfo is a named tuple or dataclass. We can use @lru_cache to cache the results of get_aws_info() to prevent the slow calls from being made more than once.

See the comments for more detail.

VakarisZ and others added 15 commits May 2, 2022 15:55
Singleton is a common pattern, potentially usable in the Agent so it belongs in common
AWS related services call AWS metadata service which might take a long time to timeout, that's why they are ran on a separate thread
Locks will avoid the situation where is_running_on_aws is called before this service finished initializing
Update the IAM role change screenshot and add a note about firewall rules
This change simplifies the codebase by removing unnecessary inheritance and nested directory structure
This also changes AwsInstance from singleton and instead the aws_service package is used as one
@VakarisZ VakarisZ force-pushed the 1636-long-aws-check branch from 501827a to e895897 Compare May 2, 2022 13:02
@mssalvatore mssalvatore merged commit 8d65fa3 into develop May 2, 2022
@mssalvatore mssalvatore deleted the 1636-long-aws-check branch May 2, 2022 13:53
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.

RemoteRunAwsService adds unnecessary delay to Island startup
3 participants