Fix #8054: decrypt trustStorePassword in REST transform init - #8061
Open
kotwal-itpro wants to merge 1 commit into
Open
Fix #8054: decrypt trustStorePassword in REST transform init#8061kotwal-itpro wants to merge 1 commit into
kotwal-itpro wants to merge 1 commit into
Conversation
The REST transform's init() reads the trust store password with resolve()
only, missing the Encr.decryptPasswordOptionallyEncrypted(...) call every
other password field in Hop wraps around resolve(). This includes the
httpPassword branch a dozen lines above it in the very same method:
data.realHttpPassword =
Encr.decryptPasswordOptionallyEncrypted(resolve(meta.getHttpPassword()));
...
data.trustStorePassword = resolve(meta.getTrustStorePassword()); // not decrypted
As a result, an encrypted value that reaches the field through a variable
is passed to the trust store loader verbatim and the SSL context cannot
be built. A password typed straight into the dialog works, because
XmlMetadataUtil already decrypts password=true properties on
deserialization -- the bug only surfaces on the variable path.
Both fields are declared identically in RestMeta (password = true) and
every peer usage decrypts:
- plugins/misc/rest/.../RestConnection.java:566 (same field name)
- plugins/databases/oracle/.../OracleDatabaseMeta.java:561
- plugins/transforms/ldap/.../LdapSslProtocol.java:41
Fix: wrap resolve() in Encr.decryptPasswordOptionallyEncrypted() to
match the peer pattern. One-line production change plus a regression
test that runs init() with an encrypted trust store password behind a
variable, asserting the plaintext lands on RestData (parity with the
pre-existing httpPassword assertion in the same test).
Verified: full plugins/transforms/rest test suite passes (168 tests, 0
failures, 0 errors). ./mvnw spotless:apply clean. Java 21 build.
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.
Fixes #8054.
Problem
The REST transform's
init()reads the trust store password withresolve()only, missing theEncr.decryptPasswordOptionallyEncrypted(...)call that every other password field in Hop wraps aroundresolve(). This includes thehttpPasswordbranch a dozen lines above it in the very same method:Both fields are declared identically in
RestMeta:Every peer usage decrypts:
plugins/misc/rest/.../RestConnection.java:566(same field name)Encr.decryptPasswordOptionallyEncrypted(resolve(trustStorePassword))plugins/databases/oracle/.../OracleDatabaseMeta.java:561decrypt(variables, trustStorePassword)plugins/transforms/ldap/.../LdapSslProtocol.java:41Utils.resolvePassword(variables, ...)(resolve + decrypt)plugins/transforms/rest/.../Rest.java:2258(before this PR)resolve(...)onlyAs a result, an encrypted value that reaches the field through a variable is passed to the trust store loader verbatim and the SSL context cannot be built.
Why it's not visible in the simple case
A password typed straight into the dialog works, because
XmlMetadataUtilalready decryptspassword = trueproperties on deserialization (core/src/main/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtil.java:1211). The bug only surfaces on the variable path — which is the whole point ofpassword = truefields being encryptable in the first place.Fix
One-line change to
Rest.java: wrapresolve(meta.getTrustStorePassword())inEncr.decryptPasswordOptionallyEncrypted(...), matching the peer pattern. TheEncrimport is already present in the file. Added a short comment tying the pattern to the peer locations and to this issue.Test
New
testInitDecryptsTrustStorePasswordFromVariableinRestInitAndProcessTest:Encr.encryptPasswordIfNotUsingVariables${TRUST_PWD}variableinit()and assertsdata.trustStorePasswordequals the original plaintextdata.realHttpPasswordon the same run for parity with the pre-existinghttpPasswordhandling — makes the equivalence explicit for future readersVerified locally
./mvnw testonplugins/transforms/rest— 168 tests, 0 failures, 0 errors./mvnw spotless:apply— no formatting changes