toolcraft-openapi 0.0.72 → 0.0.73
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/bin/generate.js +33 -6
- package/package.json +2 -2
package/dist/bin/generate.js
CHANGED
|
@@ -554,20 +554,47 @@ async function assertSafeProjectPath(fs, cwd, filePath) {
|
|
|
554
554
|
path.isAbsolute(relativePath)) {
|
|
555
555
|
throw new Error("Generated skill output must remain inside the project directory.");
|
|
556
556
|
}
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
557
|
+
const canonicalRoot = await fs.realpath(cwd);
|
|
558
|
+
const canonicalFileParent = await realpathExistingAncestor(fs, path.dirname(filePath));
|
|
559
|
+
const relativeParentPath = path.relative(canonicalRoot, canonicalFileParent);
|
|
560
|
+
if (relativeParentPath === ".." ||
|
|
561
|
+
relativeParentPath.startsWith(`..${path.sep}`) ||
|
|
562
|
+
path.isAbsolute(relativeParentPath)) {
|
|
563
|
+
throw new Error("Generated skill output must remain inside the project directory.");
|
|
564
|
+
}
|
|
565
|
+
try {
|
|
566
|
+
if ((await fs.lstat(filePath)).isSymbolicLink()) {
|
|
567
|
+
const canonicalFilePath = await fs.realpath(filePath);
|
|
568
|
+
const relativeFilePath = path.relative(canonicalRoot, canonicalFilePath);
|
|
569
|
+
if (relativeFilePath === ".." ||
|
|
570
|
+
relativeFilePath.startsWith(`..${path.sep}`) ||
|
|
571
|
+
path.isAbsolute(relativeFilePath)) {
|
|
562
572
|
throw new Error("Generated skill output must remain inside the project directory.");
|
|
563
573
|
}
|
|
564
574
|
}
|
|
575
|
+
}
|
|
576
|
+
catch (error) {
|
|
577
|
+
if (!isNotFoundError(error)) {
|
|
578
|
+
throw error;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
async function realpathExistingAncestor(fs, targetPath) {
|
|
583
|
+
let currentPath = targetPath;
|
|
584
|
+
while (true) {
|
|
585
|
+
try {
|
|
586
|
+
return await fs.realpath(currentPath);
|
|
587
|
+
}
|
|
565
588
|
catch (error) {
|
|
566
589
|
if (!isNotFoundError(error)) {
|
|
567
590
|
throw error;
|
|
568
591
|
}
|
|
592
|
+
const parentPath = path.dirname(currentPath);
|
|
593
|
+
if (parentPath === currentPath) {
|
|
594
|
+
throw error;
|
|
595
|
+
}
|
|
596
|
+
currentPath = parentPath;
|
|
569
597
|
}
|
|
570
|
-
currentPath = path.dirname(currentPath);
|
|
571
598
|
}
|
|
572
599
|
}
|
|
573
600
|
async function atomicWriteGeneratedFile(fs, outputDir, filePath, contents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"toolcraft-openapi-generate": "dist/bin/generate.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"toolcraft": "0.0.
|
|
31
|
+
"toolcraft": "0.0.73",
|
|
32
32
|
"auth-store": "^0.0.1",
|
|
33
33
|
"fast-string-width": "^3.0.2",
|
|
34
34
|
"fast-wrap-ansi": "^0.2.0",
|