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

Introduce authentication for zmq communications #56

Open
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

mraspaud
Copy link
Member

@mraspaud mraspaud commented Nov 29, 2023

This PR aims at introducing authentication in the posttroll communications.

  • Create a zmq backend
  • Extract zmq-specific components to the backend
  • Create secure zmq alternatives to the zmq components

@mraspaud mraspaud requested a review from pnuu November 29, 2023 20:00
@mraspaud mraspaud self-assigned this Nov 29, 2023
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: Patch coverage is 94.30712% with 76 lines in your changes are missing coverage. Please review.

Project coverage is 89.63%. Comparing base (be3bb77) to head (97b2f94).
Report is 2 commits behind head on main.

Current head 97b2f94 differs from pull request most recent head ca576b5

Please upload reports for the commit ca576b5 to get more accurate results.

Files Patch % Lines
posttroll/backends/zmq/subscriber.py 88.14% 16 Missing ⚠️
posttroll/message.py 78.43% 11 Missing ⚠️
posttroll/address_receiver.py 85.45% 8 Missing ⚠️
posttroll/logger.py 0.00% 6 Missing ⚠️
posttroll/backends/zmq/__init__.py 86.84% 5 Missing ⚠️
posttroll/subscriber.py 89.79% 5 Missing ⚠️
posttroll/backends/zmq/address_receiver.py 86.95% 3 Missing ⚠️
posttroll/backends/zmq/ns.py 95.52% 3 Missing ⚠️
posttroll/bbmcast.py 93.61% 3 Missing ⚠️
posttroll/tests/test_message.py 91.66% 3 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
+ Coverage   79.90%   89.63%   +9.72%     
==========================================
  Files          17       26       +9     
  Lines        2210     2297      +87     
==========================================
+ Hits         1766     2059     +293     
+ Misses        444      238     -206     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mraspaud mraspaud marked this pull request as ready for review May 21, 2024 09:48
Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

First of all, great work with the refactoring!

Could you run flake8 and see if there are manageable amount of things to fix? There were some missing new-lines in at least message.py.

Couple additional comments inline.


ten_minutes = dt.timedelta(minutes=10)
zero_seconds = dt.timedelta(seconds=0)


def get_configured_address_port():
return config.get("address_publish_port", DEFAULT_ADDRESS_PUBLISH_PORT)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

One new-line missing. Shouldn't flake8 catch this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using ruff now, which can't count empty lines I think

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, should be fixed now

Copy link
Member Author

Choose a reason for hiding this comment

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

For reference, the --preview flag needs to be added to ruff for the blank lines.

Comment on lines +48 to +54
try:
port = int(os.environ["NAMESERVER_PORT"])
warnings.warn("NAMESERVER_PORT is pending deprecation, please use POSTTROLL_NAMESERVER_PORT instead.",
PendingDeprecationWarning)
except KeyError:
port = DEFAULT_NAMESERVER_PORT
return config.get("nameserver_port", port)
Copy link
Member

Choose a reason for hiding this comment

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

The new POSTTROLL_NAMESERVER_PORT isn't checked even if the warning suggests it should be used.

Copy link
Member

Choose a reason for hiding this comment

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

... or is it coming via Donfig?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, that's Donfig

Comment on lines +349 to +355
_ = settings.pop("nameserver", None)
_ = settings.pop("port", None)
_ = settings.pop("services", None)
_ = settings.pop("addr_listener", None),
_ = settings.pop("timeout", None)

return Subscriber(addresses, topics=topics, message_filter=message_filter, translate=translate)
return Subscriber(**settings)
Copy link
Member

Choose a reason for hiding this comment

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

I think the original is cleaner as well as explicit. If there are extra items in settings the Subscriber creation will fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's the point. Until now we could pass whatever and not even know it was wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants