zoekt-indexserver: Prevent invalid config from causing an NPE#612
Merged
Conversation
When the user specifies an invalid mirror config that contains an entry
without any of the GithubUser / GithubOrg / ... repository definitions,
zoekt-indexserver would crash, because `cmd` stays `nil` and causes a
SIGSEGV when it is later accessed in `main.executeMirror`:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0xb0ddba]
goroutine 10 [running]:
main.loggedRun(0x0)
/home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:45 +0x5a
main.executeMirror({0xc000d5a000?, 0x16?, 0x0?}, {0xc000246dc0, 0xc}, 0x0?)
/home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:265 +0x1dbd
main.periodicMirrorFile({0xc000246dc0, 0xc}, 0xc000283dc0, 0x0?)
/home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/config.go:150 +0x256
created by main.main
/home/philwo/go/pkg/mod/github.com/sourcegraph/zoekt@v0.0.0-20230711133754-25c1ea5177fb/cmd/zoekt-indexserver/main.go:294 +0x685
```
Example config how to trigger this:
```
[
{
"CredentialPath": "/zoekt/etc/github-token"
},
...
]
```
keegancsmith
approved these changes
Jul 12, 2023
Member
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the user specifies an invalid mirror config that contains an entry without any of the GithubUser / GithubOrg / ... repository definitions, zoekt-indexserver would crash, because
cmdstaysniland causes a SIGSEGV when it is later accessed inmain.executeMirror:Example config how to trigger this: