Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
spring-cloud__spring-cloud-config_CVE-2020-5405_2-1-6-RELEASE — 分布式系统的集中配置服务器,提供HTTP API、属性加密/解密,并支持Git、Vault、JDBC和本地文件系统后端。 | Kitploit
工具/GitHubGitHub/shoucheng3/spring-cloud__spring-cloud-config_cve-2020-5405_2-1-6-release
身份验证与授权加密/解密工具配置审计云安全DevSecOpsAPI 安全
GitHubshoucheng3/spring-cloud__spring-cloud-config_cve-2020-5405_2-1-6-release

spring-cloud__spring-cloud-config_CVE-2020-5405_2-1-6-RELEASE

分布式系统的集中配置服务器,提供HTTP API、属性加密/解密,并支持Git、Vault、JDBC和本地文件系统后端。

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
查看仓库
51年前尚未审核

//// 请勿编辑此文件。此文件是自动生成的。 对此文件的手动更改将在重新生成时丢失。 请编辑 src/main/asciidoc/ 目录下的文件。 ////

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"]

Spring Cloud Config 在分布式系统中为外部化配置提供服务器端和客户端的支持。通过 Config Server,您可以集中管理所有环境中应用程序的外部属性。客户端和服务器的概念与 Spring 的 Environment 和 PropertySource 抽象完全一致,因此它们非常适合 Spring 应用程序,但也可以与任何语言编写的任何应用程序一起使用。当应用程序通过部署管道从开发环境到测试环境再到生产环境时,您可以管理这些环境之间的配置,并确保应用程序在迁移时拥有运行所需的一切。服务器存储后端的默认实现使用 git,因此它易于支持配置环境的标记版本,并且可以被广泛的工具用于管理内容。添加替代实现并通过 Spring 配置插入它们也很容易。

== 特性

=== Spring Cloud Config Server

Spring Cloud Config Server 提供以下好处:

  • 基于 HTTP 资源的外部配置 API(名称-值对或等效的 YAML 内容)
  • 加密和解密属性值(对称或非对称)
  • 可通过 @EnableConfigServer 轻松嵌入到 Spring Boot 应用程序中

=== Spring Cloud Config Client

特别针对 Spring 应用程序,Spring Cloud Config Client 让您可以:

  • 绑定到 Config Server 并使用远程属性源初始化 Spring Environment。
  • 加密和解密属性值(对称或非对称)。
  • 使用 @RefreshScope 注解 Spring @Bean,以便在配置更改时重新初始化。
  • 使用管理端点: ** /env 用于更新 Environment 并重新绑定 @ConfigurationProperties 和日志级别。 ** /refresh 用于刷新 @RefreshScope bean。 ** /restart 用于重启 Spring 上下文(默认禁用)。 ** /pause 和 /resume 用于调用 Lifecycle 方法(在 ApplicationContext 上调用 stop() 和 )。

== 快速开始

本快速开始将逐步演示如何使用 Spring Cloud Config Server 的服务器和客户端。

首先,启动服务器,如下所示:

root@kitploit:~
$ cd spring-cloud-config-server
$ ../mvnw spring-boot:run

服务器是一个 Spring Boot 应用程序,因此您也可以从 IDE 中运行它(主类是 ConfigServerApplication)。

接下来,尝试一个客户端,如下所示:

root@kitploit:~
$ curl localhost:8888/foo/development
{"name":"foo","label":"master","propertySources":[
  {"name":"https://github.com/scratches/config-repo/foo-development.properties","source":{"bar":"spam"}},
  {"name":"https://github.com/scratches/config-repo/foo.properties","source":{"foo":"bar"}}
]}

定位属性源的默认策略是克隆一个 git 仓库(在 spring.cloud.config.server.git.uri 中指定),并用它来初始化一个迷你 SpringApplication。迷你应用程序的 Environment 用于枚举属性源,并在 JSON 端点上发布它们。

HTTP 服务具有以下形式的资源:

root@kitploit:~
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties

