From a1478eb765e918e288a35d8b2610756eb22e52dc Mon Sep 17 00:00:00 2001 From: Chandrasekhar Raman <33996892+chandrasekhar1996@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:04:22 -0700 Subject: [PATCH] allow % character in tag value (#2777) Signed-off-by: craman Co-authored-by: craman --- clients/go/zms/zms_schema.go | 4 ++-- core/zms/src/main/java/com/yahoo/athenz/zms/ZMSSchema.java | 4 ++-- core/zms/src/main/rdl/Names.tdl | 2 +- core/zms/src/test/java/com/yahoo/athenz/zms/ZMSCoreTest.java | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/clients/go/zms/zms_schema.go b/clients/go/zms/zms_schema.go index 26fdf544434..53a39eadc2d 100644 --- a/clients/go/zms/zms_schema.go +++ b/clients/go/zms/zms_schema.go @@ -111,12 +111,12 @@ func init() { tTagValue := rdl.NewStringTypeBuilder("TagValue") tTagValue.Comment("TagValue to contain generic string patterns") - tTagValue.Pattern("[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*") + tTagValue.Pattern("[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*") sb.AddType(tTagValue.Build()) tTagCompoundValue := rdl.NewStringTypeBuilder("TagCompoundValue") tTagCompoundValue.Comment("A compound value of TagValue") - tTagCompoundValue.Pattern("([a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*\\.)*[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*") + tTagCompoundValue.Pattern("([a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*\\.)*[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*") sb.AddType(tTagCompoundValue.Build()) tTagValueList := rdl.NewStructTypeBuilder("Struct", "TagValueList") diff --git a/core/zms/src/main/java/com/yahoo/athenz/zms/ZMSSchema.java b/core/zms/src/main/java/com/yahoo/athenz/zms/ZMSSchema.java index 0290a7dbb72..a9931d412d7 100644 --- a/core/zms/src/main/java/com/yahoo/athenz/zms/ZMSSchema.java +++ b/core/zms/src/main/java/com/yahoo/athenz/zms/ZMSSchema.java @@ -94,11 +94,11 @@ private static Schema build() { sb.stringType("TagValue") .comment("TagValue to contain generic string patterns") - .pattern("[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*"); + .pattern("[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*"); sb.stringType("TagCompoundValue") .comment("A compound value of TagValue") - .pattern("([a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*\\.)*[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*"); + .pattern("([a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*\\.)*[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*"); sb.structType("TagValueList") .arrayField("list", "TagCompoundValue", false, "list of tag values"); diff --git a/core/zms/src/main/rdl/Names.tdl b/core/zms/src/main/rdl/Names.tdl index df12a1164f0..70f81c7ab99 100644 --- a/core/zms/src/main/rdl/Names.tdl +++ b/core/zms/src/main/rdl/Names.tdl @@ -73,7 +73,7 @@ type AuthorityKeywords String (pattern="({AuthorityKeyword},)*{AuthorityKeyword} type TagKey String (pattern="({SimpleName}[:\\.])*{SimpleName}"); //TagValue to contain generic string patterns -type TagValue String (pattern="[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:,\\/-]*"); +type TagValue String (pattern="[a-zA-Z0-9_:,\\/][a-zA-Z0-9_:%,\\/-]*"); //A compound value of TagValue type TagCompoundValue String (pattern="({TagValue}\\.)*{TagValue}"); diff --git a/core/zms/src/test/java/com/yahoo/athenz/zms/ZMSCoreTest.java b/core/zms/src/test/java/com/yahoo/athenz/zms/ZMSCoreTest.java index e95443cfc94..57a9769bccb 100644 --- a/core/zms/src/test/java/com/yahoo/athenz/zms/ZMSCoreTest.java +++ b/core/zms/src/test/java/com/yahoo/athenz/zms/ZMSCoreTest.java @@ -2707,6 +2707,10 @@ public void testTagValueList() { tvl = new TagValueList().setList(Collections.singletonList("/homes/home/")); resultTvl = validator.validate(tvl, "TagValueList"); assertTrue(resultTvl.valid); + + tvl = new TagValueList().setList(Collections.singletonList("/home%test")); + resultTvl = validator.validate(tvl, "TagValueList"); + assertTrue(resultTvl.valid); } private UserAuthorityAttributeMap getUserAuthorityAttributeMapForTest() {