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

3077 get otp from env #3121

Merged
merged 9 commits into from
Mar 17, 2023
Merged

3077 get otp from env #3121

merged 9 commits into from
Mar 17, 2023

Conversation

mssalvatore
Copy link
Collaborator

What does this PR do?

Retrieve and remove the OTP from environment variables.

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?
  • Do all unit tests pass?
  • Do all end-to-end tests pass?
  • Any other testing performed?

    Tested by starting the agent with various environment variables and verifying its behavior

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

@mssalvatore mssalvatore requested review from shreyamalviya and VakarisZ and removed request for shreyamalviya March 17, 2023 01:17
@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch coverage has no change and project coverage change: +4.03 🎉

Comparison is base (a51feb1) 67.69% compared to head (3d53daf) 71.73%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3121      +/-   ##
===========================================
+ Coverage    67.69%   71.73%   +4.03%     
===========================================
  Files          449      449              
  Lines        12815    12828      +13     
===========================================
+ Hits          8675     9202     +527     
+ Misses        4140     3626     -514     

see 23 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


# SECURITY: There's no need to leave this floating around in a place as visible as
# environment variables for any longer than necessary.
del_key(os.environ, AGENT_OTP_ENVIRONMENT_VARIABLE)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a point in wrapping os.environ.pop(AGENT_OTP_ENVIRONMENT_VARIABLE, None). I think we shouldn't have del_key

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 just defensive coding. If something else modifies the environment between these two statements (highly unlikely but ??), not using del_key() would cause the agent to crash.

InfectionMonkey._get_otp()


def test_get_otp__feature_flag_disabled(monkeypatch):
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to unit test feature flags? Interesting... We should come up with a feature flag naming convention, as FLAG is a term often used in cmd arguments and lower level code. Maybe F_FLAG? So it would be OTP_F_FLAG?

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 was easy enough to do it and it helped me quickly test that the feature flag was working as expected.

Environmental name for OTP is relevant to the island as well, it should be in an accessible place for both
@VakarisZ VakarisZ merged commit a5d6170 into develop Mar 17, 2023
@mssalvatore mssalvatore deleted the 3077-get-otp-from-env branch March 17, 2023 10:55
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.

3 participants