]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(ocpp): reject a supervision URL key value the ws client cannot dial in OCPP 1...
authorVitor Coelho <6161176+VitorCoelho@users.noreply.github.com>
Fri, 30 Oct 2026 16:23:16 +0000 (16:23 +0000)
committerGitHub <noreply@github.com>
Fri, 30 Oct 2026 16:23:16 +0000 (16:23 +0000)
commitf8487b2d256fa3e476a4544a750b23af0152c03c
treedd3a5a0e49771b0ab2342033797330a10b472bb0
parent635362f66e7a5d56850ed1fb2c9714f04b9c0953
fix(ocpp): reject a supervision URL key value the ws client cannot dial in OCPP 1.6 ChangeConfiguration (#2159)

* Add validation for supervision URL in OCPP16 service

Reject invalid supervision URL values to prevent reconnect failures.

* Add tests for supervision URL OCPP configuration key

* fix(ocpp): also reject supervision URL schemes the ws client cannot dial

URL.canParse accepted values such as ftp://host, which were stored
and then failed on reconnect. Accept only the schemes the ws client
dials: ws, wss, http, https and ws+unix.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover supervision URL schemes in OCPP 1.6 ChangeConfiguration

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject a supervision URL with a fragment or an empty ws+unix socket path

The ws client throws for a URL with a fragment identifier and for a
ws+unix URL without a pathname, so OCPP 1.6 ChangeConfiguration accepted
and stored values that fail on reconnect. Reject them.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover fragments and ws+unix socket paths in OCPP 1.6 ChangeConfiguration

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject an empty fragment and a ws+unix URL without a request path separator

The charging station appends its identity to the supervision URL. After a
trailing '#' the identity becomes a fragment, which the ws client rejects,
and a ws+unix URL without a ':' between the socket path and the request
path gets the identity appended to the socket path, so the connection
fails. Reject both in the OCPP 1.6 ChangeConfiguration guard.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover an empty fragment and ws+unix URLs without a request path separator

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): reject supervision URL key values with whitespace, a query string or an ambiguous ws+unix separator

The OCPP 1.6 ChangeConfiguration value is stored as sent, but the guard
validated the parsed URL, which strips surrounding whitespace, tabs and
newlines, so 'ws://localhost:8888 ' was accepted and the reconnect then
failed. The station identity is appended to the URL, so after a '?' it
lands in the query, and ws keeps only the first two ':'-separated parts
of a ws+unix pathname. Reject these; the query and ws+unix rules match
SupervisionUrlSchema.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover whitespace, query strings and ws+unix separators in the supervision URL key

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* fix(ocpp): accept one-character ws+unix socket paths and require a '/' request path

A relative socket path such as 's' in 'ws+unix:s:/OCPP16' is valid, so
require a socket path other than '/' instead of two characters. A request
path without a leading '/' (ws+unix:s:OCPP16) makes the server answer 400,
so require it to be empty or to start with '/'. Same rule as
SupervisionUrlSchema in #2168.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* test(ocpp): cover one-character ws+unix socket paths and request paths without '/'

Regressions for the supervision URL key fix: 'ws+unix:s:/OCPP16' and
'ws+unix:./s:/OCPP16' are accepted, 'ws+unix:s:OCPP16' and
'ws+unix:///tmp/simulator.sock:OCPP16' are rejected.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
* refactor(ocpp): validate the supervision URL key with the shared SupervisionUrlSchema

The OCPP 1.6 ChangeConfiguration guard duplicated the supervision endpoint
policy (schemes, '#' and '?' delimiters, ws+unix socket and request path)
that SupervisionUrlSchema owns since #2160 and #2168. Consume the shared
schema and keep only the OCPP-specific part locally: the key stores the raw
value, so whitespace and control characters are rejected before the schema
check, which would otherwise strip them. Accepted values are still stored
verbatim. No behaviour change.

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
---------

Signed-off-by: VitorCoelho <vitorc195@gmail.com>
Co-authored-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-Configuration.test.ts