其中 application 被注入为 SpringApplication 中的 spring.config.name(在常规 Spring Boot 应用中通常是 application),profile 是一个激活的配置文件(或逗号分隔的属性列表),label 是可选的 git 标签(默认为 master)。

Spring Cloud Config Server 从各种源拉取远程客户端的配置。以下示例从一个 git 仓库(必须提供)获取配置,如下所示:

[source,yaml]

root@kitploit:~
spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo

其他源包括任何 JDBC 兼容的数据库、Subversion、Hashicorp Vault、Credhub 和本地文件系统。

=== 客户端使用

要在应用程序中使用这些功能,您可以将其构建为依赖 spring-cloud-config-client 的 Spring Boot 应用程序(例如,请参阅 config-client 的测试用例或示例应用程序)。添加依赖最方便的方式是使用 Spring Boot 启动器 org.springframework.cloud:spring-cloud-starter-config。此外,还有针对 Maven 用户的父 pom 和 BOM(spring-cloud-starter-parent),以及针对 Gradle 和 Spring CLI 用户的 Spring IO 版本管理属性文件。以下示例显示了一个典型的 Maven 配置:

[source,xml,indent=0] .pom.xml

root@kitploit:~
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>{spring-boot-docs-version}</version>
        <relativePath /> <!-- 从仓库查找父级 -->
    </parent>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>{spring-cloud-version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
		</plugins>
	</build>

    <!-- 快照和里程碑也需要仓库 -->

现在您可以创建一个标准的 Spring Boot 应用程序,例如以下 HTTP 服务器:

root@kitploit:~
@SpringBootApplication
@RestController
public class Application {

    @RequestMapping("/")
    public String home() {
        return "Hello World!";
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

当此 HTTP 服务器运行时,它会从默认的本地配置服务器(如果正在运行)的 8888 端口获取外部配置。要修改启动行为,您可以通过 bootstrap.properties(类似于 application.properties,但用于应用程序上下文的引导阶段)更改配置服务器的位置,如下所示:

root@kitploit:~
spring.cloud.config.uri: http://myconfigserver.com

默认情况下,如果未设置应用程序名称,将使用 application。要修改名称,可以在 bootstrap.properties 文件中添加以下属性:

root@kitploit:~
spring.application.name: myapp

注意:当设置属性 ${spring.application.name} 时,请不要在应用程序名称前加上保留字 application-,以防止解决正确的属性源时出现问题。

引导属性在 /env 端点中作为高优先级属性源出现,如下例所示:

root@kitploit:~
$ curl localhost:8080/env
{
  "profiles":[],
  "configService:https://github.com/spring-cloud-samples/config-repo/bar.properties":{"foo":"bar"},
  "servletContextInitParams":{},
  "systemProperties":{...},
  ...
}

一个名为 configService:<远程仓库 URL>/<文件名> 的属性源包含值为 bar 的 foo 属性,并且具有最高优先级。

注意:属性源名称中的 URL 是 git 仓库,而不是配置服务器 URL。

=== 示例应用程序

您可以在此处找到示例应用程序:https://github.com/spring-cloud/spring-cloud-config/tree/master/spring-cloud-config-sample[链接]。它是一个 Spring Boot 应用程序,因此您可以使用常规机制(例如 mvn spring-boot:run)运行它。运行时,它会在 http://localhost:8888(一个可配置的默认值)上查找配置服务器,因此您也可以同时运行服务器以查看它们一起工作的情况。

示例中有一个测试用例,其中配置服务器也在同一个 JVM 中启动(使用不同的端口),并且测试断言来自 git 配置仓库的环境属性存在。要更改配置服务器的位置,您可以在 bootstrap.yml(或系统属性和其他位置)中设置 spring.cloud.config.uri。

测试用例有一个 main() 方法,它以相同的方式运行服务器(查看日志以了解其端口),因此您可以在一个进程中运行整个系统并进行试验(例如,您可以在 IDE 中运行 main() 方法)。main() 方法使用 target/config 作为 git 仓库的工作目录,因此您可以在那里进行本地更改,并看到这些更改反映在运行中的应用程序中。以下示例显示了调整测试用例的会话:

root@kitploit:~
$ curl localhost:8080/env/sample
mytest
$ vi target/config/mytest.properties
.. 将 "sample" 的值改为新值,可以选择提交
$ curl localhost:8080/refresh
["sample"]
$ curl localhost:8080/env/sample
sampleValue

刷新端点报告 "sample" 属性已更改。

== 构建

:jdkversion: 1.7

=== 基本编译与测试

要构建源代码,您需要安装 JDK {jdkversion}。

Spring Cloud 使用 Maven 进行大多数构建相关活动,您应该能够通过克隆您感兴趣的项目并输入以下命令快速开始:

root@kitploit:~
$ ./mvnw install

注意:您也可以自己安装 Maven (>=3.3.3) 并在以下示例中运行 mvn 命令代替 ./mvnw。如果这样做,您还可能需要添加 -P spring,如果您的本地 Maven 设置不包含 spring 预发布工件的仓库声明。

注意:请注意,您可能需要通过设置 MAVEN_OPTS 环境变量,值类似于 -Xmx512m -XX:MaxPermSize=128m,来增加 Maven 可用的内存量。我们尝试在 .mvn 配置中覆盖这一点,因此如果您发现必须这样做才能使构建成功,请提交票据以将设置添加到源代码控制。

关于如何构建项目的提示,请查看 .travis.yml(如果有)。应该有一个 "script" 命令,可能还有 "install" 命令。还要查看 "services" 部分,了解是否需要本地运行某些服务(例如 mongo 或 rabbit)。忽略您在 "before_install" 中可能找到的与 git 相关的内容,因为它们与设置 git 凭据有关,而您已经拥有这些凭据。

需要中间件的项目通常包含一个 docker-compose.yml,因此请考虑使用 https://docs.docker.com/compose/[Docker Compose] 在 Docker 容器中运行中间件服务器。请参阅 https://github.com/spring-cloud-samples/scripts[scripts 演示仓库] 中的 README,了解关于 mongo、rabbit 和 redis 常见情况的具体说明。

注意:如果其他方法都失败了,请使用 .travis.yml 中的命令构建(通常是 ./mvnw install)。

=== 文档

spring-cloud-build 模块有一个 "docs" 配置文件,如果启用它,它将尝试从 src/main/asciidoc 构建 asciidoc 源。作为该过程的一部分,它将查找 README.adoc 并通过加载所有包含项来处理它,但不会解析或渲染它,只是将其复制到 ${main.basedir}(默认为 ${basedir},即项目的根目录)。如果 README 有任何更改,那么在进行 Maven 构建后,它将以修改后的文件形式出现在正确的位置。只需提交并推送更改。

=== 使用代码进行工作 如果您没有 IDE 偏好,我们建议您在处理代码时使用 https://www.springsource.com/developer/sts[Spring Tools Suite] 或 https://eclipse.org[Eclipse]。我们使用 https://eclipse.org/m2e/[m2eclipse] eclipse 插件进行 maven 支持。只要支持 Maven 3.3.3 或更好,其他 IDE 和工具也应该正常工作。

==== 使用 m2eclipse 导入到 eclipse 我们推荐使用 https://eclipse.org/m2e/[m2eclipse] eclipse 插件来处理 eclipse。如果您还没有安装 m2eclipse,可以从 "eclipse marketplace" 获取。

注意:较旧版本的 m2e 不支持 Maven 3.3,因此将项目导入 Eclipse 后,您还需要告诉 m2eclipse 使用正确的配置文件。如果您看到许多与项目中的 POM 相关的不同错误,请检查您的安装是否是最新的。如果您无法升级 m2e,请将 "spring" 配置文件添加到您的 settings.xml。或者,您可以将父 pom 的 "spring" 配置文件中的仓库设置复制到您的 settings.xml 中。

==== 不使用 m2eclipse 导入到 eclipse 如果您不想使用 m2eclipse,可以使用以下命令生成 eclipse 项目元数据:

[indent=0]

root@kitploit:~
	$ ./mvnw eclipse:eclipse

生成的项目可以通过从 文件 菜单中选择 导入现有项目 来导入。

=== JCE

如果您遇到 "密钥长度非法" 异常并且使用的是 Sun 的 JDK,则需要安装 Java 密码扩展 (JCE) 无限强度权限策略文件。有关详细信息,请参阅以下链接:

https://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html[Java 6 JCE]

https://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html[Java 7 JCE]

https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html[Java 8 JCE]

将 JCE 文件解压到您所使用的 JRE/JDK x64/x86 版本的 JDK/jre/lib/security 文件夹中。

== 贡献

:spring-cloud-build-branch: master

Spring Cloud 在非限制性 Apache 2.0 许可下发布,并遵循非常标准的 Github 开发流程,使用 Github 跟踪器处理问题,并将拉取请求合并到 master 分支。如果您想贡献哪怕是很小的内容,请不要太犹豫,但请遵循以下准则。

=== 签署贡献者许可协议 在接受到非微不足道的补丁或拉取请求之前,我们需要您签署 https://cla.pivotal.io/sign/spring[贡献者许可协议]。签署贡献者协议并不会授予任何人对主仓库的提交权,但这意味着我们可以接受您的贡献,并且如果您这样做,您将获得作者信用。活跃的贡献者可能会被邀请加入核心团队,并有权合并拉取请求。

=== 行为准则 本项目遵守贡献者公约 https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[行为准则]。通过参与,您应遵守此准则。请将不可接受的行为报告至 [email protected]。

=== 代码规范与内务处理 这些并非拉取请求的必要条件,但都会有所帮助。它们也可以在原始拉取请求之后但在合并之前添加。

  • 使用 Spring Framework 代码格式约定。如果您使用 Eclipse,可以通过 https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring Cloud Build] 项目中的 eclipse-code-formatter.xml 文件导入格式化设置。如果使用 IntelliJ,可以使用 https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter Plugin] 导入同一个文件。
  • 确保所有新的 .java 文件都有简单的 Javadoc 类注释,至少包含标识您的 @author 标签,并且最好至少有一段关于该类用途的描述。
  • 为所有新的 .java 文件添加 ASF 许可头注释(从项目中的现有文件复制)。
  • 如果对 .java 文件进行了实质性修改(不仅仅是装饰性更改),请在文件中添加自己作为 @author。
  • 添加一些 Javadoc,如果更改了命名空间,则添加一些 XSD 文档元素。
  • 一些单元测试也会很有帮助 —— 必须有人来做。
  • 如果没有其他人使用您的分支,请将其变基到当前的 master 分支(或主项目中的其他目标分支)。
  • 编写提交消息时,请遵循 https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[这些约定],如果您修复某个现有问题,请在提交消息末尾添加 Fixes gh-XXXX(其中 XXXX 是问题编号)。

=== Checkstyle

Spring Cloud Build 附带一组 checkstyle 规则。您可以在 spring-cloud-build-tools 模块中找到它们。该模块下最值得注意的文件是:

.spring-cloud-build-tools/

root@kitploit:~
└── src
    ├── checkstyle
    │   └── checkstyle-suppressions.xml <3>
    └── main
        └── resources
            ├── checkstyle-header.txt <2>
            └── checkstyle.xml <1>

<1> 默认 Checkstyle 规则 <2> 文件头设置 <3> 默认抑制规则

==== Checkstyle 配置

Checkstyle 规则默认禁用。要为您的项目添加 checkstyle,只需定义以下属性和插件。

.pom.xml

root@kitploit:~
<properties>
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError> <1>
        <maven-checkstyle-plugin.failsOnViolation>true
        </maven-checkstyle-plugin.failsOnViolation> <2>
        <maven-checkstyle-plugin.includeTestSourceDirectory>true
        </maven-checkstyle-plugin.includeTestSourceDirectory> <3>
</properties>

<build>
        <plugins>
            <plugin> <4>
                <groupId>io.spring.javaformat</groupId>
                <artifactId>spring-javaformat-maven-plugin</artifactId>
            </plugin>
            <plugin> <5>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>

    <reporting>
        <plugins>
            <plugin> <5>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
</build>

<1> 在 Checkstyle 错误时使构建失败 <2> 在 Checkstyle 违规时使构建失败 <3> Checkstyle 也分析测试源 <4> 添加 Spring Java Format 插件,它会重新格式化您的代码以通过大部分 Checkstyle 格式化规则 <5> 将 checkstyle 插件添加到您的构建和报告阶段

如果您需要抑制某些规则(例如,需要更长的行长度),那么您只需在 ${project.root}/src/checkstyle/checkstyle-suppressions.xml 中定义一个文件,并在其中包含您的抑制规则。示例:.projectRoot/src/checkstyle/checkstyle-suppresions.xml

----

建议将 ${spring-cloud-build.rootFolder}/.editorconfig 和 ${spring-cloud-build.rootFolder}/.springformat 复制到你的项目中。这样,一些默认的格式规则就会被应用。你可以通过运行以下脚本来完成此操作:```bash $ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig $ touch .springformat

root@kitploit:~
=== IDE 设置

==== Intellij IDEA

要设置 Intellij,你需要导入我们的编码规范、检查配置文件并设置 checkstyle 插件。
以下文件可以在 https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] 项目中找到。

.spring-cloud-build-tools/
----
└── src
    ├── checkstyle
    │   └── checkstyle-suppressions.xml <3>
    └── main
        └── resources
            ├── checkstyle-header.txt <2>
            ├── checkstyle.xml <1>
            └── intellij
                ├── Intellij_Project_Defaults.xml <4>
                └── Intellij_Spring_Boot_Java_Conventions.xml <5>
----
<1> 默认 Checkstyle 规则
<2> 文件头部设置
<3> 默认抑制规则
<4> Intellij 项目默认设置,应用大部分 Checkstyle 规则
<5> Intellij 项目风格约定,应用大部分 Checkstyle 规则

.代码风格

image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style]

转到 `File` -> `Settings` -> `Editor` -> `Code style`。点击 `Scheme` 部分旁边的图标,然后点击 `Import Scheme` 值,选择 `Intellij IDEA code style XML` 选项。导入 `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` 文件。

.检查配置文件

image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style]

转到 `File` -> `Settings` -> `Editor` -> `Inspections`。点击 `Profile` 部分旁边的图标,然后点击 `Import Profile`,导入 `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` 文件。

.Checkstyle

要让 Intellij 配合 Checkstyle 工作,你需要安装 `Checkstyle` 插件。建议同时安装 `Assertions2Assertj` 以自动转换 JUnit 断言。

image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle]

转到 `File` -> `Settings` -> `Other settings` -> `Checkstyle`。在 `Configuration file` 部分点击 `+` 图标。然后你需要定义从哪里获取 checkstyle 规则。在上图中,我们从克隆的 Spring Cloud Build 仓库中获取了规则。然而,你也可以指向 Spring Cloud Build 的 GitHub 仓库(例如,对于 `checkstyle.xml`:`https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`)。我们需要提供以下变量:

- `checkstyle.header.file` - 请指向 Spring Cloud Build 的 `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` 文件,可以是你的克隆仓库中的路径,或者通过 `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL。
- `checkstyle.suppressions.file` - 默认抑制规则。请指向 Spring Cloud Build 的 `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` 文件,可以是你的克隆仓库中的路径,或者通过 `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL。
- `checkstyle.additional.suppressions.file` - 此变量对应你本地项目中的抑制规则。例如,你正在开发 `spring-cloud-contract`,则指向 `project-root/src/checkstyle/checkstyle-suppressions.xml` 文件夹。以 `spring-cloud-contract` 为例:`/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`。

重要:请记得将 `Scan Scope` 设置为 `All sources`,因为我们同时将 checkstyle 规则应用于生产代码和测试代码。
下载工具
start()
  • 引导应用程序上下文:主应用程序的父上下文,可被训练执行任何操作(默认情况下,它绑定到 Config Server 并解密属性值)。