Conversation
…during build time by the buildpack are escaped now. Values that are pulled at runtime before an app starts are escaped at that point in time, so we skip that here or it results in double escaping of values.
dmikusa
pushed a commit
that referenced
this pull request
Jun 11, 2021
PR #870 reversed the logic overriding the default_unique_host_name with the application_name. This results in problems with AppDynamics where applications running on multiple foundations are unable to add metrics when using the same application name in Cloud Foundry. Really, application_name should never be used. unique_host_name is by definition a unique identifier vs an application_name, which is not guaranteed to be unique. But this restores the previous logic, which was functional and may have handled cases I am not aware of.
dmikusa
pushed a commit
that referenced
this pull request
Oct 12, 2021
…pDynamnics config [Previous PRs escaped configuration values for AppD](#870). This was done to support things like names with spaces and other characters that, if used, would result in a broken start command. The PR broke a use case which was documented for the node or tier name. In some cases, you may want to set the node or tier name to a dynamic value that is loaded at runtime so that you can incorporate things like the application instance index. For example `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')`. This new PR will use `Shellwords.escape(..)` on the value for all properties unless that property value contains what looks like a subshell `$(..)` or environment variable `${..}` reference. If it looks like a subshell or env variable is being referenced, we will not escape but just wrap the value in escaped quotes. We wrap it in escaped quotes in case the shell variable or subshell returns something which includes spaces. This is not perfect though, and you need to be careful if using subshell/env variables, you should ensure the output is properly escaped. For example: - `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')` - `$(echo 'Hello world!') and stuff` becomes `\"$(echo 'Hello world!') and stuff\"` - `--> ${SOME_VAR} <--` becomes `\"--> ${SOME_VAR} <--\"` Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
dmikusa
pushed a commit
that referenced
this pull request
Oct 18, 2021
…pDynamnics config (#911) [Previous PRs escaped configuration values for AppD](#870). This was done to support things like names with spaces and other characters that, if used, would result in a broken start command. The PR broke a use case which was documented for the node or tier name. In some cases, you may want to set the node or tier name to a dynamic value that is loaded at runtime so that you can incorporate things like the application instance index. For example `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')`. This new PR will use `Shellwords.escape(..)` on the value for all properties unless that property value contains what looks like a subshell `$(..)` or environment variable `${..}` reference. If it looks like a subshell or env variable is being referenced, we will not escape but just wrap the value in escaped quotes. We wrap it in escaped quotes in case the shell variable or subshell returns something which includes spaces. This is not perfect though, and you need to be careful if using subshell/env variables, you should ensure the output is properly escaped. For example: - `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')` - `$(echo 'Hello world!') and stuff` becomes `\"$(echo 'Hello world!') and stuff\"` - `--> ${SOME_VAR} <--` becomes `\"--> ${SOME_VAR} <--\"` Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
ramonskie
pushed a commit
that referenced
this pull request
Dec 4, 2025
Adjusts the way App Dynamics configuration properties are being escaped. They are passed into the JVM process via system properties, so the values require proper escaping or they can cause issues. This PR uses `Shellwords.escape` to perform the escaping of the configuration set at build time. Values that are selected at runtime before an app starts are escaped at that point in time (using `jq`'s `@sh`), so those are *not* escaped at build time otherwise it results in double escaping of those values (like seeing `'`'s in the app name). This PR also updates the docs as the set of required properties for the App Dynamic agent have changed.
ramonskie
pushed a commit
that referenced
this pull request
Dec 4, 2025
PR #870 reversed the logic overriding the default_unique_host_name with the application_name. This results in problems with AppDynamics where applications running on multiple foundations are unable to add metrics when using the same application name in Cloud Foundry. Really, application_name should never be used. unique_host_name is by definition a unique identifier vs an application_name, which is not guaranteed to be unique. But this restores the previous logic, which was functional and may have handled cases I am not aware of.
ramonskie
pushed a commit
that referenced
this pull request
Dec 4, 2025
…pDynamnics config (#911) [Previous PRs escaped configuration values for AppD](#870). This was done to support things like names with spaces and other characters that, if used, would result in a broken start command. The PR broke a use case which was documented for the node or tier name. In some cases, you may want to set the node or tier name to a dynamic value that is loaded at runtime so that you can incorporate things like the application instance index. For example `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')`. This new PR will use `Shellwords.escape(..)` on the value for all properties unless that property value contains what looks like a subshell `$(..)` or environment variable `${..}` reference. If it looks like a subshell or env variable is being referenced, we will not escape but just wrap the value in escaped quotes. We wrap it in escaped quotes in case the shell variable or subshell returns something which includes spaces. This is not perfect though, and you need to be careful if using subshell/env variables, you should ensure the output is properly escaped. For example: - `DCX:$(echo $VCAP_APPLICATION | jq -r '.application_name'):$(echo $VCAP_APPLICATION | jq -r '.instance_index')` - `$(echo 'Hello world!') and stuff` becomes `\"$(echo 'Hello world!') and stuff\"` - `--> ${SOME_VAR} <--` becomes `\"--> ${SOME_VAR} <--\"` Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR #837 can result in double escaping of application names when the default value is used. This is because the value gets escaped at runtime when it's selected, so it's not necessary to escape it at build time also.
It also only handles spaces. If there were a
"in the name, that would cause an error.This PR will ensure that values for the app name that are selected during build time by the buildpack are escaped at build time and that values that are pulled at runtime before an app starts are escaped at that point in time, but not both. That way we avoid double escaping values.
In addition, it uses
Shellwords.escapeto escape the values not just surrounding them in double-quotes. This will result in properly shell escaping double quotes also.Resolves #871