Skip to content

Commit 9b5e1a7

Browse files
authored
AMBARI-26555: Password leaked for configurations at stack root (e.g. cluster-env.xml) (#4086)
1 parent 1222f31 commit 9b5e1a7

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

  • ambari-server/src/main/java/org/apache/ambari/server/state

ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -513,27 +513,44 @@ public Map<String, PropertyInfo> getRequiredProperties() {
513513
}
514514

515515
public Map<PropertyInfo.PropertyType, Set<String>> getConfigPropertiesTypes(String configType) {
516-
if(!propertiesTypesCache.containsKey(configType)) {
516+
if (!propertiesTypesCache.containsKey(configType)) {
517517
Map<PropertyInfo.PropertyType, Set<String>> propertiesTypes = new HashMap<>();
518+
519+
collectPropertyTypes(propertiesTypes, getProperties(), configType);
520+
518521
Collection<ServiceInfo> services = getServices();
519522
for (ServiceInfo serviceInfo : services) {
520-
for (PropertyInfo propertyInfo : serviceInfo.getProperties()) {
521-
if (propertyInfo.getFilename().contains(configType) && !propertyInfo.getPropertyTypes().isEmpty()) {
522-
Set<PropertyInfo.PropertyType> types = propertyInfo.getPropertyTypes();
523-
for (PropertyInfo.PropertyType propertyType : types) {
524-
if (!propertiesTypes.containsKey(propertyType)) {
525-
propertiesTypes.put(propertyType, new HashSet<>());
526-
}
527-
propertiesTypes.get(propertyType).add(propertyInfo.getName());
528-
}
529-
}
530-
}
523+
collectPropertyTypes(propertiesTypes, serviceInfo.getProperties(), configType);
531524
}
532525
propertiesTypesCache.put(configType, propertiesTypes);
533526
}
534527
return propertiesTypesCache.get(configType);
535528
}
536529

530+
private void collectPropertyTypes(Map<PropertyInfo.PropertyType, Set<String>> target,
531+
Collection<PropertyInfo> sources,
532+
String configType) {
533+
if (sources == null) {
534+
return;
535+
}
536+
537+
for (PropertyInfo propertyInfo : sources) {
538+
String filename = propertyInfo.getFilename();
539+
if (filename == null || !filename.contains(configType)) {
540+
continue;
541+
}
542+
543+
Set<PropertyInfo.PropertyType> types = propertyInfo.getPropertyTypes();
544+
if (types == null || types.isEmpty()) {
545+
continue;
546+
}
547+
548+
for (PropertyInfo.PropertyType propertyType : types) {
549+
target.computeIfAbsent(propertyType, key -> new HashSet<>()).add(propertyInfo.getName());
550+
}
551+
}
552+
}
553+
537554
/**
538555
* Return default config attributes for specified config type.
539556
* @param configType config type

0 commit comments

Comments
 (0)