Skip to content
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
1 change: 1 addition & 0 deletions lsp/base_service_client/base_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ReferencedCondition struct {
// references.
func EvaluateReferenced[T base](t T, ctx ctx, cap string, info []byte) (resp, error) {
sc := t.GetLSPServiceClientBase()
sc.Log.Info("Evaluate Call", "cap", cap, "info", info)

var cond ReferencedCondition
err := yaml.Unmarshal(info, &cond)
Expand Down
4 changes: 4 additions & 0 deletions lsp/base_service_client/base_service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ func NewLSPServiceClientBase(
} else {
sc.Log.Info("using provided connection", "conn", c.RPC)
sc.Conn = c.RPC
sc.ServerCapabilities = protocol.ServerCapabilities{
AssumeWorks: true,
}
}
// Create the caches for the various handler stuffs
sc.PublishDiagnosticsCache = NewAwaitCache[string, []protocol.Diagnostic]()
Expand Down Expand Up @@ -353,6 +356,7 @@ func (sc *LSPServiceClientBase) GetAllDeclarations(ctx context.Context, workspac
// Client may or may not support the "workspace/symbol" method, so we must
// check before calling.

sc.Log.Info("server caps", "supports", sc.ServerCapabilities.Supports("workspace/symbol"))
if sc.ServerCapabilities.Supports("workspace/symbol") {
params := protocol.WorkspaceSymbolParams{
Query: query,
Expand Down
3 changes: 3 additions & 0 deletions lsp/protocol/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ package protocol
// FIXME: Implement all requests!
// TODO: Evaluate tradeoffs of turning this into a map?
func (c *ServerCapabilities) Supports(method string) bool {
if c.AssumeWorks {
return true
}
Comment on lines +8 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Do not globally bypass capability checks; narrow the scope

Global early-return on AssumeWorks defeats the guard that prevents sending unsupported methods to servers that may crash (as noted in the file header). This is a high‑risk regression.

Constrain the bypass to an explicit, minimal allowlist (e.g., only the method you need to unblock), and fall back to existing switch logic otherwise. Example:

-	if c.AssumeWorks {
-		return true
-	}
+	if c.AssumeWorks {
+		switch method {
+		case "workspace/symbol":
+			return true
+		}
+	}

If more methods are required, make the list configurable per provider rather than blanket enabling.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In lsp/protocol/extensions.go around lines 8-10, the code currently returns true
unconditionally when c.AssumeWorks is set which bypasses all capability checks;
change this to only bypass for a minimal allowlist of explicit method names (or
provider-configurable list) by checking if the requested method is in that
allowlist and return true only in that case, otherwise fall through to the
existing switch/capability logic so unsupported methods are still guarded
against.

switch method {
// case "$/cancelRequest":
// case "$/logTrace":
Expand Down
1 change: 1 addition & 0 deletions lsp/protocol/tsprotocol.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions provider/grpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ func (g *grpcProvider) Init(ctx context.Context, log logr.Logger, config provide
return nil, provider.InitConfig{}, err
}

if config.PipeName != "" {
config.Initialized = true
}

g.log.Info("provider configuration", "config", config)
c := pb.Config{
Location: config.Location,
Expand Down
2 changes: 1 addition & 1 deletion provider/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (s *server) Init(ctx context.Context, config *libgrpc.Config) (*libgrpc.Ini
NoProxy: config.Proxy.NoProxy,
},
PipeName: config.LanguageServerPipe,
Initialized: config.Initialized,
Initialized: config.LanguageServerPipe != "",
}

newCtx := context.Background()
Expand Down
3 changes: 1 addition & 2 deletions provider_pod_local_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"dependencyFolders": [],

"dependencyProviderPath": "/usr/local/bin/golang-dependency-provider"
},
"pipeName": "/tmp/go-pls-pipe-test"
}
}]
},
{
Expand Down
Loading