Skip to content

Fixes #28299: mask and encrypt secrets nested in a schema oneOf - #33193

Merged
ulixius9 merged 4 commits into
mainfrom
geneva
Sep 24, 2026
Merged

ulixius9 merged 4 commits into
mainfrom
geneva

Conversation

@ulixius9

@ulixius9 ulixius9 commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #28299

I worked on masking the SFTP connection password because the plain-text input the issue reports turned out to be the visible symptom of a deeper bug that spans 41 connector properties.

jsonschema2pojo ignores oneOf, so a oneOf property is generated as a bare Object and holds a LinkedHashMap at runtime. PasswordEntityMasker.maskPasswordFields and SecretsManager.encryptPasswordFields both recurse only into values whose package starts with org.openmetadata, so that map is skipped entirely: every format: password leaf below it was never Fernet-encrypted, never handed to the external secrets manager, and never masked on read. The UI lost the format: password marker for the same reason and rendered the value in a readable text input. The thing that closes the hole is a ClassConverter that re-types the property before either walk runs (SecretsUtil.convert runs first in both paths).

Type of change:

  • Bug fix

High-level design:

Audit. I walked every connection schema and cross-referenced converter coverage: 41 (connection, property) pairs were uncovered. 37 are fixed here.

  • Credentials/tokens — SFTP (password, privateKey, privateKeyPassphrase), OpenSearch, Alation, Alation Sink, Databricks Pipeline, MyDb, QuestDB, Microsoft Access, REST openAPISchemaConnection, PowerBI pbitFilesSource, and the Elasticsearch/OpenSearch SSLConfig.certificates values.
  • TLS material — every sslConfig (its caCertificate / sslCertificate / sslKey are all format: password): Db2, Doris, Informix, MongoDB, MyDb, SAP ERP, SAP S/4HANA, SAP SuccessFactors, Omni, SSRS, REST, Tableau, Cassandra, Hive, Prefect, Fivetran, Flink, Alation Sink, OpenMetadata, NATS, Kafka (x2), OpenLineage Kafka broker, Matillion ETL.

Approach. 26 of these connections need nothing but re-typing, so rather than 26 near-identical converter classes I added NestedConfigClassConverter — constructed with a property -> candidate classes map — plus a reflective ClassConverter.convertProperty helper. ClassConverterFactory stays the single source of truth for the registry. Four existing converters (Tableau, Cassandra, Hive, Prefect) gained their missing sslConfig pass, and OpenSearchConnectionClassConverter is new because it also needs the nested SSLConfig.certificates pass that Elasticsearch's converter now does.

Why the schema changed. SFTP's auth branches were inline #/definitions, and jsonschema2pojo generates a class per schema file, not per $ref target — so no Java class existed to convert into. They are extracted to drive/sftp/{basicAuth,keyAuth}.json with the titles unchanged, so the UI form labels are identical; the only cross-language cost is that datamodel-codegen names the Python models after the title, hence the two import renames in the SFTP connector. A stray type: object on common/sslConfig.json is dropped for the same reason (it made certificates a fieldless Certificates class with an untyped additionalProperties map; no Java code referenced it).

Alternative rejected. Teaching the reflection walk to descend into Map values and mask any key matching a known secret name would fix all 41 at once with no schema change — but it changes the semantics of the core secrets path for every entity, including free-form connectionArguments, which is a much riskier diff than extending the established converter pattern.

Regression gate. NestedSecretConverterCoverageTest walks every connection schema on the classpath, builds a payload per secret-bearing oneOf branch, runs the registered converter and fails if the property is still a Map. Its KNOWN_UNCONVERTIBLE allowlist holds the four cases that still need a branch extracted into its own file — SAP S/4HANA authType, NATS authType, Delta Lake MetastoreConfig.connection, Qlik Sense certificates — so they stay visible and the set cannot grow silently. I verified the gate is not vacuous by de-registering SFTP, Db2 and OpenSearch and confirming it fails on exactly those three.

Rollout / backward compatibility. No migration is needed: the stored JSON shape is unchanged (only Java/Python class generation changes), and decryptPasswordFields already passes a non-Fernet value through untouched, so existing services keep working and get encrypted on their next save. Operators should be aware that credentials saved on an affected connector before this fix are sitting unencrypted in the metadata DB and were never written to the configured secrets manager, so they need rotating and re-saving.

Tests:

