From f470b52f1bb52bedac984c2101bea9a3ac52e2e7 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Tue, 26 May 2020 15:28:18 -0400 Subject: [PATCH 1/7] Verifies resources are in allowed locations --- .../resource/GenericResourceRepository.java | 21 +++--- .../config/server/support/PathUtils.java | 72 +++++++++++++++++++ .../GenericResourceRepositoryTests.java | 11 +++ 3 files changed, 96 insertions(+), 8 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/GenericResourceRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/GenericResourceRepository.java index 87b89764..667827fc 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/GenericResourceRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/GenericResourceRepository.java @@ -17,6 +17,7 @@ package org.springframework.cloud.config.server.resource; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; @@ -56,18 +57,22 @@ public class GenericResourceRepository if (StringUtils.hasText(path)) { String[] locations = this.service.getLocations(application, profile, label) .getLocations(); + ArrayList locationResources = new ArrayList<>(); + for (int i = locations.length; i-- > 0;) { + String location = locations[i]; + if (!PathUtils.isInvalidEncodedLocation(location)) { + locationResources.add(this.resourceLoader.getResource(location)); + } + } + try { - for (int i = locations.length; i-- > 0;) { - String location = locations[i]; - if (PathUtils.isInvalidEncodedLocation(location)) { - continue; - } + for (Resource location : locationResources) { for (String local : getProfilePaths(profile, path)) { if (!PathUtils.isInvalidPath(local) && !PathUtils.isInvalidEncodedPath(local)) { - Resource file = this.resourceLoader.getResource(location) - .createRelative(local); - if (file.exists() && file.isReadable()) { + Resource file = location.createRelative(local); + if (file.exists() && file.isReadable() && PathUtils + .checkResource(file, location, locationResources)) { return file; } } diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/PathUtils.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/PathUtils.java index e6bb0f99..3102aad3 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/PathUtils.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/PathUtils.java @@ -16,12 +16,17 @@ package org.springframework.cloud.config.server.support; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; @@ -205,4 +210,71 @@ public abstract class PathUtils { return false; } + /** + * Perform additional checks on a resolved resource beyond checking whether the + * resources exists and is readable. The default implementation also verifies the + * resource is either under the location relative to which it was found or is under + * one of the {@link #setAllowedLocations allowed locations}. + * @param resource the resource to check + * @param location the location relative to which the resource was found + * @param allowedLocations set of allowed locations + * @return "true" if resource is in a valid location, "false" otherwise. + * @throws IOException if Resource URLS fail to parse. + * @since 4.1.2 + */ + public static boolean checkResource(Resource resource, Resource location, + List allowedLocations) throws IOException { + if (isResourceUnderLocation(resource, location)) { + return true; + } + if (allowedLocations != null) { + for (Resource current : allowedLocations) { + if (isResourceUnderLocation(resource, current)) { + return true; + } + } + } + if (logger.isWarnEnabled()) { + logger.warn("Resource path \"" + location.getURI() + + "\" was successfully resolved " + "but resource \"" + + resource.getURL() + "\" is neither under the " + + "current location \"" + location.getURL() + + "\" nor under any of the " + "allowed locations " + + (allowedLocations != null ? allowedLocations : "[]")); + } + return false; + } + + private static boolean isResourceUnderLocation(Resource resource, Resource location) + throws IOException { + if (resource.getClass() != location.getClass()) { + return false; + } + + String resourcePath; + String locationPath; + + if (resource instanceof UrlResource) { + resourcePath = resource.getURL().toExternalForm(); + locationPath = StringUtils.cleanPath(location.getURL().toString()); + } + else if (resource instanceof ClassPathResource) { + resourcePath = ((ClassPathResource) resource).getPath(); + locationPath = StringUtils + .cleanPath(((ClassPathResource) location).getPath()); + } + else { + resourcePath = resource.getURL().getPath(); + locationPath = StringUtils.cleanPath(location.getURL().getPath()); + } + + if (locationPath.equals(resourcePath)) { + return true; + } + locationPath = (locationPath.endsWith("/") || locationPath.isEmpty() + ? locationPath : locationPath + "/"); + return (resourcePath.startsWith(locationPath) + && !isInvalidEncodedPath(resourcePath)); + } + } diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/GenericResourceRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/GenericResourceRepositoryTests.java index f333c0d7..062a2c36 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/GenericResourceRepositoryTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/resource/GenericResourceRepositoryTests.java @@ -120,6 +120,17 @@ public class GenericResourceRepositoryTests { testInvalidPath("%2E%2E%2F"); } + @Test + public void invalidPathEncodedSlash() { + String file = System.getProperty("user.dir"); + file = file.replaceFirst("\\/", "%2f"); + file += "/src/test/resources/ssh/key"; + this.exception.expect(NoSuchResourceException.class); + this.nativeRepository.setSearchLocations("file:./"); + this.output.expect(containsString("is neither under the current location")); + this.repository.findOne("blah", "local", "master", file); + } + private void testInvalidPath(String label) { this.exception.expect(NoSuchResourceException.class); this.nativeRepository.setSearchLocations("file:./src/test/resources/test/local"); From 5d5a1925d0dc73cd3328230cdd3910038da37757 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Wed, 27 May 2020 15:16:38 -0400 Subject: [PATCH 2/7] formatting --- .../config/server/environment/EnvironmentControllerTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/EnvironmentControllerTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/EnvironmentControllerTests.java index 167160b9..cd1a1eb0 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/EnvironmentControllerTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/EnvironmentControllerTests.java @@ -439,8 +439,7 @@ public class EnvironmentControllerTests { String text = this.controller.properties("foo", "bar", true).getBody(); Properties properties = new Properties(); properties.load(new StringReader(text)); - assertThat(properties).containsOnly(entry("a.b.c", "bar"), - entry("foo", "bar")); + assertThat(properties).containsOnly(entry("a.b.c", "bar"), entry("foo", "bar")); } @Test From 39264d6ba04609838d912e503662de16937ec4bf Mon Sep 17 00:00:00 2001 From: buildmaster Date: Thu, 28 May 2020 17:21:41 +0000 Subject: [PATCH 3/7] Update SNAPSHOT to 2.2.3.RELEASE --- README.adoc | 7 ++++++- docs/pom.xml | 2 +- pom.xml | 6 +++--- spring-cloud-config-client/pom.xml | 2 +- spring-cloud-config-dependencies/pom.xml | 4 ++-- spring-cloud-config-monitor/pom.xml | 4 ++-- spring-cloud-config-sample/pom.xml | 2 +- spring-cloud-config-server/pom.xml | 2 +- spring-cloud-starter-config/pom.xml | 4 ++-- 9 files changed, 19 insertions(+), 14 deletions(-) diff --git a/README.adoc b/README.adoc index 4bace665..b251b1c4 100644 --- a/README.adoc +++ b/README.adoc @@ -190,7 +190,7 @@ $ curl localhost:8080/env } ---- -A property source called ```configService:/` contains the `foo` property with a value of `bar` and is highest priority. +A property source called `configService:/` contains the `foo` property with a value of `bar` and is the highest priority. NOTE: The URL in the property source name is the git repository, not the config server URL. @@ -284,6 +284,11 @@ https://eclipse.org[Eclipse] when working with the code. We use the https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better. +==== Activate the Spring Maven profile +Spring Cloud projects require the 'spring' Maven profile to be activated to resolve +the spring milestone and snapshot repositories. Use your preferred IDE to set this +profile to be active, or you may experience build errors. + ==== Importing into eclipse with m2eclipse We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with eclipse. If you don't already have m2eclipse installed it is available from the "eclipse diff --git a/docs/pom.xml b/docs/pom.xml index e66e7690..8ff1933a 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -8,7 +8,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE .. diff --git a/pom.xml b/pom.xml index 4c316837..618d81b2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE pom Spring Cloud Config Spring Cloud Config @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-build - 2.3.0.BUILD-SNAPSHOT + 2.3.0.RELEASE @@ -27,7 +27,7 @@ config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE 1.11.52 v1-rev20191010-1.30.3 true diff --git a/spring-cloud-config-client/pom.xml b/spring-cloud-config-client/pom.xml index aa3a8513..723a1eed 100644 --- a/spring-cloud-config-client/pom.xml +++ b/spring-cloud-config-client/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE .. diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml index 26050ed6..17e11ec5 100644 --- a/spring-cloud-config-dependencies/pom.xml +++ b/spring-cloud-config-dependencies/pom.xml @@ -6,11 +6,11 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.3.0.BUILD-SNAPSHOT + 2.3.0.RELEASE spring-cloud-config-dependencies - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE pom spring-cloud-config-dependencies Spring Cloud Config Dependencies diff --git a/spring-cloud-config-monitor/pom.xml b/spring-cloud-config-monitor/pom.xml index 89e974aa..214ed7d0 100644 --- a/spring-cloud-config-monitor/pom.xml +++ b/spring-cloud-config-monitor/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE .. spring-cloud-config-monitor @@ -14,7 +14,7 @@ Spring Cloud Config Monitor ${basedir}/../.. - 2.2.2.BUILD-SNAPSHOT + 2.2.2.RELEASE diff --git a/spring-cloud-config-sample/pom.xml b/spring-cloud-config-sample/pom.xml index 3e9b9ac6..d1e2bad3 100644 --- a/spring-cloud-config-sample/pom.xml +++ b/spring-cloud-config-sample/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE .. diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml index be46408a..5baaf411 100644 --- a/spring-cloud-config-server/pom.xml +++ b/spring-cloud-config-server/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE .. diff --git a/spring-cloud-starter-config/pom.xml b/spring-cloud-starter-config/pom.xml index 13156142..99601944 100644 --- a/spring-cloud-starter-config/pom.xml +++ b/spring-cloud-starter-config/pom.xml @@ -6,10 +6,10 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE spring-cloud-starter-config - 2.2.3.BUILD-SNAPSHOT + 2.2.3.RELEASE spring-cloud-starter-config Spring Cloud Starter https://projects.spring.io/spring-cloud From 827ccee470f495bb98161b50222f00df6e3bae05 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Thu, 28 May 2020 17:25:11 +0000 Subject: [PATCH 4/7] Going back to snapshots --- README.adoc | 7 +------ docs/pom.xml | 2 +- pom.xml | 6 +++--- spring-cloud-config-client/pom.xml | 2 +- spring-cloud-config-dependencies/pom.xml | 4 ++-- spring-cloud-config-monitor/pom.xml | 4 ++-- spring-cloud-config-sample/pom.xml | 2 +- spring-cloud-config-server/pom.xml | 2 +- spring-cloud-starter-config/pom.xml | 4 ++-- 9 files changed, 14 insertions(+), 19 deletions(-) diff --git a/README.adoc b/README.adoc index b251b1c4..4bace665 100644 --- a/README.adoc +++ b/README.adoc @@ -190,7 +190,7 @@ $ curl localhost:8080/env } ---- -A property source called `configService:/` contains the `foo` property with a value of `bar` and is the highest priority. +A property source called ```configService:/` contains the `foo` property with a value of `bar` and is highest priority. NOTE: The URL in the property source name is the git repository, not the config server URL. @@ -284,11 +284,6 @@ https://eclipse.org[Eclipse] when working with the code. We use the https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better. -==== Activate the Spring Maven profile -Spring Cloud projects require the 'spring' Maven profile to be activated to resolve -the spring milestone and snapshot repositories. Use your preferred IDE to set this -profile to be active, or you may experience build errors. - ==== Importing into eclipse with m2eclipse We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with eclipse. If you don't already have m2eclipse installed it is available from the "eclipse diff --git a/docs/pom.xml b/docs/pom.xml index 8ff1933a..e66e7690 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -8,7 +8,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT .. diff --git a/pom.xml b/pom.xml index 618d81b2..4c316837 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT pom Spring Cloud Config Spring Cloud Config @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-build - 2.3.0.RELEASE + 2.3.0.BUILD-SNAPSHOT @@ -27,7 +27,7 @@ config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT 1.11.52 v1-rev20191010-1.30.3 true diff --git a/spring-cloud-config-client/pom.xml b/spring-cloud-config-client/pom.xml index 723a1eed..aa3a8513 100644 --- a/spring-cloud-config-client/pom.xml +++ b/spring-cloud-config-client/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT .. diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml index 17e11ec5..26050ed6 100644 --- a/spring-cloud-config-dependencies/pom.xml +++ b/spring-cloud-config-dependencies/pom.xml @@ -6,11 +6,11 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.3.0.RELEASE + 2.3.0.BUILD-SNAPSHOT spring-cloud-config-dependencies - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT pom spring-cloud-config-dependencies Spring Cloud Config Dependencies diff --git a/spring-cloud-config-monitor/pom.xml b/spring-cloud-config-monitor/pom.xml index 214ed7d0..89e974aa 100644 --- a/spring-cloud-config-monitor/pom.xml +++ b/spring-cloud-config-monitor/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT .. spring-cloud-config-monitor @@ -14,7 +14,7 @@ Spring Cloud Config Monitor ${basedir}/../.. - 2.2.2.RELEASE + 2.2.2.BUILD-SNAPSHOT diff --git a/spring-cloud-config-sample/pom.xml b/spring-cloud-config-sample/pom.xml index d1e2bad3..3e9b9ac6 100644 --- a/spring-cloud-config-sample/pom.xml +++ b/spring-cloud-config-sample/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT .. diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml index 5baaf411..be46408a 100644 --- a/spring-cloud-config-server/pom.xml +++ b/spring-cloud-config-server/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT .. diff --git a/spring-cloud-starter-config/pom.xml b/spring-cloud-starter-config/pom.xml index 99601944..13156142 100644 --- a/spring-cloud-starter-config/pom.xml +++ b/spring-cloud-starter-config/pom.xml @@ -6,10 +6,10 @@ org.springframework.cloud spring-cloud-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT spring-cloud-starter-config - 2.2.3.RELEASE + 2.2.3.BUILD-SNAPSHOT spring-cloud-starter-config Spring Cloud Starter https://projects.spring.io/spring-cloud From 035e6f6ed6c6019b0a7dd9b3c6cabe6917bcf19e Mon Sep 17 00:00:00 2001 From: buildmaster Date: Thu, 28 May 2020 17:25:11 +0000 Subject: [PATCH 5/7] Bumping versions to 2.2.4.BUILD-SNAPSHOT after release --- docs/pom.xml | 2 +- pom.xml | 6 +++--- spring-cloud-config-client/pom.xml | 2 +- spring-cloud-config-dependencies/pom.xml | 4 ++-- spring-cloud-config-monitor/pom.xml | 4 ++-- spring-cloud-config-sample/pom.xml | 2 +- spring-cloud-config-server/pom.xml | 2 +- spring-cloud-starter-config/pom.xml | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index e66e7690..9d5bf2c1 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -8,7 +8,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT .. diff --git a/pom.xml b/pom.xml index 4c316837..9eb86ce7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT pom Spring Cloud Config Spring Cloud Config @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-build - 2.3.0.BUILD-SNAPSHOT + 2.3.0.RELEASE @@ -27,7 +27,7 @@ config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT 1.11.52 v1-rev20191010-1.30.3 true diff --git a/spring-cloud-config-client/pom.xml b/spring-cloud-config-client/pom.xml index aa3a8513..a3d7d09d 100644 --- a/spring-cloud-config-client/pom.xml +++ b/spring-cloud-config-client/pom.xml @@ -10,7 +10,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT .. diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml index 26050ed6..fdbc39f1 100644 --- a/spring-cloud-config-dependencies/pom.xml +++ b/spring-cloud-config-dependencies/pom.xml @@ -6,11 +6,11 @@ spring-cloud-dependencies-parent org.springframework.cloud - 2.3.0.BUILD-SNAPSHOT + 2.3.1.BUILD-SNAPSHOT spring-cloud-config-dependencies - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT pom spring-cloud-config-dependencies Spring Cloud Config Dependencies diff --git a/spring-cloud-config-monitor/pom.xml b/spring-cloud-config-monitor/pom.xml index 89e974aa..0884d6c9 100644 --- a/spring-cloud-config-monitor/pom.xml +++ b/spring-cloud-config-monitor/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT .. spring-cloud-config-monitor @@ -14,7 +14,7 @@ Spring Cloud Config Monitor ${basedir}/../.. - 2.2.2.BUILD-SNAPSHOT + 2.2.3.BUILD-SNAPSHOT diff --git a/spring-cloud-config-sample/pom.xml b/spring-cloud-config-sample/pom.xml index 3e9b9ac6..caf749d5 100644 --- a/spring-cloud-config-sample/pom.xml +++ b/spring-cloud-config-sample/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT .. diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml index be46408a..3acd15cc 100644 --- a/spring-cloud-config-server/pom.xml +++ b/spring-cloud-config-server/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT .. diff --git a/spring-cloud-starter-config/pom.xml b/spring-cloud-starter-config/pom.xml index 13156142..c2bc7791 100644 --- a/spring-cloud-starter-config/pom.xml +++ b/spring-cloud-starter-config/pom.xml @@ -6,10 +6,10 @@ org.springframework.cloud spring-cloud-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT spring-cloud-starter-config - 2.2.3.BUILD-SNAPSHOT + 2.2.4.BUILD-SNAPSHOT spring-cloud-starter-config Spring Cloud Starter https://projects.spring.io/spring-cloud From b153f639be69b568a252e0b37bc15066f7813508 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 4 Jun 2020 13:37:28 +0200 Subject: [PATCH 6/7] Migrated to docs.spring.io & updated sc-build --- README.adoc | 62 +++++++++++++----------- docs/pom.xml | 34 +++++++------ docs/src/main/asciidoc/_configprops.adoc | 27 +++++++++++ pom.xml | 2 +- 4 files changed, 81 insertions(+), 44 deletions(-) create mode 100644 docs/src/main/asciidoc/_configprops.adoc diff --git a/README.adoc b/README.adoc index 4bace665..8e329aed 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,7 @@ Manual changes to this file will be lost when it is generated again. Edit the files in the src/main/asciidoc/ directory instead. //// + image::https://circleci.com/gh/spring-cloud/spring-cloud-config/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-config/tree/master"] image::https://codecov.io/gh/spring-cloud/spring-cloud-config/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-config/branch/master"] image::https://api.codacy.com/project/badge/Grade/f064024a072c477e97dca6ed5a70fccd?branch=master["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-config?branch=master&utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-config&utm_campaign=Badge_Grade"] @@ -107,38 +108,38 @@ There is also a parent pom and BOM (`spring-cloud-starter-parent`) for Maven use - - - - org.springframework.cloud - spring-cloud-dependencies - {spring-cloud-version} - pom - import - - - + + + + org.springframework.cloud + spring-cloud-dependencies + {spring-cloud-version} + pom + import + + + - - - org.springframework.cloud - spring-cloud-starter-config - - - org.springframework.boot - spring-boot-starter-test - test - - + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.boot + spring-boot-starter-test + test + + - - + + org.springframework.boot spring-boot-maven-plugin - - + + ---- @@ -190,7 +191,7 @@ $ curl localhost:8080/env } ---- -A property source called ```configService:/` contains the `foo` property with a value of `bar` and is highest priority. +A property source called `configService:/` contains the `foo` property with a value of `bar` and is the highest priority. NOTE: The URL in the property source name is the git repository, not the config server URL. @@ -284,6 +285,11 @@ https://eclipse.org[Eclipse] when working with the code. We use the https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better. +==== Activate the Spring Maven profile +Spring Cloud projects require the 'spring' Maven profile to be activated to resolve +the spring milestone and snapshot repositories. Use your preferred IDE to set this +profile to be active, or you may experience build errors. + ==== Importing into eclipse with m2eclipse We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with eclipse. If you don't already have m2eclipse installed it is available from the "eclipse @@ -504,4 +510,4 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t - `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. - `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. \ No newline at end of file +IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. diff --git a/docs/pom.xml b/docs/pom.xml index 9d5bf2c1..4da29dd3 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -18,40 +18,44 @@ spring-cloud-config ${basedir}/.. - 1.3.x,1.4.x,2.1.x + deploy + spring.cloud.config.* - - - - - maven-deploy-plugin - - true - - - - + + + ${project.groupId} + spring-cloud-starter-config + + docs - org.apache.maven.plugins + pl.project13.maven + git-commit-id-plugin + + maven-dependency-plugin - org.apache.maven.plugins maven-resources-plugin + + org.codehaus.mojo + exec-maven-plugin + org.asciidoctor asciidoctor-maven-plugin - org.apache.maven.plugins maven-antrun-plugin + + maven-deploy-plugin + diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc new file mode 100644 index 00000000..595be92b --- /dev/null +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -0,0 +1,27 @@ +|=== +|Name | Default | Description + +|spring.cloud.config.allow-override | true | Flag to indicate that {@link #isOverrideSystemProperties() systemPropertiesOverride} can be used. Set to false to prevent users from changing the default accidentally. Default true. +|spring.cloud.config.discovery.enabled | false | Flag to indicate that config server discovery is enabled (config server URL will be looked up via discovery). +|spring.cloud.config.discovery.service-id | configserver | Service id to locate config server. +|spring.cloud.config.enabled | true | Flag to say that remote configuration is enabled. Default true; +|spring.cloud.config.fail-fast | false | Flag to indicate that failure to connect to the server is fatal (default false). +|spring.cloud.config.headers | | Additional headers used to create the client request. +|spring.cloud.config.label | | The label name to use to pull remote configuration properties. The default is set on the server (generally "master" for a git based server). +|spring.cloud.config.name | | Name of application used to fetch remote properties. +|spring.cloud.config.override-none | false | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false. +|spring.cloud.config.override-system-properties | true | Flag to indicate that the external properties should override system properties. Default true. +|spring.cloud.config.password | | The password to use (HTTP Basic) when contacting the remote server. +|spring.cloud.config.profile | default | The default profile to use when fetching remote configuration (comma-separated). Default is "default". +|spring.cloud.config.request-connect-timeout | 0 | timeout on waiting to connect to the Config Server. +|spring.cloud.config.request-read-timeout | 0 | timeout on waiting to read data from the Config Server. +|spring.cloud.config.retry.initial-interval | 1000 | Initial retry interval in milliseconds. +|spring.cloud.config.retry.max-attempts | 6 | Maximum number of attempts. +|spring.cloud.config.retry.max-interval | 2000 | Maximum interval for backoff. +|spring.cloud.config.retry.multiplier | 1.1 | Multiplier for next interval. +|spring.cloud.config.send-state | true | Flag to indicate whether to send state. Default true. +|spring.cloud.config.token | | Security Token passed thru to underlying environment repository. +|spring.cloud.config.uri | [http://localhost:8888] | The URI of the remote server (default http://localhost:8888). +|spring.cloud.config.username | | The username to use (HTTP Basic) when contacting the remote server. + +|=== \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9eb86ce7..9b570380 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.springframework.cloud spring-cloud-build - 2.3.0.RELEASE + 2.3.1.BUILD-SNAPSHOT From 4bbb4ca5e4eee32129559c510fa8e61a7e116a7a Mon Sep 17 00:00:00 2001 From: spencergibb Date: Thu, 25 Jun 2020 13:15:04 -0400 Subject: [PATCH 7/7] Removes @Autowired from fields --- ...ntConfigServiceBootstrapConfiguration.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfiguration.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfiguration.java index 4d3815ed..01638336 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfiguration.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/DiscoveryClientConfigServiceBootstrapConfiguration.java @@ -23,7 +23,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -71,20 +70,24 @@ public class DiscoveryClientConfigServiceBootstrapConfiguration { } @Bean - public SmartApplicationListener heartbeatListener( + public SmartApplicationListener heartbeatListener(ConfigClientProperties properties, ConfigServerInstanceProvider provider) { - return new HeartbeatListener(); + return new HeartbeatListener(properties, provider); } - private static class HeartbeatListener implements SmartApplicationListener { + private final static class HeartbeatListener implements SmartApplicationListener { - @Autowired - private ConfigClientProperties config; + private final ConfigClientProperties config; - @Autowired - private ConfigServerInstanceProvider instanceProvider; + private final ConfigServerInstanceProvider instanceProvider; - private HeartbeatMonitor monitor = new HeartbeatMonitor(); + private final HeartbeatMonitor monitor = new HeartbeatMonitor(); + + private HeartbeatListener(ConfigClientProperties config, + ConfigServerInstanceProvider instanceProvider) { + this.config = config; + this.instanceProvider = instanceProvider; + } @Override public boolean supportsEventType(Class eventType) {