gnodet-bot commented on code in PR #31005:
URL: https://github.com/apache/camel/pull/31005#discussion_r4720616278
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java:
##########
@@ -74,11 +74,20 @@ public void setVerboseLogging(boolean verboseLogging) {
this.verboseLogging = verboseLogging;
}
+ /**
+ * The logger that the JSch instance of each session of the endpoints of
this component logs with.
+ */
+ public Logger getJschLogger() {
Review Comment:
⚠️ **`getJschLogger()` is `public` but serves as internal API**
`ScpOperations.createSession()` uses this method to inject the logger into
each JSch session. Making it `public` exposes it on the component's
externally-visible API — callers that do `context.getComponent("scp",
ScpComponent.class).getJschLogger()` or sub-class `ScpComponent` will see it as
a stable contract.
Since `ScpOperations` is in the same package as `ScpComponent`, `protected`
or package-private would be sufficient and would not expose an implementation
detail. Alternatively, annotate it with `@InternalApi` to signal its non-stable
nature.
As written, any sub-class that overrides `initJsch()` and forgets to set
`jschLogger` will silently produce a `null` return here — the guard in
`ScpOperations` (`scp.getJschLogger() != null`) will then skip the per-instance
logger entirely, defeating the main point of this change with no warning.
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java:
##########
@@ -393,6 +393,16 @@ private Session createSession(ScpConfiguration config) {
session = jsch.getSession(config.getUsername(), config.getHost(),
config.getPort());
session.setTimeout(config.getTimeout());
session.setUserInfo(new SessionUserInfo(config));
+ if (ObjectHelper.isNotEmpty(config.getCiphers())) {
+ // on the session: JSch.setConfig would change the ciphers of
every JSch session in the JVM
+ LOG.trace("Using ciphers: {}", config.getCiphers());
+ session.setConfig("cipher.s2c", config.getCiphers());
+ session.setConfig("cipher.c2s", config.getCiphers());
+ }
+ if (config.getPassword() != null) {
+ // JSch answers a keyboard-interactive password prompt only
with the password of the session
+ session.setPassword(config.getPassword());
Review Comment:
📝 **Add a comment explaining why `promptKeyboardInteractive` returning
`null` is correct**
`session.setPassword()` is set here, and
`SessionUserInfo.promptKeyboardInteractive()` (at the bottom of this file)
still returns `null`. On first glance this appears to be a gap: if the callback
returns null, how does keyboard-interactive auth succeed?
The answer: when `session.setPassword()` is set on the session, JSch answers
a single non-echoed `password:` prompt internally without calling
`UserInfo.promptKeyboardInteractive()` at all. The null return from `UserInfo`
correctly cancels any multi-step or echoed challenge. This is correct per JSch
internals but non-obvious from the code.
Please add a brief comment near `setPassword()` and in
`promptKeyboardInteractive()` explaining the split responsibility — otherwise
the next reader will likely "fix" the null return and break the security
invariant that cancels password-change requests.
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java:
##########
@@ -74,11 +74,20 @@ public void setVerboseLogging(boolean verboseLogging) {
this.verboseLogging = verboseLogging;
}
+ /**
+ * The logger that the JSch instance of each session of the endpoints of
this component logs with.
Review Comment:
💡 **Javadoc — passive voice and awkward phrasing (low)**
> *The logger that the JSch instance of each session of the endpoints of
this component logs with.*
Suggested rewrite:
```suggestion
* Returns the logger set on the JSch instance of each session created
by this component's endpoints.
```
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java:
##########
@@ -74,11 +74,20 @@ public void setVerboseLogging(boolean verboseLogging) {
this.verboseLogging = verboseLogging;
}
+ /**
+ * The logger that the JSch instance of each session of the endpoints of
this component logs with.
+ */
+ public Logger getJschLogger() {
Review Comment:
⚠️ **`getJschLogger()` is `public` but serves as internal API**
`ScpOperations.createSession()` uses this method to inject the logger into
each JSch session. Making it `public` exposes it on the component's
externally-visible API — callers that do `context.getComponent("scp",
ScpComponent.class).getJschLogger()` or sub-class `ScpComponent` will see it as
a stable contract.
Since `ScpOperations` is in the same package as `ScpComponent`, `protected`
or package-private would be sufficient and would not expose an implementation
detail. Alternatively, annotate it with `@InternalApi` to signal its non-stable
nature.
As written, any sub-class that overrides `initJsch()` and forgets to set
`jschLogger` will silently produce a `null` return here — the guard in
`ScpOperations` (`scp.getJschLogger() != null`) will then skip the per-instance
logger entirely, defeating the main point of this change with no warning.
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java:
##########
@@ -393,6 +393,16 @@ private Session createSession(ScpConfiguration config) {
session = jsch.getSession(config.getUsername(), config.getHost(),
config.getPort());
session.setTimeout(config.getTimeout());
session.setUserInfo(new SessionUserInfo(config));
+ if (ObjectHelper.isNotEmpty(config.getCiphers())) {
+ // on the session: JSch.setConfig would change the ciphers of
every JSch session in the JVM
+ LOG.trace("Using ciphers: {}", config.getCiphers());
+ session.setConfig("cipher.s2c", config.getCiphers());
+ session.setConfig("cipher.c2s", config.getCiphers());
+ }
+ if (config.getPassword() != null) {
+ // JSch answers a keyboard-interactive password prompt only
with the password of the session
+ session.setPassword(config.getPassword());
Review Comment:
📝 **Add a comment explaining why `promptKeyboardInteractive` returning
`null` is correct**
`session.setPassword()` is set here, and
`SessionUserInfo.promptKeyboardInteractive()` (at the bottom of this file)
still returns `null`. On first glance this appears to be a gap: if the callback
returns null, how does keyboard-interactive auth succeed?
The answer: when `session.setPassword()` is set on the session, JSch answers
a single non-echoed `password:` prompt internally without calling
`UserInfo.promptKeyboardInteractive()` at all. The null return from `UserInfo`
correctly cancels any multi-step or echoed challenge. This is correct per JSch
internals but non-obvious from the code.
Please add a brief comment near `setPassword()` and in
`promptKeyboardInteractive()` explaining the split responsibility — otherwise
the next reader will likely "fix" the null return and break the security
invariant that cancels password-change requests.
##########
components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpComponent.java:
##########
@@ -74,11 +74,20 @@ public void setVerboseLogging(boolean verboseLogging) {
this.verboseLogging = verboseLogging;
}
+ /**
+ * The logger that the JSch instance of each session of the endpoints of
this component logs with.
Review Comment:
💡 **Javadoc — passive voice and awkward phrasing (low)**
> *The logger that the JSch instance of each session of the endpoints of
this component logs with.*
Suggested rewrite:
```suggestion
* Returns the logger set on the JSch instance of each session created
by this component's endpoints.
```
--
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]