Skip to content

fix: Support for Non-json secret fetched from Delinea SecretServer#4743

Merged
gusfcarvalho merged 23 commits intoexternal-secrets:mainfrom
DelineaSahilWankhede:main
May 20, 2025
Merged

fix: Support for Non-json secret fetched from Delinea SecretServer#4743
gusfcarvalho merged 23 commits intoexternal-secrets:mainfrom
DelineaSahilWankhede:main

Conversation

@DelineaSahilWankhede
Copy link
Copy Markdown
Contributor

@DelineaSahilWankhede DelineaSahilWankhede commented May 5, 2025

Problem Statement

External Secrets Operator currently assumes secret template data is always in JSON format. This limitation prevents users from creating secrets with non-JSON templates such as plain text, shell scripts, or configuration formats (e.g., INI, YAML).
What is the problem you're trying to solve?

Proposed Changes

  • Added support for handling non-JSON secret templates in templating logic.
  • Introduced new behavior to detect whether the template is JSON, and fallback gracefully to plain string substitution if not.
  • This change enables more flexible use of templated secrets without requiring users to structure them strictly as JSON.
  • Ensured backward compatibility with existing JSON-based workflows.

Checklist

  • I have read the contribution guidelines
  • All commits are signed with git commit --signoff
  • My changes have reasonable test coverage
  • All tests pass with make test
  • I ensured my PR is ready for review with make reviewable

This commit enhances the Delinea Secret Server provider to support secrets created using custom templates that contain only a single non-JSON field.

Previously, the provider assumed that `Items[0].ItemValue` always contained a JSON object. This caused failures when the value was plain text (as is common in single-field custom templates).

The updated logic introduces a hybrid strategy:
- If `Items[0].ItemValue` exists and is a valid JSON string, it uses GJSON to extract the desired property.
- If not, it falls back to a flattened map lookup using `fieldName` and `slug` to locate the value directly in the Fields array.

This ensures compatibility with both:
- Legacy structured secrets (nested JSON within `ItemValue`)
- Simpler templates where `ItemValue` is plain text (e.g. `"value": "abc123"`)

This fix improves interoperability with a wider range of Delinea secret templates without breaking compatibility with existing ones.

Tested with:
- Single-field plaintext custom templates
- Multi-field secrets with JSON-encoded values
- Empty or missing properties (returns full object)

Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
Added test cases for Non-JSON secret and Malformed JSON secret

Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
…patch-1

fix: Support for Non-json secret fetched from Delinea SecretServer
@DelineaSahilWankhede DelineaSahilWankhede requested a review from a team as a code owner May 5, 2025 14:09
Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
@gusfcarvalho
Copy link
Copy Markdown
Member

hi @DelineaSahilWankhede . We also need to add a noSecretError test. This has no coverage as of yet.

Signed-off-by: DelineaSahilWankhede <161290557+DelineaSahilWankhede@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

@gusfcarvalho gusfcarvalho merged commit 8debc0e into external-secrets:main May 20, 2025
20 checks passed
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