fix: a running watcher keeps writing through .codegraph after a pull turns it into a symlink

未关闭
#375 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
go
领域
backend, security

调研方向

Start by reading query.IndexDirs and trace how the watcher started by codegraph serve --mcp with auto-sync and codegraph daemon start flushes or swaps the store. Review #374 and #364 for the existing path checks and store swap behavior. Reproduce the checkout replacing .codegraph/store with an external symlink, then confirm the watcher refuses to write through it before each flush or swap.

由索引模型根据 Issue 内容生成。

描述

area:indexer bug needs-triage
What happens

A running watcher keeps writing index data through .codegraph after a pull or checkout replaces that directory with a symlink.

When a command or daemon.New starts, the root .codegraph and .codegraph/store paths are checked once (#374). A long-running watcher never checks them again. This applies to codegraph serve --mcp with auto-sync and to codegraph daemon start.

.codegraph is ignored by .gitignore because of the * inside it. When a commit adds .codegraph or .codegraph/store as a symlink, Git replaces the real directory without a warning.

The next flush or store swap then follows the new link. Depending on the target, it can:

  • rewrite the index of another project,
  • replace or delete the contents of another store, or
  • create a store at a dangling target outside the repository.

The Git half was observed. The codegraph half is not reproduced. It is a static trace from the security lane of the suite review of #374, rated medium.

Related: #372 (the start-up finding) and #364 (the store swap through a symlinked store directory).

What you expected instead

Before each flush or store swap, the watcher checks the index paths again with query.IndexDirs. If they now resolve outside the repository, the watcher stops with the same refusal error that a command gives.

Another option is to record the resolved paths at watcher start. Before each flush or swap, the watcher compares them with the current resolution and stops on any change.

Steps to reproduce

The Git half was observed with steps 1 to 4. Steps 5 and 6 cover the codegraph half, which is not yet reproduced.

  1. cd <repo>, a repository with a built index in .codegraph.
  2. codegraph daemon start
  3. Commit a symlink at .codegraph/store that points to a directory outside the repository.
  4. git checkout <commit that adds the symlink>
  5. If the checkout replaces the real .codegraph/store directory, edit a source file so the watcher flushes.
  6. Check whether the watcher writes into the symlink target.
Version

Built from source at main (commit d8517c46).

Platform

macOS (Darwin 27.2.0).

How did you install it?

Built from source

Languages in the affected repository

Not applicable.

Before submitting
  • I searched existing issues and this is not a duplicate
  • I checked the capability matrix and this is not a documented limitation
  • This is not a security vulnerability
主要语言
Go
星标
0
派生
0
平均合并
7 小时 42 分钟
30 天内合并 PR
111

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

seanb4t/codegraph-go 的其他 Issue

查看 seanb4t/codegraph-go 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。