Use cases covered

  • Viewing an SFTP drive service's Connection tab renders the password as type="password", not type="text" (the exact assertion from the issue report).
  • Saving an SFTP service Fernet-encrypts authType.password instead of persisting it in clear text.
  • GET /v1/services/driveServices/{fqn} returns ********* for authType.password / authType.privateKey, and a subsequent PUT carrying the mask restores the original secret.
  • The same holds when the config arrives from the database as a raw map rather than a typed object.
  • Any future connector that puts a secret behind a oneOf without registering a converter fails the build.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added: NestedSecretConverterCoverageTest.java, ServiceConnectionDetailsUtils.test.tsx
  • Files updated: PasswordEntityMaskerTest.java (mask/unmask round-trip + serialized-map variant), DBSecretsManagerTest.java (Fernet encryption of a nested secret), test_sftp.py
  • Backend coverage (jacoco:report, secrets package): 90.3% lines aggregate over the changed classes — ClassConverterFactory 100%, NestedConfigClassConverter 100%, Tableau/Cassandra/Hive/Prefect converters 100%, OpenSearchConnectionClassConverter 91%, ElasticSearchConnectionClassConverter 86%, ClassConverter 85%, PasswordEntityMasker 80%.
  • UI coverage: the new getSchemaProperties / resolveRef block is fully covered; ServiceConnectionDetailsUtils.tsx as a whole is 69.4% lines, the remainder being pre-existing untested renderers.
  • Suite results: 166/166 org.openmetadata.service.secrets.**, 18/18 new UI tests (136/136 across the service-utils suites), 37/37 test_sftp.py, 24/24 search-connector tests. Each new test was confirmed to fail without its fix.

Backend integration tests

  • Not applicable — no API surface changed; the fix is inside the existing masker/secrets-manager path and is covered by unit tests at that seam.

Ingestion integration tests

  • The only ingestion change is renaming two generated model imports in the SFTP connector (BasicAuth -> UsernamePasswordAuthentication, KeyAuth -> PrivateKeyAuthentication). The existing test_sftp.py exercises both auth branches and was updated accordingly.

Playwright (UI) tests

  • Not added — the change is a rendered input type on the read-only Connection tab, asserted directly in Jest against the DOM. Happy to add a Playwright spec if reviewers prefer one.

Manual testing performed

  1. mvn install -pl openmetadata-spec and confirmed SftpBasicAuth / SftpKeyAuth classes are now generated, and that SSLConfig.getCertificates() is Object.
  2. Ran scripts/datamodel_generation.py and yarn parse-schema, then confirmed the dereferenced UI schema still inlines both SFTP oneOf branches with format: password and unchanged branch titles.
  3. De-registered the SFTP converter and re-ran the masker tests to reproduce the original bug: ClassCast class java.util.LinkedHashMap cannot be cast to ... SftpBasicAuth — i.e. the map the masker silently skips.
  4. Reverted the one-line UI wiring and confirmed the render test fails with type="text", matching the HTML in the issue.
  5. mvn spotless:check, the CI ESLint/Prettier/organize-imports sequence, and ruff all clean; tsc reports no new errors in the changed file (28 -> 26, all pre-existing).

UI screen recording / screenshots:

TODO: attach recording. Before/after is the single attribute the issue quotes:

