-
Notifications
You must be signed in to change notification settings - Fork 899
fix: track JetBrains connections #10968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c9a226f
feat: implement jetbrains agentssh tracking
Emyrk 2447970
Add unit test to confirm tracking
Emyrk 76d3a24
implement unit test to verify jetbrains functionality
Emyrk adf2fb3
Implement port process inspection
code-asher ad034f2
Add JetBrains tracking to bottom bar
code-asher 34b7c5e
Elaborate on process name check comment
code-asher dce56fd
Comment that localForwardChannelData is copied
code-asher 7139448
Comment ChannelAccepterWatcher
code-asher 6e8f235
Rename channel watcher to be specific to Jetbrains
code-asher 4d65478
Log unmarshal failure
code-asher 254a5b6
Add constant for JetBrains magic string
code-asher a75ed6c
Fix JetBrains tracking test
code-asher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Implement port process inspection
- Loading branch information
commit adf2fb37a942cb7b1885ae692262103e79355517
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build linux | ||
|
||
package agentssh | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/cakturk/go-netstat/netstat" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
func getListeningPortProcessCmdline(port uint32) (string, error) { | ||
tabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool { | ||
return s.LocalAddr != nil && uint32(s.LocalAddr.Port) == port | ||
}) | ||
if err != nil { | ||
return "", xerrors.Errorf("inspect port %d: %w", port, err) | ||
} | ||
if len(tabs) == 0 { | ||
return "", nil | ||
} | ||
// The process name provided by go-netstat does not include the full command | ||
// line so grab that instead. | ||
pid := tabs[0].Process.Pid | ||
data, err := os.ReadFile(fmt.Sprintf("/proc/%d/cmdline", pid)) | ||
if err != nil { | ||
return "", xerrors.Errorf("read /proc/%d/cmdline: %w", pid, err) | ||
} | ||
return string(data), nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build !linux | ||
|
||
package agentssh | ||
|
||
func getListeningPortProcessCmdline(port uint32) (string, error) { | ||
// We are not worrying about other platforms at the moment because Gateway | ||
// only supports Linux anyway. | ||
return "", nil | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.