Skip to content

Commit dd867bd

Browse files
authored
fix: fix jetbrains toolbox connection tracking (#19348)
Fixes #18350 I attempted the route of relying on just the session env vars, in hopes that this issue was fixed in Toolbox and the process name matching was no longer need, but it was not a fruitful endeavor and it seems to be using the same connection logic as it did in gateway, just with new binary and flag names.
1 parent 560cf84 commit dd867bd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

agent/agentssh/agentssh.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const (
4646
// MagicProcessCmdlineJetBrains is a string in a process's command line that
4747
// uniquely identifies it as JetBrains software.
4848
MagicProcessCmdlineJetBrains = "idea.vendor.name=JetBrains"
49+
MagicProcessCmdlineToolbox = "com.jetbrains.toolbox"
50+
MagicProcessCmdlineGateway = "remote-dev-server"
4951

5052
// BlockedFileTransferErrorCode indicates that SSH server restricted the raw command from performing
5153
// the file transfer.

agent/agentssh/jetbrainstrack.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, reportConne
5353

5454
// If this is not JetBrains, then we do not need to do anything special. We
5555
// attempt to match on something that appears unique to JetBrains software.
56-
if !strings.Contains(strings.ToLower(cmdline), strings.ToLower(MagicProcessCmdlineJetBrains)) {
56+
if !isJetbrainsProcess(cmdline) {
5757
return newChannel
5858
}
5959

@@ -104,3 +104,18 @@ func (c *ChannelOnClose) Close() error {
104104
c.once.Do(c.done)
105105
return c.Channel.Close()
106106
}
107+
108+
func isJetbrainsProcess(cmdline string) bool {
109+
opts := []string{
110+
MagicProcessCmdlineJetBrains,
111+
MagicProcessCmdlineToolbox,
112+
MagicProcessCmdlineGateway,
113+
}
114+
115+
for _, opt := range opts {
116+
if strings.Contains(strings.ToLower(cmdline), strings.ToLower(opt)) {
117+
return true
118+
}
119+
}
120+
return false
121+
}

0 commit comments

Comments
 (0)