Skip to content

Conversation

@karrgov
Copy link
Contributor

@karrgov karrgov commented Dec 19, 2025

LMCROSSITXSADEPLOY-2301

@karrgov karrgov force-pushed the passing_secrets_during_deployment_new branch from f0f4384 to 7208ebc Compare December 19, 2025 18:10

public DeploymentDescriptor merge(DeploymentDescriptor deploymentDescriptor, List<ExtensionDescriptor> extensionDescriptors) {
public DeploymentDescriptor merge(DeploymentDescriptor deploymentDescriptor, List<ExtensionDescriptor> extensionDescriptors,
List<String> parameterNamesToBeCensored) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that parameterNamesToBeMasked, Hidden, Redacted, flow better here for the name.

public static final String BUILDPACKS_NOT_ALLOWED_WITH_DOCKER = "Buildpacks must not be provided when lifecycle is set to 'docker'.";
public static final String EXTENSION_DESCRIPTORS_COULD_NOT_BE_PARSED_TO_VALID_YAML = "Extension descriptor(s) could not be parsed as a valid YAML file. These descriptors may fail future deployments once stricter validation is enforced. Please review and correct them now to avoid future issues. Use at your own risk";
public static final String UNSUPPORTED_FILE_FORMAT = "Unsupported file format! \"{0}\" detected";
public static final String ENCRYPTION_BOUNCY_CASTLE_AES256_HAS_FAILED = "Encryption with AES256 by Bouncy Castle has failed!";
Copy link
Contributor

Choose a reason for hiding this comment

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

This message is too specific, we should avoid leaking implementation details (algorithm and the provider). Consider using a more generic message.

Comment on lines +43 to +44
<include
file="/org/cloudfoundry/multiapps/controller/persistence/db/changelog/db-changelog-TEST-SECRET-TOKEN-TABLE-ADDITION-persistence.xml"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this added?

Comment on lines +43 to +44
Set<String> secretParameters = VariableHandling.get(execution, Variables.SECURE_EXTENSION_DESCRIPTOR_PARAMETER_NAMES);
DynamicSecureSerialization dynamicSecureSerialization = SecureSerializationFactory.ofAdditionalValues(secretParameters);
Copy link
Contributor

Choose a reason for hiding this comment

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

These two lines follow the same pattern and appear in several files (with minor variations). Might be worth extracting into a small utility or helper.

@@ -0,0 +1,17 @@
package org.cloudfoundry.multiapps.controller.process.security.resolver;

public class MissingCredentialsFromUserProvidedServiceEncryptionRelated extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Name feels too long and missing a exception suffix. Consider shortening it.

if (resultSet.next()) {
return resultSet.getLong(1);
}
throw new SQLException("INSERT secret_token did not return an id");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we include the process instance and variable name in the exception message?


private MultiValuedMap<String, String> getParametersNameValueMapFromExtensionDescriptors(
List<ExtensionDescriptor> extensionDescriptors) {
MultiValuedMap<String, String> parametersNameValueMapFromExtensionDescriptors = new ArrayListValuedHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

parametersNameValueMapFromExtensionDescriptors and parametersNameValueMapFromDeploymentDescriptor seems to be very long. Consider a shorter, more descriptive name to improve clarity.

Comment on lines +91 to +107
private Set<String> getNestedParameterNamesToBeCensored(MultiValuedMap<String, String> parameterNameValueMap,
Set<String> parameterNamesToBeCensored) {
Set<String> nestedParameterNamesToBeCensored = new HashSet<>();
for (Map.Entry<String, Collection<String>> parameterEntryInStringType : parameterNameValueMap.asMap()
.entrySet()) {
List<String> entryValuesToString = parameterEntryInStringType.getValue()
.stream()
.map(String::toString)
.toList();
for (String complexValue : entryValuesToString) {
for (String nameToBeCensored : parameterNamesToBeCensored) {
if (complexValue.contains(nameToBeCensored)) {
nestedParameterNamesToBeCensored.add(parameterEntryInStringType.getKey());
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The nested loops make the logic a bit hard to follow. Could we simplify by using streams or helper methods?

Comment on lines +253 to +267
private Map<String, String> getParametersStringCastedValue(ParametersContainer parametersContainer) {
return parametersContainer.getParameters()
.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey,
currentParameter -> Objects.toString(currentParameter.getValue(), "")));
}

private Map<String, String> getPropertiesStringCastedValue(PropertiesContainer propertiesContainer) {
return propertiesContainer.getProperties()
.entrySet()
.stream()
.collect(Collectors.toMap(Map.Entry::getKey,
currentProperty -> Objects.toString(currentProperty.getValue(), "")));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

getParametersStringCastedValue and getPropertiesStringCastedValue share almost identical logic. Consider a generic helper method to reduce duplication.

Comment on lines +283 to +284
private void getParametersAndPropertiesPerModule(MultiValuedMap<String, String> multiValuedMap, Module module, boolean isRequired,
boolean isWhole, boolean isProvided) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Long boolean flag lists reduce readability. Consider replacing them with an enum or separate helper methods for each case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants