T09 · Insecure Skill Coding Practices
- Location
scripts/migrate-vscode.ps1:59- Finding
Source Data Is Deleted After Copy Failures Are Suppressed
- Content
View full analysis
&1 | Out-Null ``` `scripts/migrate-npm.ps1:28-30`: ```powershell Copy-Item -Path "$npmCachePath\*" -Destination $DstPath -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $npmCachePath -Recurse -Force -ErrorAction Stop cmd /c "mklink /J `"$npmCachePath`" `"$DstPath`"" 2>&1 | Out-Null ``` `scripts/migrate-yarn.ps1:39-41`: ```powershell Copy-Item -Path "$yarnCachePath\*" -Destination $dstFull -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $yarnCachePath -Recurse -Force -ErrorAction Stop cmd /c "mklink /J `"$yarnCachePath`" `"$dstFull`"" 2>&1 | Out-Null ``` `SKILL.md:148-150`: ```powershell Copy-Item "$Src\*" $Dst -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $Src -Recurse -Force cmd /c "mklink /J `"$Src`" `"$Dst`"" 2>&1 | Out-Null ``` ### Technical Analysis The migration sequence suppresses all non-terminating errors raised by `Copy-Item` and then unconditionally removes the original directory. Copy operations may fail because of locked files, access-control restrictions, insufficient destination space, path-length limitations, storage disconnection, or other I/O errors. Because `-ErrorAction SilentlyContinue` hides these failures, the scripts do not establish that the destination is a complete copy before executing recursive deletion. They also do not compare source and destination file counts, sizes, or hashes. Junction creation occurs only after deletion, and failure to create ...[truncated 1428 chars]- Remediation
View remediation
