kibi-plugin-builtin 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # kibi-plugin-builtin
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f53950a]
8
+ - kibi-plugin-sdk@0.6.0
9
+
10
+ ## 0.5.3
11
+
12
+ ### Patch Changes
13
+
14
+ - 25d537e: Symbol coordinate refresh no longer treats `sourceFile` as an unrestricted filesystem path. Absolute paths and `..` escapes are rejected at upsert and refused at read time, so MCP/CLI coordinate refresh cannot probe files outside the workspace.
15
+
16
+ Tighten Prolog `sourceFile` typing to `workspace_relpath` in `kibi-core` (and the CLI schema mirror), add `resolveWorkspaceSourceAbsolute` confinement (with realpath checks), and cover the escape oracle with regression tests in CLI and MCP.
17
+
3
18
  ## 0.5.2
4
19
 
5
20
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ts-morph-enrichment.d.ts","sourceRoot":"","sources":["../../src/symbols/ts-morph-enrichment.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAGD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAKD,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,mBAAmB,EAAE,EAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuGhC"}
1
+ {"version":3,"file":"ts-morph-enrichment.d.ts","sourceRoot":"","sources":["../../src/symbols/ts-morph-enrichment.ts"],"names":[],"mappings":"AAqCA,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAGD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAKD,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,mBAAmB,EAAE,EAC9B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuGhC"}
@@ -19,6 +19,7 @@ import { access, readFile } from "node:fs/promises";
19
19
  import * as path from "node:path";
20
20
  import { tsMorph } from "./ts-morph-runtime.js";
21
21
  import { SUPPORTED_SOURCE_EXTENSIONS, isPrivateClassMember, onlyCandidate, } from "./ts-morph-shared.js";
22
+ import { resolveWorkspaceSourceAbsolute } from "./workspace-path.js";
22
23
  // implements REQ-capability-plugin-builtin-parity-v1
23
24
  export async function enrichSymbolCoordinatesWithTsMorph(entries, workspaceRoot) {
24
25
  const project = new (tsMorph().Project)({
@@ -102,9 +103,9 @@ export async function enrichSymbolCoordinatesWithTsMorph(entries, workspaceRoot)
102
103
  async function resolveSourcePath(sourceFile, workspaceRoot) {
103
104
  if (!sourceFile)
104
105
  return null;
105
- const absolute = path.isAbsolute(sourceFile)
106
- ? sourceFile
107
- : path.resolve(workspaceRoot, sourceFile);
106
+ const absolute = resolveWorkspaceSourceAbsolute(workspaceRoot, sourceFile);
107
+ if (absolute === null)
108
+ return null;
108
109
  const ext = path.extname(absolute).toLowerCase();
109
110
  if (!SUPPORTED_SOURCE_EXTENSIONS.has(ext))
110
111
  return null;
@@ -0,0 +1,3 @@
1
+ /** Return null when `candidate` escapes `workspaceRoot`. */
2
+ export declare function resolveWorkspaceSourceAbsolute(workspaceRoot: string, sourceFile: string): string | null;
3
+ //# sourceMappingURL=workspace-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-path.d.ts","sourceRoot":"","sources":["../../src/symbols/workspace-path.ts"],"names":[],"mappings":"AAoBA,4DAA4D;AAE5D,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CA+Bf"}
@@ -0,0 +1,55 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { realpathSync } from "node:fs";
19
+ import path from "node:path";
20
+ /** Return null when `candidate` escapes `workspaceRoot`. */
21
+ // implements REQ-symbol-sourcefile-workspace-confinement
22
+ export function resolveWorkspaceSourceAbsolute(workspaceRoot, sourceFile) {
23
+ if (sourceFile.trim() === "")
24
+ return null;
25
+ let slashed = sourceFile.replaceAll("\\", "/");
26
+ const foreignAbsolute = /^[A-Za-z]:\//.test(slashed) || slashed.startsWith("//");
27
+ if (slashed.startsWith("/") || foreignAbsolute) {
28
+ if (foreignAbsolute && path.sep === "/")
29
+ return null;
30
+ const root = path.resolve(workspaceRoot);
31
+ const relative = path.relative(root, path.resolve(sourceFile));
32
+ if (relative === "" || path.isAbsolute(relative))
33
+ return null;
34
+ slashed = relative.replaceAll("\\", "/");
35
+ }
36
+ const normalized = path.posix.normalize(slashed).replace(/\/+$/, "");
37
+ if (normalized === "" ||
38
+ normalized === "." ||
39
+ normalized === ".." ||
40
+ normalized.startsWith("../")) {
41
+ return null;
42
+ }
43
+ const absolute = path.resolve(workspaceRoot, normalized);
44
+ try {
45
+ const realRoot = realpathSync.native(path.resolve(workspaceRoot));
46
+ const realFile = realpathSync.native(absolute);
47
+ const confined = path.relative(realRoot, realFile);
48
+ if (confined.startsWith("..") || path.isAbsolute(confined))
49
+ return null;
50
+ return realFile;
51
+ }
52
+ catch {
53
+ return absolute;
54
+ }
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-plugin-builtin",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Default Kibi capability plugins: TS symbol extraction, ontology pack, and semantic classifier",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "kibi-plugin-sdk": "^0.5.0",
40
+ "kibi-plugin-sdk": "^0.6.0",
41
41
  "ts-morph": "^23.0.0"
42
42
  },
43
43
  "devDependencies": {