Skip to content

fix: make agent ssh session env var case insensitive #9675

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 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions agent/agentssh/agentssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,13 @@ func (s *Server) sessionStart(session ssh.Session, extraEnv []string) (retErr er
magicType = strings.TrimPrefix(kv, MagicSessionTypeEnvironmentVariable+"=")
env = append(env[:index], env[index+1:]...)
}
switch magicType {
case MagicSessionTypeVSCode:

// Always force lowercase checking to be case-insensitive.
switch strings.ToLower(magicType) {
case strings.ToLower(MagicSessionTypeVSCode):
s.connCountVSCode.Add(1)
defer s.connCountVSCode.Add(-1)
case MagicSessionTypeJetBrains:
case strings.ToLower(MagicSessionTypeJetBrains):
s.connCountJetBrains.Add(1)
defer s.connCountJetBrains.Add(-1)
case "":
Expand Down
5 changes: 4 additions & 1 deletion agent/agentssh/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package agentssh

import (
"strings"

"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -78,5 +80,6 @@ func magicTypeMetricLabel(magicType string) string {
default:
magicType = "unknown"
}
return magicType
// Always be case insensitive
return strings.ToLower(magicType)
}