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

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

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

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

工具目录

分类

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

spring-cloud__spring-cloud-config_CVE-2020-5410_2-1-8-RELEASE

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

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

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

//// 请勿编辑此文件。它是自动生成的。 对此文件的手动更改将在重新生成时丢失。 请改为编辑 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 为分布式系统中的外部化配置提供了服务端和客户端支持。通过配置服务器,您可以集中管理所有环境中应用程序的外部属性。 客户端和服务端的概念与 Spring 的 Environment 和 PropertySource 抽象完全一致,因此它们非常适合 Spring 应用程序,也可以与任何语言运行的任何应用程序一起使用。 当应用程序通过部署管道从开发环境到测试环境再到生产环境时,您可以管理这些环境之间的配置,并确保应用程序在迁移时拥有运行所需的一切。 服务器存储后端的默认实现使用 git,因此它轻松支持配置环境的带标签版本,并且可以被广泛的内容管理工具访问。 添加替代实现并利用 Spring 配置将它们集成起来非常容易。

== 特性

=== Spring Cloud Config 服务端

Spring Cloud Config 服务端提供以下优势:

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

=== Spring Cloud Config 客户端

特别针对 Spring 应用程序,Spring Cloud Config 客户端让您能够:

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

== 快速开始

本快速入门将逐步介绍如何使用 Spring Cloud Config 的服务端和客户端。

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


$ cd spring-cloud-config-server $ ../mvnw spring-boot:run

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

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


$ 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 服务具有以下形式的资源:


/{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 是一个激活的 profile(或以逗号分隔的属性列表),label 是一个可选的 git 标签(默认为 master)。

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

[source,yaml]

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 starter 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 /> <!-- lookup parent from repository -->
</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>

<!-- repositories also needed for snapshots and milestones -->

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


@SpringBootApplication @RestController public class Application {

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

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

}

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


spring.cloud.config.uri: http://myconfigserver.com

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


spring.application.name: myapp

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

引导属性会在 /env 端点中以高优先级属性源的形式显示,如下例所示。


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

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

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

=== 示例应用程序

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

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

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


$ curl localhost:8080/env/sample mytest $ vi target/config/mytest.properties .. change value of "sample", optionally commit $ curl localhost:8080/refresh ["sample"] $ curl localhost:8080/env/sample sampleValue

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

== 构建

:jdkversion: 1.7

=== 基本编译和测试

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

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


$ ./mvnw install

注意:您也可以自行安装 Maven(>=3.3.3)并在下面的示例中使用 mvn 命令代替 ./mvnw。如果这样做,并且您的本地 Maven 设置不包含用于 Spring 预发布工件的仓库声明,您可能还需要添加 -P 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" profile,如果启用它,它将尝试从 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 为项目使用正确的 profile。如果您在项目中看到许多与 POM 相关的错误,请检查您是否拥有最新的安装。如果无法升级 m2e,请将 "spring" profile 添加到您的 settings.xml 中。或者,您可以将父 pom 的 "spring" profile 中的仓库设置复制到您的 settings.xml 中。

==== 不使用 m2eclipse 导入到 Eclipse 如果您更倾向于不使用 m2eclipse,您可以使用以下命令生成 Eclipse 项目元数据:

[indent=0]

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

生成的 Eclipse 项目可以通过从 file 菜单中选择 import existing projects 来导入。

=== JCE

如果您因为 "Illegal key size" 异常而遇到问题,并且使用的是 Sun 的 JDK,您需要安装 Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files。 有关更多信息,请参阅以下链接:

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 是问题编号)。

=== 代码风格检查

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

.spring-cloud-build-tools/

└── src    ├── checkstyle    │   └── checkstyle-suppressions.xml <3>    └── main    └── resources    ├── checkstyle-header.txt <2>    └── checkstyle.xml <1>

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

==== Checkstyle 配置

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

.pom.xml

true <1> true <2> true <3> <4> io.spring.javaformat spring-javaformat-maven-plugin <5> org.apache.maven.plugins maven-checkstyle-plugin
root@kitploit:~
<reporting>
    <plugins>
        <plugin> <5>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
        </plugin>
    </plugins>
</reporting>
---- <1> 在 Checkstyle 错误时使构建失败 <2> 在 Checkstyle 违规时使构建失败 <3> Checkstyle 也分析测试源代码 <4> 添加 Spring Java 格式化插件,该插件将重新格式化您的代码以通过大多数 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[代码样式]

转到 `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[代码样式]

转到 `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()
  • 引导应用程序上下文:主应用程序的父上下文,可以训练其执行任何操作(默认情况下,它绑定到配置服务器并解密属性值)。