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

feature/141, OCPP 1.6 Security White Paper Ed 2 #206

Merged
merged 2 commits into from
Jun 27, 2021

Conversation

villekr
Copy link
Contributor

@villekr villekr commented Apr 23, 2021

Improved Security for OCPP 1.6-J specification (https://www.openchargealliance.org/news/enhanced-security-for-ocpp-16/) adds few messages backported from 2.0 to 1.6. Some messages have been renamed to prevent conflict with original 1.6 messages. Also some schemas have modified content. Open Charge Alliance hasn't released official backported schema files.

Changes to mobilityhouse/ocpp:

  • Copied selected 2.0 schema files to 1.6. Files are stored ocpp/v16/schemas/backport to clearly separate them from original 1.6 files.
  • Backported schema files have been renamed according to improved security specification, and their content has been checked and modified.
  • Added support for loading backported schema files.
  • Added test case to verify that using backported action type works.

This PR is a fix for #141.

@villekr villekr changed the title feature/197, Support for Improved Security for OCPP 1.6-J specification feature/141, OCPP 1.6 Security White Paper Ed 2 Apr 23, 2021
Copy link
Collaborator

@OrangeTux OrangeTux left a comment

Choose a reason for hiding this comment

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

Thanks for your PR. I've some suggestion for improvements.

I don't like the suffix Type to all enums. although it's according to the specification. So I'm not sure yet if we should keep it or remove it. I'll come back to you regarding this topic.

ocpp/messages.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
ocpp/v16/call.py Outdated Show resolved Hide resolved
@villekr
Copy link
Contributor Author

villekr commented Apr 27, 2021

I've made the following changes:

  • Replaced backported schema files with official ones (https://www.openchargealliance.org/uploads/files/OCPP-1.6-security-whitepaper-edition-2.zip) instead of the ones copied and modified form v20/schemas folder.
  • Stored backported schema files in v16/schemas. Removed related code changes that were added to messages.py to read schemas from v16/schemas/backport.
  • Renamed enum types without Type-suffix so naming now follows the pattern (type in spec) CertificateSignedStatusEnumType -> (type in code) CertificateSignedStatus. The following ones are exceptions due conflict in original types: SignedFirmwareStatus, ExtendedMessageTrigger, ExtendedTriggerMessageStatus.
  • Also made fixes to mentioned request payload classes.

ocpp/messages.py Outdated Show resolved Hide resolved
ocpp/messages.py Outdated Show resolved Hide resolved
ocpp/v16/enums.py Outdated Show resolved Hide resolved
Comment on lines 756 to 764
class ExtendedTriggerMessageStatus(str, Enum):
"""
TriggerMessageStatusEnumType is used by: ExtendedTriggerMessage.conf
"""

accepted = "Accepted"
rejected = "Rejected"
not_implemented = "NotImplemented"

Copy link
Collaborator

@tropxy tropxy May 6, 2021

Choose a reason for hiding this comment

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

This already exists as TriggerMessageStatus, so I dont think we need to repeat it with a different name. Also in the whitepaper is defined as "TriggerMessageStatusEnumType" and I think we should stick with the whitepaper terms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point as values are the same there's no point duplicating this type.

Comment on lines 742 to 753
class ExtendedMessageTrigger(str, Enum):
"""
MessageTriggerEnumType is used by: ExtendedTriggerMessage.req
"""

boot_notification = "BootNotification"
log_status_notification = "LogStatusNotification"
firmware_status_notification = "FirmwareStatusNotification"
heartbeat = "Heartbeat"
meter_values = "MeterValues"
sign_charge_point_certificate = "SignChargePointCertificate"
status_notification = "StatusNotification"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont think we need to create a new Status for the Extended Trigger. We can just add the extra fields that are added by the whitepaper and add a comment mentioning it. This will then be in accordance with the Whitepaper which also doesnt change the name of the enum "TriggerMessageStatusEnumType"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make that change also.

ocpp/v16/enums.py Outdated Show resolved Hide resolved
@villekr
Copy link
Contributor Author

villekr commented May 6, 2021

I will also sort payload classes in call.py and call_result.py based on communication direction as are previous payloads defined. Also enums.py is using alphabetical sorting so I'll follow that as well.

@villekr
Copy link
Contributor Author

villekr commented May 6, 2021

I made suggested/requested changed (hopefully all this time) and also rebased against master.

Copy link
Collaborator

@tropxy tropxy left a comment

Choose a reason for hiding this comment

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

Looks good now, to me ;)

@villekr
Copy link
Contributor Author

villekr commented May 17, 2021

@OrangeTux @tropxy When are you planning to create next release that will include this PR?

@villekr
Copy link
Contributor Author

villekr commented Jun 10, 2021

@OrangeTux @tropxy Is there something still regarding this PR that you would like to see changed? When are you planning to include this in release?

@tropxy
Copy link
Collaborator

tropxy commented Jun 11, 2021

As I said last time, for me this PR seems complete. There are some lack of new lines in the schema files, but that is not a blocker for me at least. @OrangeTux needs to take an action here and check if he confirms that the PR is ready to merge. Without his feedback, your PR cant be merged

@OrangeTux OrangeTux merged commit 10996e2 into mobilityhouse:master Jun 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants