From 1379abc4909cce887e40fdc7a25bcbe05d55b59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piet=20G=C3=B6mpel?= Date: Mon, 9 Dec 2024 19:13:45 +0100 Subject: [PATCH] Added bounds checking for ConnectorEvseIds and ISO15118EvseId MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piet Gömpel --- config/v16/profile_schemas/Internal.json | 4 +++- .../v201/component_config/custom/EVSE_1.json | 4 +++- .../v201/component_config/custom/EVSE_2.json | 4 +++- lib/ocpp/v16/charge_point_configuration.cpp | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/v16/profile_schemas/Internal.json b/config/v16/profile_schemas/Internal.json index f9e5aed42..854539645 100644 --- a/config/v16/profile_schemas/Internal.json +++ b/config/v16/profile_schemas/Internal.json @@ -292,7 +292,9 @@ "ConnectorEvseIds": { "$comment": "Comma separated EVSEIDs for OCPP connectors starting with connector 1 in one string.", "type": "string", - "readOnly": false + "readOnly": false, + "minLength": 7, + "maxLength": 1000 }, "AllowChargingProfileWithoutStartSchedule": { "$comment": "OCPP1.6 specifies that for certain ChargingProfiles the startSchedule field needs to be set. This flag ignores this requirement and will accept those profiles without startSchedule, assuming startSchedule is now.", diff --git a/config/v201/component_config/custom/EVSE_1.json b/config/v201/component_config/custom/EVSE_1.json index a7022e185..ba04107c2 100644 --- a/config/v201/component_config/custom/EVSE_1.json +++ b/config/v201/component_config/custom/EVSE_1.json @@ -111,7 +111,9 @@ "variable_name": "ISO15118EvseId", "characteristics": { "supportsMonitoring": true, - "dataType": "string" + "dataType": "string", + "minLimit": 7, + "maxLimit": 37 }, "attributes": [ { diff --git a/config/v201/component_config/custom/EVSE_2.json b/config/v201/component_config/custom/EVSE_2.json index 25d859aff..2adade3a4 100644 --- a/config/v201/component_config/custom/EVSE_2.json +++ b/config/v201/component_config/custom/EVSE_2.json @@ -111,7 +111,9 @@ "variable_name": "ISO15118EvseId", "characteristics": { "supportsMonitoring": true, - "dataType": "string" + "dataType": "string", + "minLimit": 7, + "maxLimit": 37 }, "attributes": [ { diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index c235f444c..998006c58 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -940,6 +940,18 @@ bool ChargePointConfiguration::validate_measurands(const json& config) { return true; } +bool validate_connector_evse_ids(const std::string& value) { + // this fullfills parts of HUB-24-003 of Requirements EVSE Check PnC with ISO15118-2 v4 + const auto evse_ids = split_string(value, ','); + for (const auto& evse_id : evse_ids) { + if (evse_id.size() < 7 or evse_id.size() > 37) { + EVLOG_warning << "Attempting to set ConnectorEvseIds to invalid value: " << evse_id; + return false; + } + } + return true; +} + bool ChargePointConfiguration::measurands_supported(std::string csv) { if (csv.empty()) { @@ -3802,7 +3814,11 @@ ConfigurationStatus ChargePointConfiguration::set(CiString<50> key, CiString<500 } if (key == "ConnectorEvseIds") { if (this->getConnectorEvseIds().has_value()) { - this->setConnectorEvseIds(value.get()); + if (validate_connector_evse_ids(value.get())) { + this->setConnectorEvseIds(value.get()); + } else { + return ConfigurationStatus::Rejected; + } } else { return ConfigurationStatus::NotSupported; }