Skip to content
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

ctags: allow binary to be anything with validation #652

Merged
merged 1 commit into from
Oct 5, 2023
Merged

Conversation

keegancsmith
Copy link
Member

Previously we enforced the binary was called universal-ctags. However, we let users override the name of the binary, so if they override it we should use it. To prevent footguns, we now validate the binary was built with the interactive feature.

In the case of scip-ctags we use the old validation of just checking the name.

Additionally we fix a bug that was introduced where if symbols are optional we continue if parsing fails.

Test Plan: indexed with and without universal-ctags. Ctags on my mbp points to something from xcode which wouldn't work

  $ CTAGS_COMMAND=ctags go run ./cmd/zoekt-git-index -require_ctags .
  2023/10/04 17:08:12 indexGitRepo(/Users/keegan/src/github.com/sourcegraph/zoekt, delta=false): build.NewBuilder: ctags.NewParserMap: ctags binary is not universal-ctags or is not compiled with +interactive feature: bin=ctags
  exit status 1

  $ CTAGS_COMMAND=universal-ctags go run ./cmd/zoekt-git-index -require_ctags .
  2023/10/04 17:08:29 finished github.com%2Fsourcegraph%2Fzoekt_v16.00000.zoekt: 8657338 index bytes (overhead 2.9)

  $ CTAGS_COMMAND=ctags go run ./cmd/zoekt-git-index .
  2023/10/04 17:08:40 finished github.com%2Fsourcegraph%2Fzoekt_v16.00000.zoekt: 8538246 index bytes (overhead 2.9)

Fixes https://github.com/sourcegraph/sourcegraph/issues/57336

Previously we enforced the binary was called universal-ctags. However,
we let users override the name of the binary, so if they override it we
should use it. To prevent footguns, we now validate the binary was built
with the interactive feature.

In the case of scip-ctags we use the old validation of just checking the
name.

Additionally we fix a bug that was introduced where if symbols are
optional we continue if parsing fails.

Test Plan: indexed with and without universal-ctags. Ctags on my mbp
points to something from xcode which wouldn't work

  $ CTAGS_COMMAND=ctags go run ./cmd/zoekt-git-index -require_ctags .
  2023/10/04 17:08:12 indexGitRepo(/Users/keegan/src/github.com/sourcegraph/zoekt, delta=false): build.NewBuilder: ctags.NewParserMap: ctags binary is not universal-ctags or is not compiled with +interactive feature: bin=ctags
  exit status 1

  $ CTAGS_COMMAND=universal-ctags go run ./cmd/zoekt-git-index -require_ctags .
  2023/10/04 17:08:29 finished github.com%2Fsourcegraph%2Fzoekt_v16.00000.zoekt: 8657338 index bytes (overhead 2.9)

  $ CTAGS_COMMAND=ctags go run ./cmd/zoekt-git-index .
  2023/10/04 17:08:40 finished github.com%2Fsourcegraph%2Fzoekt_v16.00000.zoekt: 8538246 index bytes (overhead 2.9)
@keegancsmith keegancsmith requested review from eseliger, SuperAuguste and a team October 4, 2023 15:21
Comment on lines +124 to +126
func NewParser(parserType CTagsParserType, bin string) (Parser, error) {
if err := checkBinary(parserType, bin); err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

is this code path run often? ie. would this spawn a ton of processes?

Copy link
Member Author

Choose a reason for hiding this comment

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

once per index job, so acceptable. IE before this change we would do one long running subprocess to universal-ctags (and communicate over stdio), now before we start the long lived process we run this first. Long lived == time it takes to index a repo.

@keegancsmith keegancsmith merged commit cc1b5cd into main Oct 5, 2023
8 checks passed
@keegancsmith keegancsmith deleted the k/ctags branch October 5, 2023 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should zoekt permit ctags binaries not named universal-ctags?
2 participants