Skip to content

[2.0] Fixes #28299: mask plain text secrets left in service version history (#37975) - #38184

Merged
Khairajani merged 6 commits into
2.0from
bp-37975-2.0
Nov 19, 2026
Merged

Khairajani merged 6 commits into
2.0from
bp-37975-2.0

Conversation

@Khairajani

@Khairajani Khairajani commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #28299

[2.0] backport of #37975 and the version-history part of #38117 (was #38187).

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The remaining repository requirements must be addressed before merging; no new behavior issue was found in the latest update.

Findings

  1. P2 Unchanged variables lack final . ▶
  2. P2 Secret prefixes are defined twice. ▶
  3. P2 Tests use the wrong module. ▶
  4. P2 Secret list exceeds class limit. ▶

Summary

This PR masks plain-text secrets in saved service and Test Connection versions during the 2.0.9 upgrade.

  • Old service and Test Connection versions now mask plain-text secrets.

Reviews (6) · Last reviewed commit: "Name boolean locals as questions in vers..." · Reviewed by Greptile

…#37975)

* Fixes #28299: mask secrets nested below every oneOf branch

The coverage test from #33193 converted only the first secret-bearing
branch of each oneOf and only checked that the property itself was no
longer a Map, so a secret in a later branch, or a oneOf nested inside a
typed value, passed unnoticed. Checking every branch through a walk that
mirrors the password walkers finds three secrets still returned unmasked:

- PowerBI GCS pbitFilesSource: securityConfig.gcpConfig.privateKey
- Superset API connection: sslConfig certificates and key
- MySQL GCP CloudSQL authType: password and gcpConfig.privateKey

convertProperty now sets a property through its getter's type, so a typed
property such as GCPCredentials can be run through its own converter, and
the registry gains converters for GcpCloudSqlConfig, the PowerBI GCSConfig
and SupersetApiConnection. MySQL's authType candidates include CloudSQL.

* test: assert each nested secret field is masked, not just absent

A converter that dropped a nested secret would have passed the previous
check, which only looked for the original value and any mask in the JSON.

* Keep an empty oneOf object as it is instead of converting it

Choosing None for an optional oneOf (e.g. the Alation database connection)
submits {}, which converted to the first candidate class filled with schema
defaults.

* Mask plain text connection secrets left in service version history

Secrets below some oneOf branches (Databricks Pipeline auth, PowerBI GCS key,
Superset SSL and Cloud SQL, MySQL Cloud SQL) were saved without encryption.
migrate re-saves current services with the fixed converters; this 2.0.9 data
step masks the plain text copies kept in entity_extension version rows.

* test: cover the Superset Cloud SQL secrets in the version masking step

* Mask every connection secret released versions left in version history

The list now covers every format:password path of every service connection
in the releases from 1.11.0 to 2.0.8 and the current schemas, for all service
types and for Test Connection workflow versions, keyed on the config's own
type. Paths may cross arrays ([]) and maps whose every value is a secret ({}).

* Skip workflow versions that are not Test Connection requests

A workflow such as a query runner request has no serviceType, and looking up
its secret paths with a null service entity threw out of the step.

(cherry picked from commit 31575e1)
@Khairajani
Khairajani requested a review from a team as a code owner November 19, 2026 08:08
@Khairajani
Khairajani requested review from IceS2 and removed request for a team November 19, 2026 08:08
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Comment on lines +98 to +99
public static void maskPlainTextSecrets(Handle handle, ConnectionType connectionType) {
List<VersionKey> keys = readVersionKeys(handle);

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.

P2 Unchanged variables lack final. The Java guide requires final on local variables and parameters that do not change. The new helper omits it on handle, connectionType, and keys, with the same pattern elsewhere in the added code. Apply final to unchanged locals and parameters.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +50 to +51
private static final String FERNET_PREFIX = "fernet:";
private static final String SECRET_REFERENCE_PREFIX = "secret:";

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.

P2 Secret prefixes are defined twice. The helper copies values already defined by Fernet.FERNET_PREFIX and SecretsManager.SECRET_FIELD_PREFIX. The Java guide requires one definition in one location. Import the existing constants so these checks do not drift from the code that writes the values.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +42 to +43
@Testcontainers(disabledWithoutDocker = true)
class ServiceVersionSecretsMaskingTest {

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.

P2 Tests use the wrong module. This class starts real MySQL and PostgreSQL containers, so it is an integration test. AGENTS.md requires integration tests in openmetadata-integration-tests, but this class is added under openmetadata-service. Move it to the required module.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +29 to +32
final class ServiceSecretPaths {
private ServiceSecretPaths() {}

static final Map<String, Map<String, List<String>>> SECRET_PATHS =

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.

P2 Secret list exceeds class limit. ServiceSecretPaths spans more than 600 lines. The Java guide says classes should stay under 500 lines. Split the fixed lists by service family and combine them here so each list is easier to review without changing the migration's saved field paths.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@gitar-bot

gitar-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findings

The 2.0.9 migration irreversibly replaces plaintext secrets across service and Test Connection history, altering persisted version data and losing those values.

Adds a 2.0.9 migration step that masks plain text secrets in saved service and Test Connection version history on MySQL and Postgres, including values starting with secret:. The Javadoc reference to a 2.1.0 hook was resolved, since this branch has no such hook. No open issues remain.

✅ 1 closed
✅ Quality: Javadoc says the step also runs from 2.1.0; this branch has no such hook

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v209/ServiceVersionSecretsMasking.java:46-47
The new Javadoc says the step "runs from 2.0.9 and again from 2.1.0". On the 2.0 branch, though, only mysql/v209/Migration.java and postgres/v209/Migration.java call ServiceVersionSecretsMasking. No v210 Migration class exists here (only utils/v210/MigrationUtil.java), so nothing runs the step again from 2.1.0. A maintainer reading this would assume databases already at 2.1.0 are covered on this branch, and they are not. Either drop the paragraph from the backport, or reword it to say the 2.1.0 re-run lives on the 2.1 branch.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Khairajani
Khairajani merged commit adbd612 into 2.0 Nov 19, 2026
69 of 76 checks passed
@Khairajani
Khairajani deleted the bp-37975-2.0 branch November 19, 2026 13:41
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