You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2021/07/30 04:49:21 UTC

[sling-org-apache-sling-feature-extension-apiregions] branch master updated: SLING-10687 : Don't log values when validating secrets

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-extension-apiregions.git


The following commit(s) were added to refs/heads/master by this push:
     new 07aa828  SLING-10687 : Don't log values when validating secrets
07aa828 is described below

commit 07aa82827e640c7b4e3f590271b7ef717c06495e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jul 30 06:49:02 2021 +0200

    SLING-10687 : Don't log values when validating secrets
---
 .../api/config/validation/PropertyValidator.java     | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java b/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
index 6a586de..5617b9a 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
@@ -181,7 +181,7 @@ public class PropertyValidator {
                     }
                 }
                 if ( found ) {
-                    setResult(context, desc, "Required excluded value " + exc + " found");
+                    setResult(context, desc, "Not allowed excluded value " + exc + " found");
                 }
             }
         }
@@ -189,7 +189,7 @@ public class PropertyValidator {
 
     private static final List<String> PLACEHOLDERS = Arrays.asList("$[env:", "$[secret:", "$[prop:");
 
-	void validateValue(final Context context, final DescribableEntity desc, final Object value) {
+	void validateValue(final Context context, final PropertyDescription desc, final Object value) {
 		if ( value != null ) {
             // check for placeholder
             boolean hasPlaceholder = false;
@@ -472,15 +472,19 @@ public class PropertyValidator {
 		}
 	}
 
-    void validateRegex(final Context context, final DescribableEntity desc, final Pattern pattern, final Object value) {
+    void validateRegex(final Context context, final PropertyDescription desc, final Pattern pattern, final Object value) {
         if ( pattern != null ) {
             if ( !pattern.matcher(value.toString()).matches() ) {
-                setResult(context, desc, "Value " + value + " does not match regex " + pattern.pattern());
+                if ( desc.getType() == PropertyType.PASSWORD ) {
+                    setResult(context, desc, "Value does not match regex " + pattern.pattern());
+                } else {
+                    setResult(context, desc, "Value " + value + " does not match regex " + pattern.pattern());
+                }
             }
         }
     }
 
-    void validateOptions(final Context context, final DescribableEntity desc, final Object value) {
+    void validateOptions(final Context context, final PropertyDescription desc, final Object value) {
         if ( context.description.getOptions() != null ) {
             boolean found = false;
             for(final Option opt : context.description.getOptions()) {
@@ -489,7 +493,11 @@ public class PropertyValidator {
                 }
             }
             if ( !found ) {
-                setResult(context, desc, "Value " + value + " does not match provided options");
+                if ( desc.getType() == PropertyType.PASSWORD ) {
+                    setResult(context, desc, "Value does not match provided options");
+                } else {
+                    setResult(context, desc, "Value " + value + " does not match provided options");
+                }
             }
         }
     }