Croway opened a new pull request, #30679:
URL: https://github.com/apache/camel/pull/30679

   ## Summary
   
   Five commits:
   
   - **CAMEL-27453 camel-file - starting directory check: normalize paths 
without special prefixes.**
     - The producer's `jailStartingDirectory` check and the remote file 
consumers' starting directory check compacted paths with 
`FileUtil.compactPath`, which gives a leading `http:`, `https:`, `file:` or 
`classpath:` prefix and a drive such as `C:` a special meaning. A server gives 
them none.
     - The checks now use a new `GenericFileHelper.compactPathForContainment`, 
which treats every segment alike, and `isWithinDirectory` refuses a path with a 
`..` segment left anywhere in it.
     - Applied in `RemoteFileConsumer`, `GenericFileProducer` and 
`SmbConsumer`. `FileUtil.compactPath` and the local work directory check are 
unchanged.
   - **CAMEL-27453 camel-ftp - refuse a remote path with both a backslash and a 
`..` segment.** Where such a path resolves depends on the server, on the 
`separator` option and on the platform Camel runs on.
   - **CAMEL-27454 camel-ftp - a producer without a directory refuses absolute 
file names.**
     - With `jailStartingDirectory` enabled (the default), a producer endpoint 
without a directory in its URI refuses a file name starting with `/`, `\`, 
`C:/` or `C:\`.
     - `jailStartingDirectory=false` keeps the previous behaviour.
     - The 4.24 upgrade guide has an entry for it.
   - **CAMEL-27453 camel-ftp, camel-mina-sftp - stepwise: stay in the current 
directory for a path that compacts to it.**
     - A relative path such as `sub/..` compacts to empty, and every current 
directory starts with the empty string, so the stepwise change went up to the 
root of the server. It now stays in the current directory, and the 
parent-directory comparison uses whole segments.
     - A stepwise recursive poll skips a listed directory whose name is not a 
single name.
   - **CAMEL-27453 camel-ftp - handleDirectoryParserAbsoluteResult: change into 
a listed directory by its name.**
     - A recursive poll changed into a listed sub directory by the absolute 
path the server listed, so its files could not be downloaded.
     - It now changes into the directory by its name, relative to the directory 
being listed, and skips a listed directory that is not in it.
     - Listed files are still matched as listed.
     - The 4.24 upgrade guide has an entry for it.
   
   ## Tests
   
   - **New and extended tests:**
     - `GenericFileHelperTest`
     - `RemoteFileConsumerStartingDirectoryJailTest`, 
`RemoteFileProducerStartingDirectoryJailTest`
     - `FtpConsumerListedDirectoryNameTest`, with a `FakeFtpServer` that lists 
crafted names
     - `FtpProducerJailStartingDirectoryResolvedNameIT`
     - `SftpStepwiseChangeDirectoryIT` and `MinaSftpStepwiseChangeDirectoryIT`, 
using an embedded SSHD whose login home is not `/`
   - **Local run before the rebase onto current main:** 0 failures, 0 errors.
   
   | Module | Unit tests | ITs |
   |---|---|---|
   | camel-file | 52 | |
   | camel-ftp | 304 | 558 |
   | camel-mina-sftp | 53 | 319 |
   | camel-smb | 44 | |
   | camel-core file tests | 562 | |
   
   ## Backports
   
   camel-4.22.x and camel-4.18.x get CAMEL-27453 only, without CAMEL-27454, 
plus a docs note on producers without a directory. Links follow.
   


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