diff options
Diffstat (limited to 'lib/configuration/tests/errors.t')
| -rw-r--r-- | lib/configuration/tests/errors.t | 98 |
1 files changed, 98 insertions, 0 deletions
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 <<EOF + > { + > "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 <<EOF + > { + > "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 <<EOF + > { + > "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" |
