codex-plugin-doctor 0.10.0 → 0.10.1
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/dist/core/fix-plan.js +17 -0
- package/package.json +1 -1
package/dist/core/fix-plan.js
CHANGED
|
@@ -4,6 +4,11 @@ import { validatePlugin } from "./validate-plugin.js";
|
|
|
4
4
|
function relativeToTarget(targetPath, candidatePath) {
|
|
5
5
|
return path.relative(targetPath, candidatePath).replace(/\\/g, "/");
|
|
6
6
|
}
|
|
7
|
+
function isPathWithinRoot(rootPath, candidatePath) {
|
|
8
|
+
const relativePath = path.relative(rootPath, candidatePath);
|
|
9
|
+
return (relativePath === "" ||
|
|
10
|
+
(!relativePath.startsWith("..") && !path.isAbsolute(relativePath)));
|
|
11
|
+
}
|
|
7
12
|
export async function buildFixPlan(targetPath) {
|
|
8
13
|
const result = await validatePlugin(targetPath);
|
|
9
14
|
const rootPath = result.targetPath;
|
|
@@ -38,6 +43,12 @@ export async function buildFixPlan(targetPath) {
|
|
|
38
43
|
.catch(() => ({}));
|
|
39
44
|
if (typeof manifest.skills === "string") {
|
|
40
45
|
const skillsPath = path.resolve(rootPath, manifest.skills);
|
|
46
|
+
if (!isPathWithinRoot(rootPath, skillsPath)) {
|
|
47
|
+
return {
|
|
48
|
+
targetPath: rootPath,
|
|
49
|
+
actions
|
|
50
|
+
};
|
|
51
|
+
}
|
|
41
52
|
if (await directoryExists(skillsPath)) {
|
|
42
53
|
for (const entry of await readdir(skillsPath, { withFileTypes: true })) {
|
|
43
54
|
if (!entry.isDirectory()) {
|
|
@@ -70,6 +81,12 @@ export async function buildFixPlan(targetPath) {
|
|
|
70
81
|
}
|
|
71
82
|
if (typeof manifest.mcpServers === "string") {
|
|
72
83
|
const mcpConfigPath = path.resolve(rootPath, manifest.mcpServers);
|
|
84
|
+
if (!isPathWithinRoot(rootPath, mcpConfigPath)) {
|
|
85
|
+
return {
|
|
86
|
+
targetPath: rootPath,
|
|
87
|
+
actions
|
|
88
|
+
};
|
|
89
|
+
}
|
|
73
90
|
if (!(await fileExists(mcpConfigPath))) {
|
|
74
91
|
actions.push({
|
|
75
92
|
id: "mcp.scaffold_config",
|
package/package.json
CHANGED