Skip to content

Commit 435c25f

Browse files
feat(security): harden CLI security, fix ZIP extraction, upgrade dependencies to Node 18+ ESM targets
- Replaced all JSON.parse calls with safeJsonParse prototype pollution protection - Hardened share HTTP server with rate limiting (60 req/min), CORS restriction, and security headers - Fixed archiver v8 data descriptor ZIP extraction for commit rollback - Upgraded dependencies (commander 15.x, archiver 8.x, esbuild 0.28.x, ssh2 1.17.x) - Replaced deprecated pkg with @yao-pkg/pkg 6.22.0 - Verified 0 vulnerabilities across 230+ audited packages
1 parent 43e988d commit 435c25f

27 files changed

Lines changed: 1650 additions & 1699 deletions

cloudsync-cli/bin/cloudsync.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,27 @@ import { fileURLToPath } from 'url';
1414

1515
const __dirname = dirname(fileURLToPath(import.meta.url));
1616

17-
// ── Ensure .cloudsync directories exist ──────────────────
18-
const csyncDir = join(process.cwd(), '.cloudsync');
19-
[
20-
csyncDir,
21-
join(csyncDir, 'staging'),
22-
join(csyncDir, 'history', 'commits'),
23-
join(csyncDir, 'history', 'diffs'),
24-
join(csyncDir, 'cache'),
25-
join(csyncDir, 'logs'),
26-
].forEach((dir) => {
27-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
28-
});
17+
// ── Ensure .cloudsync directories exist (only for real commands) ──
18+
function ensureDirs() {
19+
const csyncDir = join(process.cwd(), '.cloudsync');
20+
[
21+
csyncDir,
22+
join(csyncDir, 'staging'),
23+
join(csyncDir, 'history', 'commits'),
24+
join(csyncDir, 'history', 'diffs'),
25+
join(csyncDir, 'cache'),
26+
join(csyncDir, 'logs'),
27+
].forEach((dir) => {
28+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
29+
});
30+
}
31+
32+
// Only create dirs when a real command is being run (not --help/--version)
33+
const helpFlags = ['--help', '-h', '--version', '-v', '-V'];
34+
const isHelpOrVersion = process.argv.length <= 2 || process.argv.some(a => helpFlags.includes(a));
35+
if (!isHelpOrVersion) {
36+
ensureDirs();
37+
}
2938

3039
// ── Global error handlers ────────────────────────────────
3140
process.on('uncaughtException', (err) => {

0 commit comments

Comments
 (0)