njnu-seafish opened a new pull request, #18737:
URL: https://github.com/apache/dolphinscheduler/pull/18737

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are 
happy that you want to help us improve DolphinScheduler! -->
   
   ## Was this PR generated or assisted by AI?
   
   Yes, generate test cases by AI
   
   ## Purpose of the pull request
   
   Fix part of #17813 (the password-overwrite half; also reported by #18004).
   
   The query APIs (`queryDataSource`, `queryDataSourceListPaging`) always 
return the password masked as `Constants.XXXXXX` (`******`). The edit form 
echoes this value back unchanged on save, and on dev `updateDataSource` only 
treats a *blank*
   password as "not updated" — so the literal mask gets stored as the real 
password:
   
       expected: <oldSecret> but was: <******>
   
   That is exactly the #18004 failure mode on dev: edit a datasource, save 
without touching the password, and the stored password is silently overwritten; 
S QL tasks on that datasource stop connecting afterwards.
   
   ## Brief change log
   
   - `DataSourceServiceImpl#updateDataSource`: "password not updated" now means 
`blank OR equals the mask value returned by the query APIs`, reusing the 
existing old-password backfill branch.
   - The comparison happens on the raw DTO value 
(`dataSourceParam.getPassword()`) before `buildConnectionParams`, so it also 
holds when `DATASOURCE_ENCRYPTION_ENABLE` is on (the connection param carries 
the Base64-encoded password in that case — comparing there would silently 
break).
   - The mask reference is the same one the query APIs use to mask, so the 
guard and the read path can never drift apart.
   - No config switch: this value can only originate from our own echo and 
never deserves to be written as a password. Semantically this extends the 
existing "blank keeps the old password" rule from {blank} to {blank, mask}; the 
only
     input lost is setting the password to a literal `******`, the same class 
as the  existing "cannot set an empty password".
   
   ## Verify this pull request
   
   Added 4 contract tests to `DataSourceServiceTest`, each asserting the 
persisted `connectionParams.password` byte-for-byte:
   
   - blank password → old stored value kept (existing rule, regression coverage)
   - mask `******`, default config → old stored value kept
   - mask `******`, `DATASOURCE_ENCRYPTION_ENABLE=true` → old stored value kept
     (guards the compare-on-raw-DTO decision; comparing on the encoded 
connection
     param differs in exactly this case)
   - new password → new value stored
   
   `DataSourceServiceTest`: 18/18 green. Mutation-checked: removing the mask 
condition turns exactly the two mask cases red while blank/new-password cases 
stay green (no false positives). Spotless check passed.
   
   ## Pull Request Notice
   [Pull Request 
Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contains incompatible change, you should also add it to 
`docs/docs/en/guide/upgrade/incompatible.md`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to