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

   ## Summary
   
   Backport of the CAMEL-27453 commits from main (the main PR also carries 
CAMEL-27454, which is not backported). 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-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.
   - **CAMEL-27453 camel-ftp - docs.** The ftp, sftp and mina-sftp pages now 
say that a producer endpoint without a directory writes an absolute file name 
to that absolute path on the server. If file names can come from untrusted 
input, configure a directory or use `flatten=true`.
   
   ## Tests
   
   See the main PR for the full list of tests. Local results on this branch are 
below.
   
   | Module | Unit tests | ITs |
   |---|---|---|
   | camel-file | 33 | |
   | camel-ftp | 140 | 22 relevant ITs |
   | camel-mina-sftp | 27 | 16 |
   | camel-smb | 7 | |
   
   0 failures. The ITs run were the jail, stepwise, resolved-name and 
overrule-once ITs.
   


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