A `../` entry in package.json `workspaces` makes a folder outside the project count as a workspace package, and a call gets linked to the wrong function
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- json, node.js, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu với src/resolution/workspace-packages.ts, đặc biệt là expandWorkspaceGlob, và so sánh các trường hợp tái hiện được cung cấp: trường hợp đối chứng, trong dự án và ngoài dự án. Thêm một bài kiểm tra hồi quy cho mục workspace ../; hoàn thành khi mục này không được xem là một gói workspace và các trường hợp đối chứng vẫn hoạt động như đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
With "workspaces": ["../sibling"] in a project's package.json, CodeGraph treats the folder ../sibling (outside the indexed project) as a workspace package. An import of that package then resolves to an unrelated function inside the project: run() is shown calling pad in src/util.ts, although the import is left-pad2, an external package. With the same dependency and no workspaces field, or with an in-project glob such as packages/*, run() has no such call.
Repro (CodeGraph 1.6.2 built from upstream 60b0d7a9, Node v24.22.2, Linux):
// repro.cjs — usage: node repro.cjs <path-to-codegraph>/dist <control|inproject|outside>
const fs = require('fs'), os = require('os'), path = require('path');
const [dist, mode] = process.argv.slice(2);
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-ws-'));
const put = (f, t) => { fs.mkdirSync(path.dirname(path.join(root, f)), { recursive: true }); fs.writeFileSync(path.join(root, f), t); };
const workspaces = { control: undefined, inproject: ['packages/*'], outside: ['../sibling'] }[mode];
put('app/package.json', JSON.stringify({ name: 'app', ...(workspaces ? { workspaces } : {}), dependencies: { 'left-pad2': '^1.0.0' } }));
put('app/src/util.ts', 'export function pad(s) { return s; }\n');
put('app/src/main.ts', "import { pad } from 'left-pad2';\nexport function run() { return pad('x'); }\n");
put('sibling/package.json', JSON.stringify({ name: 'left-pad2', main: 'index.ts' }));
put('sibling/index.ts', 'export function pad(s) { return s; }\n');
const CodeGraph = require(path.join(dist, 'index.js')).default;
(async () => {
const cg = CodeGraph.initSync(path.join(root, 'app'));
await cg.indexAll();
const run = cg.searchNodes('run').find((r) => r.node.name === 'run');
console.log(mode, 'run() calls:', cg.getCallees(run.node.id).map((c) => `${c.node.name} @ ${c.node.filePath}`));
cg.close();
})().finally(() => fs.rmSync(root, { recursive: true, force: true }));
Output (run just now):
control run() calls: []
inproject run() calls: []
outside run() calls: [ 'pad @ src/util.ts' ]
Cause: expandWorkspaceGlob in src/resolution/workspace-packages.ts joins each workspaces entry onto the project root without checking that the result stays inside the root, so ../sibling is scanned as a package folder. (The same file was last verified identical at upstream cd04b21a.)
Suggested fix: skip any entry that has a .. segment, and add a test with a ../ workspace entry. A matching guard is small (three lines); I can send it as a PR if you want one.
Not claimed: this does not read or index files outside the project, and I found no way to expose their contents. Only .. segments escape; an absolute path in workspaces did not (tried). I did not trace why the wrong edge lands on src/util.ts rather than on no edge; I only observed that it does and that the control cases do not.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 3 giờ 37 phút
- Pull request đã merge (30 ngày)
- 533
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của colbymchenry/codegraph
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launchĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
colbymchenry/codegraph#3054 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#2974 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Security Vulnerabiliy] Vulnerable bundled `node.exe` detected (Node2Shell - CVE-2026-111497)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
colbymchenry/codegraph#2959 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
codegraph ui - does not workĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
colbymchenry/codegraph#1900 · 2 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
colbymchenry/codegraph#1700 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của colbymchenry/codegraph
Issue tương tự
-
LSP: Invalid buffer id in previous_result_ids during workspace/diagnostic/refreshCó thể đã có người làm @sharky720 đã nhận hôm nay. Đang mởdiagnostic lsp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
neovim/neovim#42629 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
epics-base/epics-base#1034 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
-
kind: bug preview-effort: small priority: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày