From b848e5d9dfd66553d9b2368931d95a248af20ca2 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Tue, 14 Feb 2023 16:44:41 +0100 Subject: [PATCH] stages/shell.init: add pattern for env var names Pattern for valid environment variable names as defined in The Open Group Base Specifications Issue 7, 2018 edition IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008) https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html Updated tests to match UPPERCASE ONLY var names. --- stages/org.osbuild.shell.init | 5 ++++- test/data/stages/shell.init/b.json | 6 +++--- test/data/stages/shell.init/b.mpp.json | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stages/org.osbuild.shell.init b/stages/org.osbuild.shell.init index 626de098..4684c24f 100755 --- a/stages/org.osbuild.shell.init +++ b/stages/org.osbuild.shell.init @@ -27,7 +27,10 @@ SCHEMA_2 = r""" "additionalProperties": false, "required": ["key", "value"], "properties": { - "key": "string", + "key": { + "type": "string", + "pattern": "^[A-Z_][A-Z0-9_]*$" + }, "value": "string" } } diff --git a/test/data/stages/shell.init/b.json b/test/data/stages/shell.init/b.json index ad9eab02..5512b710 100644 --- a/test/data/stages/shell.init/b.json +++ b/test/data/stages/shell.init/b.json @@ -397,7 +397,7 @@ "test_env": { "env": [ { - "key": "var", + "key": "VAR", "value": "val" } ] @@ -405,11 +405,11 @@ "test_env.2": { "env": [ { - "key": "one", + "key": "ONE", "value": "1" }, { - "key": "two", + "key": "TWO", "value": "2" } ] diff --git a/test/data/stages/shell.init/b.mpp.json b/test/data/stages/shell.init/b.mpp.json index feaac1a2..05adb0e6 100644 --- a/test/data/stages/shell.init/b.mpp.json +++ b/test/data/stages/shell.init/b.mpp.json @@ -54,7 +54,7 @@ "test_env": { "env": [ { - "key": "var", + "key": "VAR", "value": "val" } ] @@ -62,11 +62,11 @@ "test_env.2": { "env": [ { - "key": "one", + "key": "ONE", "value": "1" }, { - "key": "two", + "key": "TWO", "value": "2" } ]