<!-- before --> <input readonly data-testid="input-field" type="text"     value="test">
<!-- after  --> <input readonly data-testid="input-field" type="password" value="*********">

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: no migration needed — the persisted JSON shape is unchanged, only Java/Python class generation is, and non-Fernet values already pass through decryption untouched.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing (issue Sftp Service connection details contain unmasked password #28299 is referenced in the test and gate Javadoc).

🤖 Generated with Claude Code

RetriggerConfidence Score: 4/5

The functional secret-handling fix appears sound, but the PR is not ready to merge until the two outstanding explicit repository-convention findings are addressed.

Findings

  1. P1 Stale SFTP Model Import ▶
  2. P2 Later Secret Branches Untested ▶
  3. P2 SFTP Schemas Break Naming Convention ▶
  4. P2 Fully Qualified Class Used ▶
Summary

The PR re-types secret-bearing connection properties generated as raw objects so nested credentials and TLS material participate in encryption, external secret storage, and response masking.

  • Adds generic and connector-specific class converters for secret-bearing oneOf properties.
  • Extracts SFTP authentication schemas into generated concrete models and updates Python ingestion callers.
  • Preserves password metadata in the UI schema and resolves nested schema properties when rendering connection details.
  • Adds backend, ingestion, and UI regression coverage, including coverage of every secret-bearing schema branch.

Reviews (7) · Last reviewed commit: "Merge branch 'main' into geneva"

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 11, 2026
@ulixius9
ulixius9 marked this pull request as ready for review September 16, 2026 08:40
@ulixius9
ulixius9 requested review from harshsoni2024 and a lite review from Copilot September 16, 2026 08:40

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

Comment on lines +39 to +42
"$ref": "sftp/basicAuth.json"
},
{
"$ref": "#/definitions/keyAuth"
"$ref": "sftp/keyAuth.json"

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.

P1 Stale SFTP Model Import

Moving these authentication definitions into separate schema files removes BasicAuth and KeyAuth from the generated sftpConnection Python module. However, ingestion/tests/unit/source/drive/sftp/test_connection.py still imports and instantiates BasicAuth from that module. After model generation, the test raises ImportError during collection, preventing the ingestion unit suite from completing.

} catch (ClassNotFoundException e) {
return false; // Not a generated class, so nothing walks it either.
}
Ref branch = secretBearingBranch(oneOf.node(), oneOf.path(), schemas);

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 Later Secret Branches Untested

This gate builds a payload for only the first secret-bearing branch. Properties such as SFTP authType and Alation authType have multiple secret-bearing branches, so a converter that handles the first but omits a later branch would still pass. The omitted branch could remain a map, leaving its secrets unencrypted and unmasked. The gate should exercise every secret-bearing branch.

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!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Generated Sources Auto-Updated

The generated TypeScript types (src/generated/) and dereferenced JSON
schemas (src/jsons/, public/jsons/) have been automatically updated
based on JSON schema changes in this PR.

Copilot AI review requested due to automatic review settings September 16, 2026 08:45

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.52% (103952/143339) 57.62% (63292/109827) 58.68% (20715/35298)

Comment on lines +4 to +7
"title": "Username/Password Authentication",
"description": "Username and password authentication for SFTP",
"type": "object",
"javaType": "org.openmetadata.schema.services.connections.drive.sftp.SftpBasicAuth",

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 SFTP Schemas Break Naming Convention

The new basicAuth.json schema declares the descriptive title Username/Password Authentication and the explicit Java type SftpBasicAuth. The same pattern appears in keyAuth.json, which declares Private Key Authentication and SftpKeyAuth. This violates the repository requirement that schema titles follow the camelCase filename and generated classes follow that schema identity. This repository requirement must be satisfied before merging.

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 +234 to +235
org.openmetadata.schema.services.connections.dasboard.powerbi.GCSConfig
.class,

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 Fully Qualified Class Used

The Power BI converter references org.openmetadata.schema.services.connections.dasboard.powerbi.GCSConfig.class inline. This violates the repository requirement to import Java classes instead of using fully qualified names in code, and the requirement must be satisfied before merging.

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!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Generated Sources Auto-Updated

The generated TypeScript types (src/generated/) and dereferenced JSON
schemas (src/jsons/, public/jsons/) have been automatically updated
based on JSON schema changes in this PR.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

ulixius9 and others added 3 commits September 22, 2026 17:52
jsonschema2pojo ignores `oneOf`, so a `oneOf` property is generated as a
bare `Object` and holds a `LinkedHashMap` at runtime. Both
`PasswordEntityMasker` and `SecretsManager` recurse only into values whose
package starts with `org.openmetadata`, so that map is skipped entirely:
every `format: password` leaf below it was never Fernet-encrypted, never
handed to the external secrets manager, and never masked on read. The UI
lost the `format: password` marker for the same reason and rendered the
value in a plain text input, which is what #28299 reports for SFTP.

Audited every connection schema: 41 (connection, property) pairs were
uncovered. 37 are fixed here by registering a converter that re-types the
property before either walk runs -- SFTP, OpenSearch, Alation, Databricks
Pipeline, REST, PowerBI, Microsoft Access, MyDb, QuestDB auth configs, the
ES/OS SSL certificate values, and every `sslConfig` (its certificate and
key fields are `format: password` too).

`NestedConfigClassConverter` covers the 26 connections that need nothing
but re-typing, so the registry stays the single source of truth instead of
26 near-identical classes.

