summaryrefslogtreecommitdiff
path: root/lib/configuration/tests/errors.t
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-18 20:24:52 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-18 21:57:48 +0100
commit62123e577ee5d4066d53f8ad7e5ac3d2eb190430 (patch)
treef569686630681a9eceb2685f69b55fe5a2bac17c /lib/configuration/tests/errors.t
parent7087a0c2c84e796e474784cbd28d4a4e574cf2c0 (diff)
Securized the queries in the database with a dedicated type for the Identifiers
Diffstat (limited to 'lib/configuration/tests/errors.t')
-rw-r--r--lib/configuration/tests/errors.t98
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"