Skip to content

Commit

Permalink
Narrow criteria for hidden property paths
Browse files Browse the repository at this point in the history
A previous change intended to prevent temporary directories created as
an implementation detail of mounting volumes on kubernetes pods from
being used as a source for property files had a side-effect of also
preventing other types of hidden directories from being recognized. This
commit narrows the criteria for considering a directory as hidden,
using the kubernetes `..` prefix convention instead of the Unix `.`
prefix.

Fixes gh-23983
  • Loading branch information
scottfrederick committed Nov 4, 2020
1 parent fdd028d commit 62aa1b7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
Expand Up @@ -569,7 +569,7 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
private boolean hasHiddenPathElement(Resource resource) throws IOException {
String cleanPath = StringUtils.cleanPath(resource.getFile().getAbsolutePath());
for (Path value : Paths.get(cleanPath)) {
if (value.toString().startsWith(".")) {
if (value.toString().startsWith("..")) {
return true;
}
}
Expand Down

2 comments on commit 62aa1b7

@skloessel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be better to call the method "hasTempPathElement" or "hasK8sHiddenPathElement"?
Hidden path elements should not be prevented.

@bo0ts
Copy link

@bo0ts bo0ts commented on 62aa1b7 Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a fix for the problem. We have a custom script that collects mounted configmaps in k8s and resolves paths. This results in config locations like: /config/autoloaded/our-app/..2020_10_27_21_10_29.797568129/application.properties This happens because everything not in ..DATE is a symlink.

Please sign in to comment.