Timezone aware datetimes + remove hack from #209#300
Conversation
|
@marcoag @clalancette is it possible to launch a round of CI for this PR please 🙏 |
sros2/test/sros2/commands/security/verbs/test_create_enclave.py
Outdated
Show resolved
Hide resolved
|
@ruffsl interested in having your feedback on this. (all info in the description of the PR) |
|
CI on WIndows is failing because CI is using a lower version of Python than the one defined in REP-2000. |
I commented over there, but in short, we are not going to be able to update Python. So we'll have to figure out another solution. |
5006e37 to
1752d32
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rolling #300 +/- ##
===========================================
- Coverage 88.94% 88.38% -0.56%
===========================================
Files 24 24
Lines 615 620 +5
Branches 64 66 +2
===========================================
+ Hits 547 548 +1
- Misses 50 52 +2
- Partials 18 20 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
fefd058 to
03a1e3e
Compare
| <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'"/> |
There was a problem hiding this comment.
Do we want to use +00:00 or Z here?
From the OP ticket:
The time zone may be specified as Z (UTC) or (+|-)hh:mm.
Not sure if this (formatting choice) was the original point of issue here.
There was a problem hiding this comment.
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.
And even in Python 3.12, the printing in isoformat is not configurable and outputs the +HH:MM.
I guess we can revisit if the testing of this with connext show the issue still exists with version 6.0.1.
sros2/sros2/keystore/_permission.py
Outdated
| 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()) | ||
| # TODO replace "not_valid_before"/"not_valid_after" functions by |
There was a problem hiding this comment.
Sad to read about that window holding back and blocking the python REP updates, given the Qt release changes. I hope the latest minor release of cryptography is still secure and up-to-date for all platforms. :<
| # when extracting it from the permissions file and thinking it's in the future | ||
| # https://github.com/ros2/ci/pull/436#issuecomment-624874296 | ||
| utcnow - datetime.timedelta(days=1) | ||
| utcnow |
There was a problem hiding this comment.
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.
yeah so its a bit tricky,
the version shipped with the Jazzy binaries fails to run the launcher:
/opt/rti.com/rti_connext_dds-6.0.1/bin/rtilauncher
Gtk-Message: 09:06:35.729: Failed to load module "canberra-gtk-module"
No RTI workspace was created.
Please contact RTI Support (https://support.rti.com)
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.
@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.
this is the only concern before merge, everything else looks good to me.
|
@marcoag mind giving this a try with connect? 🧇 |
| # when extracting it from the permissions file and thinking it's in the future | ||
| # https://github.com/ros2/ci/pull/436#issuecomment-624874296 | ||
| utcnow - datetime.timedelta(days=1) | ||
| utcnow |
There was a problem hiding this comment.
this is the only concern before merge, everything else looks good to me.
03a1e3e to
f30f050
Compare
|
@sloretz @marcoag @fujitatomoya I rebased this, anyone has the ability to test it on Connext so we can decide if we merge this or if we need to downscope it ? Thanks 🙏 |
|
@mikaelarguedas how about starting CI? that should include the test with ConnextDDS, right? |
|
Pulls: #300 |
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Python 3.8 compatible because windows Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
f30f050 to
6890599
Compare
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
6890599 to
4fde405
Compare
sros2/sros2/keystore/_permission.py
Outdated
| 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: |
There was a problem hiding this comment.
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:
if hasattr(cert_content, 'not_valid_before_utc'):
kwargs = ...
else:
kwargs = ...
(this also means we don't add another dependency to this package, which I'm always a fan of)
What do you think?
There was a problem hiding this comment.
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)There was a problem hiding this comment.
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 👍)
Yeah, I think that would be better rather than adding the new dependency. Thanks!
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
clalancette
left a comment
There was a problem hiding this comment.
This looks good to me, thanks! I'll run CI on it next.
|
Pulls: #300 |
This PR (basically a redo of #210) does:
I dont have a connext setup (license plugins etc right now) and the ROS 2 CI machines seem to be UTC so maybe they wont reflect the issue. If a reviewer that is behind UTC and has the right setup can give it a try that'd be awesome