From 62123e577ee5d4066d53f8ad7e5ac3d2eb190430 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 18 Nov 2026 20:24:52 +0100 Subject: Securized the queries in the database with a dedicated type for the Identifiers --- lib/configuration/tests/errors.t | 98 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'lib/configuration/tests/errors.t') diff --git a/lib/configuration/tests/errors.t b/lib/configuration/tests/errors.t index 58c15ed..bad5b3b 100644 --- a/lib/configuration/tests/errors.t +++ b/lib/configuration/tests/errors.t @@ -117,3 +117,101 @@ Cycles between required content are not accepted > ] > } Dependency circle found between: entity user + +Identifiers are validated when the configuration is parsed: characters +outside letters, digits and underscore are rejected (a double quote could +otherwise break out of the quoted SQL identifiers): + + $ tests --configuration < { + > "content": [ + > { + > "id": "evil\"; DROP TABLE entity;--" + > } + > ] + > } + > EOF + in field "content": + while decoding a list: + element 0: + in field "id": + Expected an identifier with only the accepted characters, but got + "evil\"; DROP TABLE entity;--" + +Field names are validated the same way: + + $ tests --configuration < { + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "bad\"name", + > "label": {}, + > "type": "text" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + in field "content": + while decoding a list: + element 0: + in field "section": + while decoding a list: + element 0: + in field "field": + while decoding a list: + element 0: + in field "name": + Expected an identifier with only the accepted characters, but got + "bad\"name" + +Reference targets are validated the same way: + + $ tests --configuration < { + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "ref", + > "label": {}, + > "type": { + > "content": "bad\"target" + > } + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + in field "content": + while decoding a list: + element 0: + in field "section": + while decoding a list: + element 0: + in field "field": + while decoding a list: + element 0: + in field "type": + I tried the following decoders but they all failed: + "text" decoder: + Expected a string, but got + { "content": "bad\"target" } + "content" decoder: + in field "content": + Expected an identifier with only the accepted characters, but got + "bad\"target" -- cgit v1.2.3