Skip to content

Fix AppDynamics agent loading with bring-your-own agent - #1580

Open
ramonskie wants to merge 1 commit into
mainfrom
appdynamics-byo-agent
Open

ramonskie wants to merge 1 commit into
mainfrom
appdynamics-byo-agent

Conversation

@ramonskie

Copy link
Copy Markdown
Contributor

Summary

AppDynamics staging fails with:

failed to install framework AppDynamics Agent: unable to determine AppDynamics version: no default version for appdynamics

src/java/frameworks/app_dynamics.go called Manifest.DefaultVersion("appdynamics"), but the appdynamics default version and dependency were removed during the 5.x manifest refactor (first released in v5.0.0). AppDynamics' own download portal requires authentication, so the agent cannot be published in the upstream manifest.

This change makes the framework bring-your-own-agent, following existing patterns in the buildpack (Checkmarx/Seeker agent URLs, New Relic's app-provided directory, and the IBM JRE fork-and-manifest BYOL path).

Agent sources (in order)

  1. agent-uri (aliases: agent_uri, agent_url, agent-url, agent-download-url, agent_download_url, customoneagenturl) on any bound AppDynamics service. Supports HTTP basic auth in the URL. .zip, .tar.gz and .tgz are accepted; the format is sniffed from file magic, so a zip named .tar.gz also works.
  2. An agent vendored in the application: appdynamics-agent.{zip,tar.gz,tgz} in the app root, .appdynamics/ or .app-dynamics/, or an already-unpacked .appdynamics/ / .app-dynamics/ directory containing javaagent.jar. App-provided agents are also detected without a service binding, matching New Relic's .new-relic-credentials behavior.
  3. An appdynamics dependency in a forked buildpack's manifest.yml (IBM JRE-style BYOL path; upstream has no entry, so only forks reach this).

If the agent-uri download fails, the buildpack logs a warning and falls back to the next source.

Other fixes

  • Search agent-uri across all bound AppDynamics services, so a marketplace binding without a URI does not hide a user-provided binding that has one.
  • Deterministic service selection across Detect/Supply/Finalize.
  • Match appdynamics and app-dynamics as case-insensitive substrings in labels, names and tags (including the documented app-dynamics-agent=<version> tag).
  • Validate zip entry paths before extraction (ExtractZip does not sanitize ..).
  • Redact credentials, query strings and fragments from logged agent URLs.
  • Check download Close errors instead of ignoring them.
  • Update docs and integration-test skip messages.

Tests

go build -mod vendor ./...            OK
go vet -mod vendor ./src/java/...     OK
go test -mod vendor ./src/java/...    OK

AppDynamics framework specs: 48 passing (was 38), covering the credential URL and aliases, basic auth, multi-binding lookup, download fallback, app archive and directory sources, app-only detection, forked manifest, versioned tags, and traversal rejection.

Behavior change

An app with a standard AppDynamics marketplace binding but no agent-uri and no vendored agent now fails staging with an actionable BYO error. Previously it failed with no default version for appdynamics, so the failure mode is not new; only the message and remediation paths are.

The framework called Manifest.DefaultVersion("appdynamics"), but the
dependency was removed from manifest.yml in 5.0 because AppDynamics
requires authentication to download the agent.

Install the agent from an agent-uri service credential, an application-
provided archive or directory, or a forked buildpack manifest, following
the existing Checkmarx, New Relic and IBM JRE patterns.
@ramonskie

Copy link
Copy Markdown
Contributor Author

this was quickly made as a example.
we should investigate if we need to standardize the BYO (bring your own)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved security flaws can expose URL credentials and signed-URL tokens through errors and allow chained archive symlinks to overwrite files outside the agent directory.

3 open issues
What changed in this PR

This PR replaces AppDynamics’ unavailable upstream manifest dependency with bring-your-own-agent support, allowing applications to supply the agent while retaining a manifest fallback for forked buildpacks.

Changes:

  • Adds service-URL downloads, application-provided archives or directories, and forked-manifest installation.
  • Makes service matching deterministic and adds archive validation and URL redaction.
  • Expands framework tests and documents agent setup and fallback behavior.
File Description
src/​java/​frameworks/​app_dynamics.go Implements agent sources, service selection, downloads, and extraction.
src/​java/​frameworks/​app_dynamics_test.go Adds detection, installation, fallback, authentication, and traversal tests.
src/​integration/​frameworks_test.go Updates skip messages to explain missing agent fixtures.
docs/​framework-app_dynamics_agent.md Documents agent sources, credentials, and forked-manifest configuration.

Review effort: Balanced

Comment on lines +435 to +455
parsed, err := url.Parse(agentURI)
if err != nil {
return fmt.Errorf("invalid agent URL: %w", err)
}

request, err := http.NewRequest(http.MethodGet, parsed.String(), nil)
if err != nil {
return fmt.Errorf("failed to create agent download request: %w", err)
}

if parsed.User != nil {
password, _ := parsed.User.Password()
request.SetBasicAuth(parsed.User.Username(), password)
request.URL.User = nil
}

client := &http.Client{Timeout: appDynamicsAgentDownloadTimeout}
response, err := client.Do(request)
if err != nil {
return fmt.Errorf("agent download failed: %w", err)
}
}
return libbuildpack.ExtractZip(archive, dest)
case "tar.gz":
return libbuildpack.ExtractTarGz(archive, dest)
return "", fmt.Errorf("failed to extract AppDynamics agent archive: %w", err)
}

return fmt.Sprintf("service binding credential %q", credential), nil
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