This is an archive of the discontinued LLVM Phabricator instance.

[clangd][index-sever] Limit results in repsonse
ClosedPublic

Authored by kadircet on May 5 2021, 8:42 AM.

Details

Summary

This is to prevent server from being DOS'd by possible malicious
parties issuing requests that can yield huge responses.

One possible drawback is on rename workflow. As it really requests all
occurences, but it has an internal limit on 50 files currently.
We are putting the limit on 10000 elements per response So for rename to regress
one should have 10k refs to a symbol in less than 50 files. This seems unlikely
and we fix it if there are complaints by giving up on the response based on the
number of files covered instead.

Diff Detail

Event Timeline

kadircet created this revision.May 5 2021, 8:42 AM
kadircet requested review of this revision.May 5 2021, 8:42 AM
kbobyrev accepted this revision.May 10 2021, 10:48 PM

Good point, thanks!

I wonder if this can somehow make the experience worse in _some_ specific cases but I can't think of anything on top of my mind, so this should be all good.

clang-tools-extra/clangd/index/remote/server/Server.cpp
152

nit (here and elsewhere): maybe add something like (requested X, sending Y) to the message for clarity. I don't expect this to be common anyway so probably verbosity isn't an issue here.

This revision is now accepted and ready to land.May 10 2021, 10:48 PM
kadircet updated this revision to Diff 344289.May 10 2021, 11:20 PM
kadircet marked an inline comment as done.
  • Change logs to mention original limits.
  • Add the test i forgot first time.
clang-tools-extra/clangd/index/remote/server/Server.cpp
152

doesn't really apply here, as lookup request doesn't have a limit. practically it triggers when user makes a request with more than LimitResults request ids in a single batch, but in theory could kick in earlier as an index can return multiple results for the same symbol id (but they never do).
changing the rest though.

This revision was landed with ongoing or failed builds.May 10 2021, 11:27 PM
This revision was automatically updated to reflect the committed changes.