Adalennis opened a new issue, #9207:
URL: https://github.com/apache/hop/issues/9207

   ### Apache Hop version?
   
   SNAPSHOT-20261021
   
   ### Java version?
   
   Java 21
   
   ### Operating system
   
   macOS
   
   ### What happened?
   
   Found while documenting the result of these actions (#8970, PR #9195). Each 
point was tested with hop-run (GnuPG 2.4 with a test keyring) and re-checked on 
today's main; the plugin has no code changes since the tested build. Line 
numbers are from today's main.
   
   **1. Encrypt: "Create file with unique name" overwrites the existing file**
   
   When the destination file exists and If destination file exists is "Create 
file with unique name", ActionPGPEncryptFiles builds the new name 
(`a.txt30102026_140920035`) in `destinationFile`, but encrypts into the 
existing file:
   
       doJob(actionType, sourceFileName, userId, localUser, 
destinationFileName);   // line 835
   
   So the existing `a.txt` is overwritten, no file with the new name is 
created, and the new name, which doesn't exist, is added to the result files. 
Decrypt files with PGP does it right: it writes the decrypted file under the 
new name and keeps the existing one.
   
   Expected: write to `destinationFile`, as Decrypt does.
   
   **2. "Delete source file" deletes the destination file**
   
   With If destination file exists = "Delete source file", both actions delete 
the existing destination file (`destinationFileName.delete()`, Encrypt line 
856, Decrypt line 740) and don't encrypt or decrypt anything; the source stays. 
The action is true and Lines written is 0.
   
   Expected: as the option says, delete the source file (or rename the option 
if deleting the destination is intended).
   
   **3. "Move source file to folder" moves the source without encrypting it**
   
   With If destination file exists = "Move source file to folder", both actions 
move the source file to Destination folder (`HopVfs.moveFile(sourceFileName, 
...)`, Encrypt line 882, Decrypt line 766) without calling doJob(): the moved 
file is the original, not encrypted or decrypted, and it is added to the result 
files.
   
   Expected: encrypt or decrypt, and then move the source.
   
   **4. With the default "Do nothing", no file is added to the result files**
   
   With Add files to result files name checked, a new destination file (one 
that didn't exist yet) is only added when If destination file exists is not "Do 
nothing" or "Fail":
   
       if (addResultFileNames
           && !ifFileExists.equals("fail")
           && !ifFileExists.equals(CONST_DO_NOTHING)) {     // Encrypt lines 
783-785, Decrypt 666-668
   
   So with the default "Do nothing", encrypting `a.txt` into an empty folder 
adds nothing; with "Delete source file", "Move source file to folder", 
"Overwrite destination file" or "Create file with unique name" the same new 
file is added. What If destination file exists is set to shouldn't matter for a 
file that doesn't exist.
   
   Expected: a new destination file is always added when Add files to result 
files name is checked.
   
   **5. In a folder, the failure that breaks the success condition counts 
twice**
   
   With a folder as source and a file in it failing (for example the 
destination exists and If destination file exists is "Fail"), the loop over the 
folder returns false when the success condition is broken and files are left 
(Encrypt line 677, Decrypt line 563), and the caller counts that as another 
error (`updateErrors()`, Encrypt line 422). One failing file gives Errors = 2. 
With "Success when number of errors lesser than", the limit is then reached one 
file too early.
   
   Expected: one error per failing file.
   
   **6. Decrypt: an empty or wrong GPG location stops the workflow**
   
   ActionPGPDecryptFiles creates the GPG object outside the try (line 241), so 
a GPG location that is empty or not found throws out of execute(): the workflow 
stops with an error and no hop is followed, whatever the success condition. 
Encrypt creates it inside its try (line 266) and is false with 1 error.
   
   Expected: the same as Encrypt, a false result.
   
   **7. Sign and Sign and encrypt can't use a key with a passphrase**
   
   Encrypt files with PGP has no passphrase option, and GPG.signFile() and 
signAndEncryptFile() don't take one (only decryptFile() passes a passphrase, 
through stdin with --pinentry-mode loopback). With a signing key that has a 
passphrase, GnuPG can't ask for it in batch mode and the file fails; it only 
works with a key without passphrase or a passphrase already cached by 
gpg-agent. #8206 and #8659 added signing and the choice of the signing user, 
but not the passphrase.
   
   Expected: a passphrase option for signing, passed the same way as for 
decryption.
   
   The current behaviour is documented on both action pages (PR #9195), so the 
docs need an update when these are fixed.
   
   ### Issue Priority
   
   Priority: 3
   
   ### Issue Component
   
   Component: Hop Gui


-- 
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