SFTP's auth branches were inline `#/definitions`, and jsonschema2pojo
generates a class per schema *file*, so no class existed to convert into;
they are extracted to `drive/sftp/{basicAuth,keyAuth}.json` with the titles
unchanged. The stray `type: object` on `common/sslConfig.json` is dropped
for the same reason.

`NestedSecretConverterCoverageTest` is the regression gate: it walks every
connection schema on the classpath, builds a payload per secret-bearing
`oneOf` branch, runs the registered converter and fails if the property is
still a `Map`. Its `KNOWN_UNCONVERTIBLE` allowlist holds the four remaining
schema-extraction cases so they stay visible and the set cannot grow.
The `oneOf` fix moved SFTP's inline auth branches into
`drive/sftp/{basicAuth,keyAuth}.json`, so `BasicAuth` no longer exists on
`sftpConnection`. `tests/unit/topology/drive/test_sftp.py` was updated;
`tests/unit/source/drive/sftp/test_connection.py` was missed and failed to
import on all three Python versions.

Also drop `MicrosoftAccessConnectionClassConverter`: the registry now maps
`MicrosoftAccessConnection` to an equivalent `NestedConfigClassConverter`, and
because `converters.putAll(NESTED_CONFIG_CONVERTERS)` runs last the dedicated
class was already unreachable.

`ReflectionException` gains a cause-carrying constructor so `convertProperty`
reports which property on which connection failed instead of a bare message.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 3 closed / 3 findings

🔴 High risk · Extends encryption and masking to nested credentials across dozens of connectors

Fixes nested secret encryption and masking across 41 connector properties by re-typing oneOf configuration objects before the secrets walk, extracting SFTP authentication schemas, and extending converter coverage with a generic NestedConfigClassConverter. Adds comprehensive regression coverage including a build gate that verifies future connectors register converters for secret-bearing branches. Consider expanding the coverage gate to iterate over all secret-bearing oneOf/anyOf branches rather than checking only the first, so converters that omit later branches are caught.

✅ 3 closed
✅ Quality: MicrosoftAccessConnection converter is silently shadowed

📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/ClassConverterFactory.java:193-197 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/ClassConverterFactory.java:344
In ClassConverterFactory the static initializer registers MicrosoftAccessConnection.class -> new MicrosoftAccessConnectionClassConverter() in the base map and then calls converters.putAll(NESTED_CONFIG_CONVERTERS), whose map also keys MicrosoftAccessConnection.class to a NestedConfigClassConverter(connection -> S3Connection). Because putAll overrides, the dedicated MicrosoftAccessConnectionClassConverter is never used and becomes dead code. The two are behaviorally equivalent today, so there is no runtime bug, but any future change to MicrosoftAccessConnectionClassConverter would silently have no effect. Keep a single registration: either drop the MicrosoftAccessConnection entry from NESTED_CONFIG_CONVERTERS and its now-redundant import, or delete the dedicated converter class.

✅ Quality: convertProperty discards the reflective exception cause

📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/ClassConverter.java:93-94 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/ClassConverter.java:97-98
convertProperty catches ReflectiveOperationException and rethrows new ReflectionException(e.getMessage()), dropping the original cause and stack trace. If a registered property name ever fails to resolve a getter/setter, the resulting error will be hard to diagnose. Pass the caught exception as the cause (e.g. new ReflectionException(e.getMessage(), e) or include the target class and property name in the message).

Closed: Quality: Coverage gate checks only the first secret-bearing oneOf branch

📄 openmetadata-service/src/test/java/org/openmetadata/service/secrets/converter/NestedSecretConverterCoverageTest.java:101-115
secretBearingBranch returns the first oneOf/anyOf branch that contains a format: password leaf, and leavesSecretsInAMap builds its payload from only that branch. When a property has more than one secret-bearing branch (e.g. SFTP authType has both SftpBasicAuth and SftpKeyAuth), the gate exercises the registered converter against a single branch. A converter that lists a candidate class for the first branch but omits a later branch's class would still leave that later branch's secrets as a Map at runtime, yet the gate would pass — exactly the regression the test is meant to catch. Here the SFTP key-auth path is covered incidentally by PasswordEntityMaskerTest, but the gate itself does not guarantee every branch is converted. Consider iterating over all secret-bearing branches and asserting each one converts, rather than stopping at the first.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 1.13 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 1.13 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

This branch was previously deployed

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

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sftp Service connection details contain unmasked password

6 participants