allthingssecurity opened a new pull request, #31005: URL: https://github.com/apache/camel/pull/31005
# Description [CAMEL-27619](https://issues.apache.org/jira/browse/CAMEL-27619) The ticket lists eight problems of camel-jsch (the scp component) that came up while the option descriptions were written for CAMEL-23832 (#30951). I checked each one against main and against JSch 2.28.8 (javap). Seven are fixed here, one is left as it is. Fixed: 1. **A missing ~/.ssh/known_hosts failed the connection.** With the default `useUserKnownHostsFile=true` and no `knownHostsFile`, the producer loaded `<home>/.ssh/known_hosts` as a mandatory resource and failed with "Cannot load known host file" when it did not exist, even with the default `strictHostKeyChecking=no`. A missing user known hosts file now means that no host is known, as with `useUserKnownHostsFile=false`, and `strictHostKeyChecking` decides. This is also what JSch does itself: `KnownHosts.setKnownHosts(String)` ignores a file that does not exist, and the sftp component of camel-ftp passes the path to JSch that way. A `knownHostsFile` that is set but cannot be read still fails, as before. 2. **keyboard-interactive login with a password never succeeded.** The password was only given through `UserInfo.getPassword()`, and `promptKeyboardInteractive()` returns null, which cancels the method. The producer now also sets the password on the JSch session. JSch then answers a keyboard-interactive request of one question that is not echoed and contains `password:` (the usual PAM prompt) with it. Any other question still goes to `promptKeyboardInteractive()` and is cancelled, so the password is never sent as the answer to, for example, a verification code. 3. **The JSch logger was global to the JVM.** `ScpComponent` called the static `JSch.setLogger()` when it started. The logger is now set on the JSch instance of each session (`JSch.setInstanceLogger()`), and the static logger is left as it is. The logger only reads `verboseLogging` and logs with the SLF4J logger of the component, so the sessions share one instance. Note on the ticket text: the sftp producer of camel-ftp sets the static JSch logger itself on each connect, so before this change it was rather the scp sessions after an sftp connect that logged with the camel-ftp logger, and the other way around; other JSch users in the JVM got the scp logger. 4. **An invalid chmod was replaced by 664 without a word.** It is still replaced by 664, and now logged at WARN with the value. I did not make it fail: an endpoint with, for example, `chmod=0644` works today (with 664), and would then fail to start. 5. **certFile and certUri do the same thing.** Both load from the file system, or from the classpath with the `classpath:` prefix, and `certFile` takes precedence. `certUri` is deprecated in favour of `certFile`, and its description no longer says that it loads from the classpath by default. Both keep working. 6. **Options marked secret that hold no secret.** `knownHostsFile`, `certFile`, `certUri`, `certBytes` and `preferredAuthentications` are no longer marked secret. The password, the private key options and the passphrase stay secret. 7. **Missing labels.** `verboseLogging` of the component has the label `advanced`, and `chmod` the label `producer`. The scp endpoint is producer only, so the Endpoint DSL methods do not move. Not changed: 8. **The inherited camel-ftp option texts.** `host`, `port`, `timeout` and `soTimeout` come from `RemoteFileConfiguration` of camel-ftp, so their descriptions cannot be changed for scp alone in this component. Excluding `soTimeout` would make an scp URI that sets it fail as an unknown option. I left this to the descriptions work. The 4.24 upgrade guide has an entry for points 1 to 6. This touches the same lines as #30951 (the `@UriParam` of the options of points 5 to 7, the doc page and the generated files), so whichever is merged second needs a small rebase. Text of #30951 that becomes wrong: the description of `useUserKnownHostsFile` says "If that file cannot be read, the producer fails to connect", which no longer holds for a file that does not exist. The `security = "secret"` of #30951 on the options of point 6 and the label-less `chmod` and `verboseLogging` would undo points 6 and 7 in a rebase that takes its side. Tests (new, unit tests against the embedded Apache MINA SSHD server of the module, no Docker): - `ScpUserKnownHostsFileMissingTest`: with `user.home` set to an empty directory, the producer sends the file with the default `strictHostKeyChecking=no`, and fails with "Failed to connect to" with `strictHostKeyChecking=yes`. - `ScpKeyboardInteractiveTest`: a server that offers only keyboard-interactive authentication (SSHD asks "Password: ") accepts the `password` option. - `ScpJschLoggerTest`: a static JSch logger set by the application is still the static logger after the producer sent a file. Against the main sources all four tests fail: "Cannot load known host file" (twice), the exchange fails as the login is refused, and the static logger is replaced by the logger of `ScpComponent`. Results (offline, module build of camel-jsch, test phase): 51 tests run, 0 failures, 0 errors, 3 skipped (skipped on main too). The new tests pass 5 runs in a row. Generated files: `scp.json` of the component and its catalog copy, the catalog copy of the doc page, `ScpEndpointUriFactory` (the secret property names), and the endpoint and component DSL (`ScpEndpointBuilderFactory`, `ScpComponentBuilderFactory`). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27619](https://issues.apache.org/jira/browse/CAMEL-27619). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-jsch and ran its unit tests, and committed the regenerated component JSON and URI factory. The catalog copies were updated to match them, and the endpoint and component DSL were generated from the catalog JSON with the camel-package goals, as an offline build of those modules was not possible here. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
