@@ -152,11 +152,16 @@ 'use strict' | ||
| } | ||
| if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) { | ||
| throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`) | ||
| } | ||
| // If both symlinks resolve to the same target, they are still distinct symlinks | ||
| // that can be copied/overwritten. Only check subdirectory constraints when | ||
| // the resolved paths are different. | ||
| if (resolvedSrc !== resolvedDest) { | ||
| if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) { | ||
| throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`) | ||
| } | ||
| // prevent copy if src is a subdir of dest since unlinking | ||
| // dest in this case would result in removing src contents | ||
| // and therefore a broken symlink would be created. | ||
| if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { | ||
| throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`) | ||
| // prevent copy if src is a subdir of dest since unlinking | ||
| // dest in this case would result in removing src contents | ||
| // and therefore a broken symlink would be created. | ||
| if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { | ||
| throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`) | ||
| } | ||
| } | ||
@@ -163,0 +168,0 @@ return copyLink(resolvedSrc, dest) |
+13
-8
@@ -159,11 +159,16 @@ 'use strict' | ||
| } | ||
| if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) { | ||
| throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`) | ||
| } | ||
| // If both symlinks resolve to the same target, they are still distinct symlinks | ||
| // that can be copied/overwritten. Only check subdirectory constraints when | ||
| // the resolved paths are different. | ||
| if (resolvedSrc !== resolvedDest) { | ||
| if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) { | ||
| throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`) | ||
| } | ||
| // do not copy if src is a subdir of dest since unlinking | ||
| // dest in this case would result in removing src contents | ||
| // and therefore a broken symlink would be created. | ||
| if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { | ||
| throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`) | ||
| // do not copy if src is a subdir of dest since unlinking | ||
| // dest in this case would result in removing src contents | ||
| // and therefore a broken symlink would be created. | ||
| if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { | ||
| throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`) | ||
| } | ||
| } | ||
@@ -170,0 +175,0 @@ |
+1
-1
| { | ||
| "name": "fs-extra", | ||
| "version": "11.3.2", | ||
| "version": "11.3.3", | ||
| "description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.", | ||
@@ -5,0 +5,0 @@ "engines": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
56838
0.94%1286
0.78%3
-25%