Sanitize configuration properties that are nested beneath a List

Closes gh-8197
This commit is contained in:
Andy Wilkinson
2017-02-08 17:21:41 +00:00
parent 05dbc15a9d
commit f27bb39af9
2 changed files with 77 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -239,6 +239,9 @@ public class ConfigurationPropertiesReportEndpoint
if (value instanceof Map) {
map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value));
}
else if (value instanceof List) {
map.put(key, sanitize(qualifiedKey, (List<Object>) value));
}
else {
value = this.sanitizer.sanitize(key, value);
value = this.sanitizer.sanitize(qualifiedKey, value);
@@ -248,6 +251,24 @@ public class ConfigurationPropertiesReportEndpoint
return map;
}
@SuppressWarnings("unchecked")
private List<Object> sanitize(String prefix, List<Object> list) {
List<Object> sanitized = new ArrayList<Object>();
for (Object item : list) {
if (item instanceof Map) {
sanitized.add(sanitize(prefix, (Map<String, Object>) item));
}
else if (item instanceof List) {
sanitize(prefix, (List<Object>) item);
}
else {
item = this.sanitizer.sanitize(prefix, item);
sanitized.add(this.sanitizer.sanitize(prefix, item));
}
}
return sanitized;
}
/**
* Extension to {@link JacksonAnnotationIntrospector} to suppress CGLIB generated bean
* properties.