-
Notifications
You must be signed in to change notification settings - Fork 54
Timezone aware datetimes + remove hack from #209 #300
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
Changes from 4 commits
2d4bd54
5177e73
ef808a6
4fde405
df3fdee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import datetime | ||
| import os | ||
| import pathlib | ||
|
|
||
|
|
@@ -75,8 +76,20 @@ def create_permission_file(path: pathlib.Path, domain_id, policy_element) -> Non | |
|
|
||
| cert_path = path.parent.joinpath('cert.pem') | ||
| cert_content = _utilities.load_cert(cert_path) | ||
| kwargs['not_valid_before'] = etree.XSLT.strparam(cert_content.not_valid_before.isoformat()) | ||
| kwargs['not_valid_after'] = etree.XSLT.strparam(cert_content.not_valid_after.isoformat()) | ||
| if _utilities.cryptography_version().major >= 42: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a huge fan of using semver and parsing the version number here. What we've done elsewhere is to be conditional on the API we want existing. In this case, I think we could do something more like: (this also means we don't add another dependency to this package, which I'm always a fan of) What do you think?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My original take was to get rid of comments stating which version was needed while keeping an easy way to track from which version legacy code could be removed. I considered parsing the version string but it seemed more hacky than using a maintained package dedicated to that. I am happy to update the code accordingly if this is the recommended approach. It is explicit in terms of what API is needed. My only concern is that it hides the version of the module we're actually requiring for this API to be used. Which often leads to confusion or extra work when we ask "from what version can we get rid of this legacy code?" (similar to #347). In which case I would add back a comment stating version numbers wherever the check are performed. Would you prefer that to the current approach ? (I'm fine either way 👍) It would look like this # TODO use `not_valid_before_utc` unconditionally once cryptography 42 is available on all target platforms
if hasattr(cert_content, 'not_valid_before_utc'):
cert_not_valid_before_value = cert.not_valid_before_utc
else:
cert_not_valid_before_value = cert.not_valid_before.replace(tzinfo=datetime.timezone.utc)
# TODO use `not_valid_after_utc` unconditionally once cryptography 42 is available on all target platforms
if hasattr(cert_content, 'not_valid_after_utc'):
cert_not_valid_after_value = cert.not_valid_after_utc
else:
cert_not_valid_after_value = cert.not_valid_after.replace(tzinfo=datetime.timezone.utc)v.s. current state: if _utilities.cryptography_version().major >= 42:
cert_not_valid_before_value = cert.not_valid_before_utc
cert_not_valid_after_value = cert.not_valid_after_utc
else:
cert_not_valid_before_value = cert.not_valid_before.replace(tzinfo=datetime.timezone.utc)
cert_not_valid_after_value = cert.not_valid_after.replace(tzinfo=datetime.timezone.utc)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that would be better rather than adding the new dependency. Thanks!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in df3fdee |
||
| kwargs['not_valid_before'] = etree.XSLT.strparam( | ||
| cert_content.not_valid_before_utc | ||
| ) | ||
| kwargs['not_valid_after'] = etree.XSLT.strparam( | ||
| cert_content.not_valid_after_utc | ||
| ) | ||
| else: | ||
| kwargs['not_valid_before'] = etree.XSLT.strparam( | ||
| cert_content.not_valid_before.replace(tzinfo=datetime.timezone.utc).isoformat() | ||
| ) | ||
| kwargs['not_valid_after'] = etree.XSLT.strparam( | ||
| cert_content.not_valid_after.replace(tzinfo=datetime.timezone.utc).isoformat() | ||
| ) | ||
|
|
||
| if get_rmw_implementation_identifier() in _RMW_WITH_ROS_GRAPH_INFO_TOPIC: | ||
| kwargs['allow_ros_discovery_topic'] = etree.XSLT.strparam('1') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,8 @@ | |
| <xsl:output omit-xml-declaration="yes" indent="yes"/> | ||
| <xsl:strip-space elements="*"/> | ||
|
|
||
| <xsl:param name="not_valid_before" select="'2020-05-01T00:00:00'"/> | ||
| <xsl:param name="not_valid_after" select="'2030-05-01T00:00:00'"/> | ||
| <xsl:param name="not_valid_before" select="'2020-05-01T00:00:00+00:00'"/> | ||
| <xsl:param name="not_valid_after" select="'2030-05-01T00:00:00+00:00'"/> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to use From the OP ticket:
Not sure if this (formatting choice) was the original point of issue here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I initially tried this 2754240 but one of the issues is that Python has pretty limited support for it. The ability to parse a string in that format appeared in Python 3.11. I guess we can revisit if the testing of this with connext show the issue still exists with version 6.0.1. |
||
|
|
||
| <xsl:variable name="template_validity"> | ||
| <validity> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of the opinion if it still broken for a DDS vendor by now, then that's more concerning. I've no longer have an active licence, but I could go ask for a renewal to verify this if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah so its a bit tricky,
the version shipped with the Jazzy binaries fails to run the launcher:
The only one I saw available on their website is 7.3.0.
And 7.3.0 is not API compatible with 6.0.1 so I cannot launch nodes
I could try to install the rtipkg from commandline but not sure where to download them if not from the rti website or launcher..
Maybe someone at Open Robotics could give this PR a try ? (as osrf has both license and installer backed up)
@clalancette do you know anyone we could reach out for that could test this ?
So there is a larger issue here, how do people install connext with security plugins for any active ROS 2 distro ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahcorde Hey there 👋
The PR I dont have the ability to test myself we were chatting about offline today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only concern before merge, everything else looks good to me.