This repository was archived by the owner on Oct 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
chore(dependency): upgrade spring boot from 2.7.x to 3.0.x and spring cloud from 2021.0.x to 2022.0.x #1216
Closed
Closed
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5ef911c
chore(dependency): upgrade spring boot from 2.7.x to 3.0.x and spring…
j-sandy 828a55d
refactor(dependency): replace javax with jakarta and HandlerIntercept…
j-sandy 0dc68a1
refactor(exception): replace NestedIOException with IOException durin…
j-sandy 3386f74
refactor(eureka): removed deprecated client and refactor constructor …
j-sandy 66f2d8c
refactor(telemetry): replace the deprecated method and constructor du…
j-sandy ac20f15
refactor(dependency): replace rxjava with rxjava3 during upgrade of s…
j-sandy 4d0b66b
refactor(spring-security): refactor spring security from 5.x to 6.x …
j-sandy 3230319
refactor(dependency): replace javax.inject with jakarta.inject and up…
j-sandy 6632c05
refactor(test): replace spring.profiles with spring.config.activate.o…
j-sandy a980df2
refactor(test): refactor the method getType() to getTableType() as pa…
j-sandy 5345b79
refactor(test): upgrade spockframework to fix issue during upgrade of…
j-sandy 17f10c5
refactor(dependency): unpin snakeyaml and upgrade logback with spring…
j-sandy b993c8d
Merge branch 'master' of https://github.com/j-sandy/kork into sb-3-0-13
j-sandy 9b0bdd6
refactor(dependency): upgrade wiremock as part of spring boot 3.x and…
j-sandy 8016793
Merge branch 'spinnaker:master' into sb-3-0-13
j-sandy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...ctuator/src/main/java/com/netflix/spinnaker/kork/actuator/ActuatorSanitizingFunction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* | ||
| * Copyright 2024 OpsMx, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.netflix.spinnaker.kork.actuator; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
| import java.util.stream.Collectors; | ||
| import org.springframework.boot.actuate.endpoint.SanitizableData; | ||
| import org.springframework.boot.actuate.endpoint.SanitizingFunction; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| @Component | ||
| public class ActuatorSanitizingFunction implements SanitizingFunction { | ||
|
|
||
| private static final String[] REGEX_PARTS = {"*", "$", "^", "+"}; | ||
| private static final Set<String> DEFAULT_KEYS_TO_SANITIZE = | ||
| Set.of( | ||
| "password", | ||
| "secret", | ||
| "key", | ||
| "token", | ||
| ".*credentials.*", | ||
| "vcap_services", | ||
| "^vcap\\.services.*$", | ||
| "sun.java.command", | ||
| "^spring[._]application[._]json$"); | ||
| private static final Set<String> URI_USERINFO_KEYS = | ||
| Set.of("uri", "uris", "url", "urls", "address", "addresses"); | ||
| private static final Pattern URI_USERINFO_PATTERN = | ||
| Pattern.compile("^\\[?[A-Za-z][A-Za-z0-9\\+\\.\\-]+://.+:(.*)@.+$"); | ||
| private List<Pattern> keysToSanitize = new ArrayList<>(); | ||
|
|
||
| public ActuatorSanitizingFunction(List<String> additionalKeysToSanitize) { | ||
| addKeysToSanitize(DEFAULT_KEYS_TO_SANITIZE); | ||
| addKeysToSanitize(URI_USERINFO_KEYS); | ||
| addKeysToSanitize(additionalKeysToSanitize); | ||
| } | ||
|
|
||
| public ActuatorSanitizingFunction() { | ||
| addKeysToSanitize(DEFAULT_KEYS_TO_SANITIZE); | ||
| addKeysToSanitize(URI_USERINFO_KEYS); | ||
| } | ||
|
|
||
| private void addKeysToSanitize(Collection<String> keysToSanitize) { | ||
| for (String key : keysToSanitize) { | ||
| this.keysToSanitize.add(getPattern(key)); | ||
| } | ||
| } | ||
|
|
||
| private Pattern getPattern(String value) { | ||
| if (isRegex(value)) { | ||
| return Pattern.compile(value, Pattern.CASE_INSENSITIVE); | ||
| } | ||
| return Pattern.compile(".*" + value + "$", Pattern.CASE_INSENSITIVE); | ||
| } | ||
|
|
||
| private boolean isRegex(String value) { | ||
| for (String part : REGEX_PARTS) { | ||
| if (value.contains(part)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public void setKeysToSanitize(String... keysToSanitize) { | ||
| if (keysToSanitize != null) { | ||
| for (String key : keysToSanitize) { | ||
| this.keysToSanitize.add(getPattern(key)); // todo: clear oll existing the make the list. | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public SanitizableData apply(SanitizableData data) { | ||
| if (data.getValue() == null) { | ||
| return data; | ||
| } | ||
|
|
||
| for (Pattern pattern : keysToSanitize) { | ||
| if (pattern.matcher(data.getKey()).matches()) { | ||
| if (keyIsUriWithUserInfo(pattern)) { | ||
| return data.withValue(sanitizeUris(data.getValue().toString())); | ||
| } | ||
|
|
||
| return data.withValue(SanitizableData.SANITIZED_VALUE); | ||
| } | ||
| } | ||
|
|
||
| return data; | ||
| } | ||
|
|
||
| private boolean keyIsUriWithUserInfo(Pattern pattern) { | ||
| for (String uriKey : URI_USERINFO_KEYS) { | ||
| if (pattern.matcher(uriKey).matches()) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private Object sanitizeUris(String value) { | ||
| return Arrays.stream(value.split(",")).map(this::sanitizeUri).collect(Collectors.joining(",")); | ||
| } | ||
|
|
||
| private String sanitizeUri(String value) { | ||
| Matcher matcher = URI_USERINFO_PATTERN.matcher(value); | ||
| String password = matcher.matches() ? matcher.group(1) : null; | ||
| if (password != null) { | ||
| return StringUtils.replace( | ||
| value, ":" + password + "@", ":" + SanitizableData.SANITIZED_VALUE + "@"); | ||
| } | ||
| return value; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc please. And where do all these hard-coded strings come from?