diff --git a/package-lock.json b/package-lock.json index 40582f1622..730d80a59d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -842,9 +842,13 @@ } }, "node_modules/@contentstack/utils": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.3.tgz", - "integrity": "sha512-Zj2ejyfbxZlXrF1Wl9lhwK2mCCWo5ooiDnSlNA8nupZ1nDsTfouYERgps8r/uyzm18Vda2wBitxloThxKAyzsA==" + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@contentstack/utils/-/utils-1.3.4.tgz", + "integrity": "sha512-RGTJDcI2pabV4Ub5f4yuILz7QclR61qEusdfy48J3pnnXlbw2KODU5iJc/TtGB970OpH87/JlLsQzCUCGsd99g==", + "dependencies": { + "cheerio": "^1.0.0-rc.12", + "dompurify": "^3.1.1" + } }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", @@ -1841,6 +1845,12 @@ "which": "^2.0.2" } }, + "node_modules/@npmcli/git/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/@npmcli/git/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1853,6 +1863,21 @@ "node": ">=10" } }, + "node_modules/@npmcli/git/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@npmcli/git/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -2203,19 +2228,20 @@ } }, "node_modules/@oclif/plugin-plugins": { - "version": "5.0.21", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.0.21.tgz", - "integrity": "sha512-kyCIYUdX2a6+b6c7yjME6rW0Bw/iPqgLgCVhkV14qKHVS7FteGMDyio+nzPJ3BGdMHZuxGh9po7PImqNx7Mk7w==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.1.2.tgz", + "integrity": "sha512-O8LhkCoL4VKFn72Ur2D9zB3a7ntgIrlOzjhRnND6cwsoA0FBeqNi0Jz8pzvJzLv7fZCN9O6kxNBN/Zmkb7rgJg==", "dependencies": { "@oclif/core": "^3.26.6", "chalk": "^5.3.0", "debug": "^4.3.4", - "npm": "^10.7.0", + "npm": "^10.8.0", "npm-package-arg": "^11.0.2", "npm-run-path": "^5.3.0", "object-treeify": "^4.0.1", "semver": "^7.6.2", - "validate-npm-package-name": "^5.0.0", + "validate-npm-package-name": "^5.0.1", + "which": "^4.0.0", "yarn": "^1.22.22" }, "engines": { @@ -3467,9 +3493,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.1.tgz", - "integrity": "sha512-X+2qazGS3jxLAIz5JDXDzglAF3KpijdhFxlf/V1+hEsOUc+HnWi81L/uv/EvGuV90WY+7mPGFCUDGfQC3Gj95Q==" + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha512-wYCP26ZLxaT3R39kiN2+HcJ4kTd3U1waI/cY7ivWYqFP6pW3ZNpvi6Wd6PHZx7T/t8z0vlkXMg3QYLa7DZ/IJQ==" }, "node_modules/@types/markdown-it": { "version": "14.1.1", @@ -4227,6 +4253,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "delegates": "^1.0.0", @@ -4528,9 +4555,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1620.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1620.0.tgz", - "integrity": "sha512-G+mBI/VzuFpobBe+pu++ELc3YXSx2UzBTiLmQuZIQDi2+9VEU+/8QFAH45SI8PRPDRCcn4NMK4Euqs0uCyObvQ==", + "version": "2.1624.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1624.0.tgz", + "integrity": "sha512-SxBGDkdmsQTXLKPaY+hLqjlQyZBaGaFD34EhTd4aYuuqT952sxYeDt7w75py4o4O5z4hUUTccqTF9dtpxCPJfg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -4559,9 +4586,9 @@ } }, "node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.1.tgz", + "integrity": "sha512-+LV37nQcd1EpFalkXksWNBiA17NZ5m5/WspmHGmZmdx1qBOg/VNq/c4eRJiA9VQQHBOs+N0ZhhdU10h2TyNK7Q==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -4912,11 +4939,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -5273,9 +5300,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001618", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz", - "integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==", + "version": "1.0.30001620", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001620.tgz", + "integrity": "sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew==", "dev": true, "funding": [ { @@ -6106,9 +6133,9 @@ } }, "node_modules/contentstack": { - "version": "3.19.2", - "resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.19.2.tgz", - "integrity": "sha512-AQNfixXaXcj8j/dncq4nMUIoljWNqO+kVLU1o+qGD9pqBiI/e+f2bn1DAqtE9Ona1k+rZnGjcXGi8bPHHyW2yA==", + "version": "3.19.3", + "resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.19.3.tgz", + "integrity": "sha512-2bfiVXfM6Y76NKIkCYdwHufRBgssCA8OWTucFQiHCPKEN3kWa9Wz7R9VVVErYsyI5He6lGofY/CCtLZkpuvPVw==", "dependencies": { "@contentstack/utils": "^1.3.3", "cheerio": "^1.0.0-rc.12", @@ -6192,6 +6219,25 @@ "node": ">= 8" } }, + "node_modules/cross-spawn/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/crypto-random-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", @@ -6715,6 +6761,11 @@ "url": "https://github.com/fb55/domhandler?sponsor=1" } }, + "node_modules/dompurify": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.4.tgz", + "integrity": "sha512-2gnshi6OshmuKil8rMZuQCGiUF3cUxHY3NGDzUAdUx/NPEe5DVnO8BDoAQouvgwnx0R/+a6jUn36Z0FSdq8vww==" + }, "node_modules/domutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", @@ -6807,9 +6858,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.769", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.769.tgz", - "integrity": "sha512-bZu7p623NEA2rHTc9K1vykl57ektSPQYFFqQir8BOYf6EKOB+yIsbFB9Kpm7Cgt6tsLr9sRkqfqSZUw7LP1XxQ==", + "version": "1.4.776", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.776.tgz", + "integrity": "sha512-s694bi3+gUzlliqxjPHpa9NRTlhzTgB34aan+pVKZmOTGy2xoZXl+8E1B8i5p5rtev3PKMK/H4asgNejC+YHNg==", "dev": true }, "node_modules/elegant-spinner": { @@ -7962,13 +8013,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.9.0.tgz", - "integrity": "sha512-ZwPK4DeCDxr3GJltRz5iZejPFAAr4Wk3+2WIBaj1L5PYK5RgxExu/Y68FFVclN0y6GGwH8q+KgKRCvaTmFBbgQ==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.10.0.tgz", + "integrity": "sha512-7L01/K8W/VGl7noe2mgH0K7BE29Sq6KAbVmxurj8GGaPDZXPr8EEQ2seOeAS+mEV9DnzxBQB6ax6qQQ5C6P4xg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.9.0", - "@typescript-eslint/visitor-keys": "7.9.0" + "@typescript-eslint/types": "7.10.0", + "@typescript-eslint/visitor-keys": "7.10.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -7979,9 +8030,9 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.9.0.tgz", - "integrity": "sha512-oZQD9HEWQanl9UfsbGVcZ2cGaR0YT5476xfWE0oE5kQa2sNK2frxOlkeacLOTh9po4AlUT5rtkGyYM5kew0z5w==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.10.0.tgz", + "integrity": "sha512-7fNj+Ya35aNyhuqrA1E/VayQX9Elwr8NKZ4WueClR3KwJ7Xx9jcCdOrLW04h51de/+gNbyFMs+IDxh5xIwfbNg==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -7992,13 +8043,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.9.0.tgz", - "integrity": "sha512-zBCMCkrb2YjpKV3LA0ZJubtKCDxLttxfdGmwZvTqqWevUPN0FZvSI26FalGFFUZU/9YQK/A4xcQF9o/VVaCKAg==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.10.0.tgz", + "integrity": "sha512-LXFnQJjL9XIcxeVfqmNj60YhatpRLt6UhdlFwAkjNc6jSUlK8zQOl1oktAP8PlWFzPQC1jny/8Bai3/HPuvN5g==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.9.0", - "@typescript-eslint/visitor-keys": "7.9.0", + "@typescript-eslint/types": "7.10.0", + "@typescript-eslint/visitor-keys": "7.10.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8020,15 +8071,15 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.9.0.tgz", - "integrity": "sha512-5KVRQCzZajmT4Ep+NEgjXCvjuypVvYHUW7RHlXzNPuak2oWpVoD1jf5xCP0dPAuNIchjC7uQyvbdaSTFaLqSdA==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.10.0.tgz", + "integrity": "sha512-olzif1Fuo8R8m/qKkzJqT7qwy16CzPRWBvERS0uvyc+DHd8AKbO4Jb7kpAvVzMmZm8TrHnI7hvjN4I05zow+tg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.9.0", - "@typescript-eslint/types": "7.9.0", - "@typescript-eslint/typescript-estree": "7.9.0" + "@typescript-eslint/scope-manager": "7.10.0", + "@typescript-eslint/types": "7.10.0", + "@typescript-eslint/typescript-estree": "7.10.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8042,12 +8093,12 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.9.0.tgz", - "integrity": "sha512-iESPx2TNLDNGQLyjKhUvIKprlP49XNEK+MvIf9nIO7ZZaZdbnfWKHnXAgufpxqfA0YryH8XToi4+CjBgVnFTSQ==", + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.10.0.tgz", + "integrity": "sha512-9ntIVgsi6gg6FIq9xjEO4VQJvwOqA3jaBFQJ/6TK5AvEup2+cECI6Fh7QiBxmfMHXU0V0J4RyPeOU1VDNzl9cg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.9.0", + "@typescript-eslint/types": "7.10.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -8785,9 +8836,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -9205,6 +9256,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "aproba": "^1.0.3 || ^2.0.0", @@ -11432,9 +11484,12 @@ } }, "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "engines": { + "node": ">=16" + } }, "node_modules/isomorphic-fetch": { "version": "3.0.0", @@ -13991,17 +14046,28 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.6.tgz", + "integrity": "sha512-Y4Ypn3oujJYxJcMacVgcs92wofTHxp9FzfDpQON4msDefoC0lb3ETvQLOdLcbhSwU1bz8HrL/1sygfBIHudrkQ==", "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" + "braces": "^3.0.3", + "picomatch": "^4.0.2" }, "engines": { "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -14704,6 +14770,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "delegates": "^1.0.0", @@ -14717,6 +14784,7 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "aproba": "^1.0.3 || ^2.0.0", @@ -14732,10 +14800,17 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/node-gyp/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/node-gyp/node_modules/npmlog": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "are-we-there-yet": "^3.0.0", @@ -14776,6 +14851,21 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/node-gyp/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -14887,9 +14977,9 @@ } }, "node_modules/npm": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/npm/-/npm-10.7.0.tgz", - "integrity": "sha512-FXylyYSXNjgXx3l82BT8RSQvCoGIQ3h8YdRFGKNvo3Pv/bKscK4pdWkx/onwTpHDqGw+oeLf4Rxln9WVyxAxlQ==", + "version": "10.8.0", + "resolved": "https://registry.npmjs.org/npm/-/npm-10.8.0.tgz", + "integrity": "sha512-wh93uRczgp7HDnPMiLXcCkv2hagdJS0zJ9KT/31d0FoXP02+qgN2AOwpaW85fxRWkinl2rELfPw+CjBXW48/jQ==", "bundleDependencies": [ "@isaacs/string-locale-compare", "@npmcli/arborist", @@ -14962,71 +15052,71 @@ ], "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/arborist": "^7.2.1", - "@npmcli/config": "^8.0.2", - "@npmcli/fs": "^3.1.0", + "@npmcli/arborist": "^7.5.2", + "@npmcli/config": "^8.3.2", + "@npmcli/fs": "^3.1.1", "@npmcli/map-workspaces": "^3.0.6", "@npmcli/package-json": "^5.1.0", - "@npmcli/promise-spawn": "^7.0.1", + "@npmcli/promise-spawn": "^7.0.2", "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", - "@sigstore/tuf": "^2.3.2", + "@sigstore/tuf": "^2.3.3", "abbrev": "^2.0.0", "archy": "~1.0.0", - "cacache": "^18.0.2", + "cacache": "^18.0.3", "chalk": "^5.3.0", "ci-info": "^4.0.0", "cli-columns": "^4.0.0", "fastest-levenshtein": "^1.0.16", "fs-minipass": "^3.0.3", - "glob": "^10.3.12", + "glob": "^10.3.15", "graceful-fs": "^4.2.11", - "hosted-git-info": "^7.0.1", + "hosted-git-info": "^7.0.2", "ini": "^4.1.2", - "init-package-json": "^6.0.2", + "init-package-json": "^6.0.3", "is-cidr": "^5.0.5", - "json-parse-even-better-errors": "^3.0.1", - "libnpmaccess": "^8.0.1", - "libnpmdiff": "^6.0.3", - "libnpmexec": "^8.0.0", - "libnpmfund": "^5.0.1", - "libnpmhook": "^10.0.0", - "libnpmorg": "^6.0.1", - "libnpmpack": "^7.0.0", - "libnpmpublish": "^9.0.2", - "libnpmsearch": "^7.0.0", - "libnpmteam": "^6.0.0", - "libnpmversion": "^6.0.0", + "json-parse-even-better-errors": "^3.0.2", + "libnpmaccess": "^8.0.6", + "libnpmdiff": "^6.1.2", + "libnpmexec": "^8.1.1", + "libnpmfund": "^5.0.10", + "libnpmhook": "^10.0.5", + "libnpmorg": "^6.0.6", + "libnpmpack": "^7.0.2", + "libnpmpublish": "^9.0.8", + "libnpmsearch": "^7.0.5", + "libnpmteam": "^6.0.5", + "libnpmversion": "^6.0.2", "make-fetch-happen": "^13.0.1", "minimatch": "^9.0.4", - "minipass": "^7.0.4", + "minipass": "^7.1.1", "minipass-pipeline": "^1.2.4", "ms": "^2.1.2", "node-gyp": "^10.1.0", - "nopt": "^7.2.0", - "normalize-package-data": "^6.0.0", + "nopt": "^7.2.1", + "normalize-package-data": "^6.0.1", "npm-audit-report": "^5.0.0", "npm-install-checks": "^6.3.0", "npm-package-arg": "^11.0.2", - "npm-pick-manifest": "^9.0.0", - "npm-profile": "^9.0.2", - "npm-registry-fetch": "^17.0.0", - "npm-user-validate": "^2.0.0", + "npm-pick-manifest": "^9.0.1", + "npm-profile": "^10.0.0", + "npm-registry-fetch": "^17.0.1", + "npm-user-validate": "^2.0.1", "p-map": "^4.0.0", - "pacote": "^18.0.3", + "pacote": "^18.0.6", "parse-conflict-json": "^3.0.1", "proc-log": "^4.2.0", "qrcode-terminal": "^0.12.0", "read": "^3.0.1", - "semver": "^7.6.0", + "semver": "^7.6.2", "spdx-expression-parse": "^4.0.0", - "ssri": "^10.0.5", + "ssri": "^10.0.6", "supports-color": "^9.4.0", "tar": "^6.2.1", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^3.0.0", - "validate-npm-package-name": "^5.0.0", + "validate-npm-package-name": "^5.0.1", "which": "^4.0.0", "write-file-atomic": "^5.0.1" }, @@ -15626,34 +15716,35 @@ } }, "node_modules/npm/node_modules/@npmcli/arborist": { - "version": "7.5.1", + "version": "7.5.2", "inBundle": true, "license": "ISC", "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", - "@npmcli/fs": "^3.1.0", + "@npmcli/fs": "^3.1.1", "@npmcli/installed-package-contents": "^2.1.0", "@npmcli/map-workspaces": "^3.0.2", - "@npmcli/metavuln-calculator": "^7.1.0", + "@npmcli/metavuln-calculator": "^7.1.1", "@npmcli/name-from-folder": "^2.0.0", "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^5.1.0", "@npmcli/query": "^3.1.0", "@npmcli/redact": "^2.0.0", "@npmcli/run-script": "^8.1.0", - "bin-links": "^4.0.1", - "cacache": "^18.0.0", + "bin-links": "^4.0.4", + "cacache": "^18.0.3", "common-ancestor-path": "^1.0.1", - "hosted-git-info": "^7.0.1", - "json-parse-even-better-errors": "^3.0.0", + "hosted-git-info": "^7.0.2", + "json-parse-even-better-errors": "^3.0.2", "json-stringify-nice": "^1.1.4", + "lru-cache": "^10.2.2", "minimatch": "^9.0.4", - "nopt": "^7.0.0", + "nopt": "^7.2.1", "npm-install-checks": "^6.2.0", "npm-package-arg": "^11.0.2", - "npm-pick-manifest": "^9.0.0", - "npm-registry-fetch": "^17.0.0", - "pacote": "^18.0.1", + "npm-pick-manifest": "^9.0.1", + "npm-registry-fetch": "^17.0.1", + "pacote": "^18.0.6", "parse-conflict-json": "^3.0.0", "proc-log": "^4.2.0", "proggy": "^2.0.0", @@ -15661,7 +15752,7 @@ "promise-call-limit": "^3.0.1", "read-package-json-fast": "^3.0.2", "semver": "^7.3.7", - "ssri": "^10.0.5", + "ssri": "^10.0.6", "treeverse": "^3.0.0", "walk-up-path": "^3.0.1" }, @@ -15673,14 +15764,14 @@ } }, "node_modules/npm/node_modules/@npmcli/config": { - "version": "8.3.1", + "version": "8.3.2", "inBundle": true, "license": "ISC", "dependencies": { "@npmcli/map-workspaces": "^3.0.2", "ci-info": "^4.0.0", "ini": "^4.1.2", - "nopt": "^7.0.0", + "nopt": "^7.2.1", "proc-log": "^4.2.0", "read-package-json-fast": "^3.0.2", "semver": "^7.3.5", @@ -15691,7 +15782,7 @@ } }, "node_modules/npm/node_modules/@npmcli/fs": { - "version": "3.1.0", + "version": "3.1.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -15702,7 +15793,7 @@ } }, "node_modules/npm/node_modules/@npmcli/git": { - "version": "5.0.6", + "version": "5.0.7", "inBundle": true, "license": "ISC", "dependencies": { @@ -15749,7 +15840,7 @@ } }, "node_modules/npm/node_modules/@npmcli/metavuln-calculator": { - "version": "7.1.0", + "version": "7.1.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -15797,7 +15888,7 @@ } }, "node_modules/npm/node_modules/@npmcli/promise-spawn": { - "version": "7.0.1", + "version": "7.0.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -15871,7 +15962,7 @@ } }, "node_modules/npm/node_modules/@sigstore/protobuf-specs": { - "version": "0.3.1", + "version": "0.3.2", "inBundle": true, "license": "Apache-2.0", "engines": { @@ -15879,26 +15970,28 @@ } }, "node_modules/npm/node_modules/@sigstore/sign": { - "version": "2.3.0", + "version": "2.3.1", "inBundle": true, "license": "Apache-2.0", "dependencies": { "@sigstore/bundle": "^2.3.0", "@sigstore/core": "^1.0.0", "@sigstore/protobuf-specs": "^0.3.1", - "make-fetch-happen": "^13.0.0" + "make-fetch-happen": "^13.0.1", + "proc-log": "^4.2.0", + "promise-retry": "^2.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/@sigstore/tuf": { - "version": "2.3.2", + "version": "2.3.3", "inBundle": true, "license": "Apache-2.0", "dependencies": { "@sigstore/protobuf-specs": "^0.3.0", - "tuf-js": "^2.2.0" + "tuf-js": "^2.2.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -15926,12 +16019,12 @@ } }, "node_modules/npm/node_modules/@tufjs/models": { - "version": "2.0.0", + "version": "2.0.1", "inBundle": true, "license": "MIT", "dependencies": { "@tufjs/canonical-json": "2.0.0", - "minimatch": "^9.0.3" + "minimatch": "^9.0.4" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -16003,7 +16096,7 @@ "license": "MIT" }, "node_modules/npm/node_modules/bin-links": { - "version": "4.0.3", + "version": "4.0.4", "inBundle": true, "license": "ISC", "dependencies": { @@ -16035,16 +16128,8 @@ "balanced-match": "^1.0.0" } }, - "node_modules/npm/node_modules/builtins": { - "version": "5.1.0", - "inBundle": true, - "license": "MIT", - "dependencies": { - "semver": "^7.0.0" - } - }, "node_modules/npm/node_modules/cacache": { - "version": "18.0.2", + "version": "18.0.3", "inBundle": true, "license": "ISC", "dependencies": { @@ -16130,7 +16215,7 @@ } }, "node_modules/npm/node_modules/cmd-shim": { - "version": "6.0.2", + "version": "6.0.3", "inBundle": true, "license": "ISC", "engines": { @@ -16305,7 +16390,7 @@ } }, "node_modules/npm/node_modules/glob": { - "version": "10.3.12", + "version": "10.3.15", "inBundle": true, "license": "ISC", "dependencies": { @@ -16313,13 +16398,13 @@ "jackspeak": "^2.3.6", "minimatch": "^9.0.1", "minipass": "^7.0.4", - "path-scurry": "^1.10.2" + "path-scurry": "^1.11.0" }, "bin": { "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -16342,7 +16427,7 @@ } }, "node_modules/npm/node_modules/hosted-git-info": { - "version": "7.0.1", + "version": "7.0.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -16394,7 +16479,7 @@ } }, "node_modules/npm/node_modules/ignore-walk": { - "version": "6.0.4", + "version": "6.0.5", "inBundle": true, "license": "ISC", "dependencies": { @@ -16429,7 +16514,7 @@ } }, "node_modules/npm/node_modules/init-package-json": { - "version": "6.0.2", + "version": "6.0.3", "inBundle": true, "license": "ISC", "dependencies": { @@ -16531,7 +16616,7 @@ "license": "MIT" }, "node_modules/npm/node_modules/json-parse-even-better-errors": { - "version": "3.0.1", + "version": "3.0.2", "inBundle": true, "license": "MIT", "engines": { @@ -16565,29 +16650,29 @@ "license": "MIT" }, "node_modules/npm/node_modules/libnpmaccess": { - "version": "8.0.5", + "version": "8.0.6", "inBundle": true, "license": "ISC", "dependencies": { "npm-package-arg": "^11.0.2", - "npm-registry-fetch": "^17.0.0" + "npm-registry-fetch": "^17.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmdiff": { - "version": "6.1.1", + "version": "6.1.2", "inBundle": true, "license": "ISC", "dependencies": { - "@npmcli/arborist": "^7.2.1", + "@npmcli/arborist": "^7.5.2", "@npmcli/installed-package-contents": "^2.1.0", "binary-extensions": "^2.3.0", "diff": "^5.1.0", "minimatch": "^9.0.4", "npm-package-arg": "^11.0.2", - "pacote": "^18.0.1", + "pacote": "^18.0.6", "tar": "^6.2.1" }, "engines": { @@ -16595,15 +16680,15 @@ } }, "node_modules/npm/node_modules/libnpmexec": { - "version": "8.1.0", + "version": "8.1.1", "inBundle": true, "license": "ISC", "dependencies": { - "@npmcli/arborist": "^7.2.1", + "@npmcli/arborist": "^7.5.2", "@npmcli/run-script": "^8.1.0", "ci-info": "^4.0.0", "npm-package-arg": "^11.0.2", - "pacote": "^18.0.1", + "pacote": "^18.0.6", "proc-log": "^4.2.0", "read": "^3.0.1", "read-package-json-fast": "^3.0.2", @@ -16615,103 +16700,103 @@ } }, "node_modules/npm/node_modules/libnpmfund": { - "version": "5.0.9", + "version": "5.0.10", "inBundle": true, "license": "ISC", "dependencies": { - "@npmcli/arborist": "^7.2.1" + "@npmcli/arborist": "^7.5.2" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmhook": { - "version": "10.0.4", + "version": "10.0.5", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^17.0.0" + "npm-registry-fetch": "^17.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmorg": { - "version": "6.0.5", + "version": "6.0.6", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^17.0.0" + "npm-registry-fetch": "^17.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmpack": { - "version": "7.0.1", + "version": "7.0.2", "inBundle": true, "license": "ISC", "dependencies": { - "@npmcli/arborist": "^7.2.1", + "@npmcli/arborist": "^7.5.2", "@npmcli/run-script": "^8.1.0", "npm-package-arg": "^11.0.2", - "pacote": "^18.0.1" + "pacote": "^18.0.6" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmpublish": { - "version": "9.0.7", + "version": "9.0.8", "inBundle": true, "license": "ISC", "dependencies": { "ci-info": "^4.0.0", - "normalize-package-data": "^6.0.0", + "normalize-package-data": "^6.0.1", "npm-package-arg": "^11.0.2", - "npm-registry-fetch": "^17.0.0", + "npm-registry-fetch": "^17.0.1", "proc-log": "^4.2.0", "semver": "^7.3.7", "sigstore": "^2.2.0", - "ssri": "^10.0.5" + "ssri": "^10.0.6" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmsearch": { - "version": "7.0.4", + "version": "7.0.5", "inBundle": true, "license": "ISC", "dependencies": { - "npm-registry-fetch": "^17.0.0" + "npm-registry-fetch": "^17.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmteam": { - "version": "6.0.4", + "version": "6.0.5", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^17.0.0" + "npm-registry-fetch": "^17.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/npm/node_modules/libnpmversion": { - "version": "6.0.1", + "version": "6.0.2", "inBundle": true, "license": "ISC", "dependencies": { - "@npmcli/git": "^5.0.6", + "@npmcli/git": "^5.0.7", "@npmcli/run-script": "^8.1.0", - "json-parse-even-better-errors": "^3.0.0", + "json-parse-even-better-errors": "^3.0.2", "proc-log": "^4.2.0", "semver": "^7.3.7" }, @@ -16764,7 +16849,7 @@ } }, "node_modules/npm/node_modules/minipass": { - "version": "7.0.4", + "version": "7.1.1", "inBundle": true, "license": "ISC", "engines": { @@ -16783,7 +16868,7 @@ } }, "node_modules/npm/node_modules/minipass-fetch": { - "version": "3.0.4", + "version": "3.0.5", "inBundle": true, "license": "MIT", "dependencies": { @@ -16971,7 +17056,7 @@ } }, "node_modules/npm/node_modules/nopt": { - "version": "7.2.0", + "version": "7.2.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -16985,7 +17070,7 @@ } }, "node_modules/npm/node_modules/normalize-package-data": { - "version": "6.0.0", + "version": "6.0.1", "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -17007,7 +17092,7 @@ } }, "node_modules/npm/node_modules/npm-bundled": { - "version": "3.0.0", + "version": "3.0.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -17062,7 +17147,7 @@ } }, "node_modules/npm/node_modules/npm-pick-manifest": { - "version": "9.0.0", + "version": "9.0.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -17076,19 +17161,19 @@ } }, "node_modules/npm/node_modules/npm-profile": { - "version": "9.0.2", + "version": "10.0.0", "inBundle": true, "license": "ISC", "dependencies": { - "npm-registry-fetch": "^17.0.0", + "npm-registry-fetch": "^17.0.1", "proc-log": "^4.0.0" }, "engines": { - "node": "^16.14.0 || >=18.0.0" + "node": ">=18.0.0" } }, "node_modules/npm/node_modules/npm-registry-fetch": { - "version": "17.0.0", + "version": "17.0.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -17106,7 +17191,7 @@ } }, "node_modules/npm/node_modules/npm-user-validate": { - "version": "2.0.0", + "version": "2.0.1", "inBundle": true, "license": "BSD-2-Clause", "engines": { @@ -17128,7 +17213,7 @@ } }, "node_modules/npm/node_modules/pacote": { - "version": "18.0.3", + "version": "18.0.6", "inBundle": true, "license": "ISC", "dependencies": { @@ -17151,7 +17236,7 @@ "tar": "^6.1.11" }, "bin": { - "pacote": "lib/bin.js" + "pacote": "bin/index.js" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -17179,7 +17264,7 @@ } }, "node_modules/npm/node_modules/path-scurry": { - "version": "1.10.2", + "version": "1.11.1", "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -17187,7 +17272,7 @@ "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -17255,7 +17340,7 @@ } }, "node_modules/npm/node_modules/promzard": { - "version": "1.0.1", + "version": "1.0.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -17318,12 +17403,9 @@ "optional": true }, "node_modules/npm/node_modules/semver": { - "version": "7.6.0", + "version": "7.6.2", "inBundle": true, "license": "ISC", - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -17331,17 +17413,6 @@ "node": ">=10" } }, - "node_modules/npm/node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "inBundle": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/npm/node_modules/shebang-command": { "version": "2.0.0", "inBundle": true, @@ -17466,7 +17537,7 @@ "license": "BSD-3-Clause" }, "node_modules/npm/node_modules/ssri": { - "version": "10.0.5", + "version": "10.0.6", "inBundle": true, "license": "ISC", "dependencies": { @@ -17602,13 +17673,13 @@ } }, "node_modules/npm/node_modules/tuf-js": { - "version": "2.2.0", + "version": "2.2.1", "inBundle": true, "license": "MIT", "dependencies": { - "@tufjs/models": "2.0.0", + "@tufjs/models": "2.0.1", "debug": "^4.3.4", - "make-fetch-happen": "^13.0.0" + "make-fetch-happen": "^13.0.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -17660,12 +17731,9 @@ } }, "node_modules/npm/node_modules/validate-npm-package-name": { - "version": "5.0.0", + "version": "5.0.1", "inBundle": true, "license": "ISC", - "dependencies": { - "builtins": "^5.0.0" - }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } @@ -17811,6 +17879,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "are-we-there-yet": "^2.0.0", @@ -18968,6 +19037,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, "engines": { "node": ">=8.6" }, @@ -19667,6 +19737,7 @@ "version": "6.0.4", "resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-6.0.4.tgz", "integrity": "sha512-AEtWXYfopBj2z5N5PbkAOeNHRPUg5q+Nen7QLxV8M2zJq1ym6/lCz3fYNTCXe19puu2d06jfHhrP7v/S2PtMMw==", + "deprecated": "This package is no longer supported. Please use @npmcli/package-json instead.", "dev": true, "dependencies": { "glob": "^10.2.2", @@ -19977,6 +20048,62 @@ "node": ">=8.10.0" } }, + "node_modules/recheck": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/recheck/-/recheck-4.4.5.tgz", + "integrity": "sha512-J80Ykhr+xxWtvWrfZfPpOR/iw2ijvb4WY8d9AVoN8oHsPP07JT1rCAalUSACMGxM1cvSocb6jppWFjVS6eTTrA==", + "engines": { + "node": ">=14" + }, + "optionalDependencies": { + "recheck-jar": "4.4.5", + "recheck-linux-x64": "4.4.5", + "recheck-macos-x64": "4.4.5", + "recheck-windows-x64": "4.4.5" + } + }, + "node_modules/recheck-jar": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/recheck-jar/-/recheck-jar-4.4.5.tgz", + "integrity": "sha512-a2kMzcfr+ntT0bObNLY22EUNV6Z6WeZ+DybRmPOUXVWzGcqhRcrK74tpgrYt3FdzTlSh85pqoryAPmrNkwLc0g==", + "optional": true + }, + "node_modules/recheck-linux-x64": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/recheck-linux-x64/-/recheck-linux-x64-4.4.5.tgz", + "integrity": "sha512-s8OVPCpiSGw+tLCxH3eei7Zp2AoL22kXqLmEtWXi0AnYNwfuTjZmeLn2aQjW8qhs8ZPSkxS7uRIRTeZqR5Fv/Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/recheck-macos-x64": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/recheck-macos-x64/-/recheck-macos-x64-4.4.5.tgz", + "integrity": "sha512-Ouup9JwwoKCDclt3Na8+/W2pVbt8FRpzjkDuyM32qTR2TOid1NI+P1GA6/VQAKEOjvaxgGjxhcP/WqAjN+EULA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/recheck-windows-x64": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/recheck-windows-x64/-/recheck-windows-x64-4.4.5.tgz", + "integrity": "sha512-mkpzLHu9G9Ztjx8HssJh9k/Xm1d1d/4OoT7etHqFk+k1NGzISCRXBD22DqYF9w8+J4QEzTAoDf8icFt0IGhOEQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", @@ -21234,6 +21361,12 @@ "node": ">=8" } }, + "node_modules/spawn-wrap/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/spawn-wrap/node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -21273,6 +21406,21 @@ "semver": "bin/semver.js" } }, + "node_modules/spawn-wrap/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/spdx-correct": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", @@ -22012,9 +22160,9 @@ } }, "node_modules/ts-jest": { - "version": "29.1.2", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", - "integrity": "sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==", + "version": "29.1.3", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.3.tgz", + "integrity": "sha512-6L9qz3ginTd1NKhOxmkP0qU3FyKjj5CPoY+anszfVn6Pmv/RIKzhiMCsH7Yb7UvJR9I2A64rm4zQl531s2F1iw==", "dev": true, "dependencies": { "bs-logger": "0.x", @@ -22030,10 +22178,11 @@ "ts-jest": "cli.js" }, "engines": { - "node": "^16.10.0 || ^18.0.0 || >=20.0.0" + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" }, "peerDependencies": { "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0", "@jest/types": "^29.0.0", "babel-jest": "^29.0.0", "jest": "^29.0.0", @@ -22043,6 +22192,9 @@ "@babel/core": { "optional": true }, + "@jest/transform": { + "optional": true + }, "@jest/types": { "optional": true }, @@ -23037,17 +23189,17 @@ } }, "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "dependencies": { - "isexe": "^2.0.0" + "isexe": "^3.1.1" }, "bin": { - "node-which": "bin/node-which" + "node-which": "bin/which.js" }, "engines": { - "node": ">= 8" + "node": "^16.13.0 || >=18.0.0" } }, "node_modules/which-boxed-primitive": { @@ -23801,6 +23953,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "delegates": "^1.0.0", @@ -23917,6 +24070,7 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "aproba": "^1.0.3 || ^2.0.0", @@ -23956,6 +24110,12 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/yeoman-generator/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/yeoman-generator/node_modules/json-parse-even-better-errors": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-3.0.2.tgz", @@ -24376,6 +24536,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", + "deprecated": "This package is no longer supported.", "dev": true, "dependencies": { "are-we-there-yet": "^3.0.0", @@ -24600,25 +24761,25 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.18.1", + "version": "1.18.2", "license": "MIT", "dependencies": { - "@contentstack/cli-audit": "~1.6.1", + "@contentstack/cli-audit": "~1.6.2", "@contentstack/cli-auth": "~1.3.18", - "@contentstack/cli-cm-bootstrap": "~1.9.2", - "@contentstack/cli-cm-branches": "~1.0.25", - "@contentstack/cli-cm-bulk-publish": "~1.4.6", - "@contentstack/cli-cm-clone": "~1.10.4", - "@contentstack/cli-cm-export": "~1.11.3", + "@contentstack/cli-cm-bootstrap": "~1.9.3", + "@contentstack/cli-cm-branches": "~1.0.26", + "@contentstack/cli-cm-bulk-publish": "~1.4.7", + "@contentstack/cli-cm-clone": "~1.10.5", + "@contentstack/cli-cm-export": "~1.11.4", "@contentstack/cli-cm-export-to-csv": "~1.7.1", - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-cm-migrate-rte": "~1.4.17", - "@contentstack/cli-cm-seed": "~1.7.4", + "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-launch": "~1.0.18", - "@contentstack/cli-migration": "~1.5.5", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-migration": "~1.5.6", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", @@ -24668,11 +24829,11 @@ }, "packages/contentstack-audit": { "name": "@contentstack/cli-audit", - "version": "1.6.1", + "version": "1.6.2", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", "chalk": "^4.1.2", @@ -24928,7 +25089,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", @@ -24965,12 +25126,12 @@ }, "packages/contentstack-bootstrap": { "name": "@contentstack/cli-cm-bootstrap", - "version": "1.9.2", + "version": "1.9.3", "license": "MIT", "dependencies": { - "@contentstack/cli-cm-seed": "~1.7.4", + "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.2.1 " @@ -25044,11 +25205,11 @@ }, "packages/contentstack-branches": { "name": "@contentstack/cli-cm-branches", - "version": "1.0.25", + "version": "1.0.26", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^2.9.3", "async": "^3.2.4", "big-json": "^3.2.0", @@ -25150,11 +25311,11 @@ }, "packages/contentstack-bulk-publish": { "name": "@contentstack/cli-cm-bulk-publish", - "version": "1.4.6", + "version": "1.4.7", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "bluebird": "^3.7.2", "chalk": "^4.1.2", "dotenv": "^16.1.4", @@ -25187,14 +25348,14 @@ }, "packages/contentstack-clone": { "name": "@contentstack/cli-cm-clone", - "version": "1.10.4", + "version": "1.10.5", "license": "MIT", "dependencies": { "@colors/colors": "^1.5.0", - "@contentstack/cli-cm-export": "~1.11.3", - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", "chalk": "^4.1.0", "child_process": "^1.0.2", @@ -25300,7 +25461,7 @@ "version": "1.2.18", "license": "MIT", "dependencies": { - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "contentstack": "^3.10.1" }, "devDependencies": { @@ -25375,7 +25536,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", @@ -25753,11 +25914,11 @@ }, "packages/contentstack-export": { "name": "@contentstack/cli-cm-export", - "version": "1.11.3", + "version": "1.11.4", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", @@ -25807,7 +25968,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.1.0", "fast-csv": "^4.3.6", "inquirer": "8.2.4", @@ -26258,12 +26419,12 @@ }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", - "version": "1.15.5", + "version": "1.15.6", "license": "MIT", "dependencies": { - "@contentstack/cli-audit": "~1.6.1", + "@contentstack/cli-audit": "~1.6.2", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", @@ -26377,7 +26538,7 @@ "dependencies": { "@apollo/client": "^3.7.9", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", @@ -26672,7 +26833,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/json-rte-serializer": "~2.0.4", "chalk": "^4.1.2", "collapse-whitespace": "^1.1.7", @@ -26707,11 +26868,11 @@ }, "packages/contentstack-migration": { "name": "@contentstack/cli-migration", - "version": "1.5.5", + "version": "1.5.6", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", "callsites": "^3.1.0", "cardinal": "^2.1.1", @@ -26740,12 +26901,12 @@ }, "packages/contentstack-seed": { "name": "@contentstack/cli-cm-seed", - "version": "1.7.4", + "version": "1.7.5", "license": "MIT", "dependencies": { - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.1.13", @@ -26821,7 +26982,7 @@ }, "packages/contentstack-utilities": { "name": "@contentstack/cli-utilities", - "version": "1.6.1", + "version": "1.6.2", "license": "MIT", "dependencies": { "@contentstack/management": "~1.15.3", @@ -26842,6 +27003,7 @@ "mkdirp": "^1.0.4", "open": "^8.4.2", "ora": "^5.4.0", + "recheck": "^4.4.5", "rxjs": "^6.6.7", "traverse": "^0.6.7", "unique-string": "^2.0.0", diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index caf850f222..1932a32b69 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-audit/1.6.1 darwin-arm64 node-v21.6.2 +@contentstack/cli-audit/1.6.2 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-audit/package.json b/packages/contentstack-audit/package.json index 03b48fafbb..05aca4ed19 100644 --- a/packages/contentstack-audit/package.json +++ b/packages/contentstack-audit/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-audit", - "version": "1.6.1", + "version": "1.6.2", "description": "Contentstack audit plugin", "author": "Contentstack CLI", "homepage": "https://github.com/contentstack/cli", @@ -19,7 +19,7 @@ ], "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", "chalk": "^4.1.2", diff --git a/packages/contentstack-audit/src/audit-base-command.ts b/packages/contentstack-audit/src/audit-base-command.ts index b77879fc7d..f7f87fd7d6 100644 --- a/packages/contentstack-audit/src/audit-base-command.ts +++ b/packages/contentstack-audit/src/audit-base-command.ts @@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid'; import isEmpty from 'lodash/isEmpty'; import { join, resolve } from 'path'; import cloneDeep from 'lodash/cloneDeep'; -import { cliux, ux } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath, ux } from '@contentstack/cli-utilities'; import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'fs'; import config from './config'; @@ -396,7 +396,7 @@ export abstract class AuditBaseCommand extends BaseCommand, ): Promise { - const csvPath = join(this.sharedConfig.reportPath, `${moduleName}.csv`); - - return new Promise((resolve, reject) => { - // file deepcode ignore MissingClose: Will auto close once csv stream end - const ws = createWriteStream(csvPath).on('error', reject); - const defaultColumns = Object.keys(OutputColumn); - const userDefinedColumns = this.sharedConfig.flags.columns ? this.sharedConfig.flags.columns.split(',') : null; - let missingRefs: RefErrorReturnType[] | WorkflowExtensionsRefErrorReturnType[] = - Object.values(listOfMissingRefs).flat(); - const columns: (keyof typeof OutputColumn)[] = userDefinedColumns - ? [...userDefinedColumns, ...defaultColumns.filter((val: string) => !userDefinedColumns.includes(val))] - : defaultColumns; - - if (this.sharedConfig.flags.filter) { - const [column, value]: [keyof typeof OutputColumn, string] = this.sharedConfig.flags.filter.split('='); - // Filter the missingRefs array - missingRefs = missingRefs.filter((row) => { - if (OutputColumn[column] in row) { - const rowKey = OutputColumn[column] as keyof (RefErrorReturnType | WorkflowExtensionsRefErrorReturnType); - return row[rowKey] === value; - } - return false; - }); - } + if (Object.keys(config.moduleConfig).includes(moduleName)) { + const csvPath = join(sanitizePath(this.sharedConfig.reportPath), `${sanitizePath(moduleName)}.csv`); + return new Promise((resolve, reject) => { + // file deepcode ignore MissingClose: Will auto close once csv stream end + const ws = createWriteStream(csvPath).on('error', reject); + const defaultColumns = Object.keys(OutputColumn); + const userDefinedColumns = this.sharedConfig.flags.columns ? this.sharedConfig.flags.columns.split(',') : null; + let missingRefs: RefErrorReturnType[] | WorkflowExtensionsRefErrorReturnType[] = + Object.values(listOfMissingRefs).flat(); + const columns: (keyof typeof OutputColumn)[] = userDefinedColumns + ? [...userDefinedColumns, ...defaultColumns.filter((val: string) => !userDefinedColumns.includes(val))] + : defaultColumns; + + if (this.sharedConfig.flags.filter) { + const [column, value]: [keyof typeof OutputColumn, string] = this.sharedConfig.flags.filter.split('='); + // Filter the missingRefs array + missingRefs = missingRefs.filter((row) => { + if (OutputColumn[column] in row) { + const rowKey = OutputColumn[column] as keyof (RefErrorReturnType | WorkflowExtensionsRefErrorReturnType); + return row[rowKey] === value; + } + return false; + }); + } - const rowData: Record[] = []; - for (const issue of missingRefs) { - let row: Record = {}; + const rowData: Record[] = []; + for (const issue of missingRefs) { + let row: Record = {}; - for (const column of columns) { - if (Object.keys(issue).includes(OutputColumn[column])) { - const issueKey = OutputColumn[column] as keyof typeof issue; - row[column] = issue[issueKey] as string; - row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column]; + for (const column of columns) { + if (Object.keys(issue).includes(OutputColumn[column])) { + const issueKey = OutputColumn[column] as keyof typeof issue; + row[column] = issue[issueKey] as string; + row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column]; + } } - } - if (this.currentCommand === 'cm:stacks:audit:fix') { - row['Fix status'] = row.fixStatus; - } + if (this.currentCommand === 'cm:stacks:audit:fix') { + row['Fix status'] = row.fixStatus; + } - rowData.push(row); - } - csv.write(rowData, { headers: true }).pipe(ws).on('error', reject).on('finish', resolve); - }); + rowData.push(row); + } + csv.write(rowData, { headers: true }).pipe(ws).on('error', reject).on('finish', resolve); + }); + } else { + return new Promise((reject) => { + return reject() + }) + } } } diff --git a/packages/contentstack-audit/src/messages/index.ts b/packages/contentstack-audit/src/messages/index.ts index d8a37c1c98..ea3ffb15b2 100644 --- a/packages/contentstack-audit/src/messages/index.ts +++ b/packages/contentstack-audit/src/messages/index.ts @@ -1,5 +1,5 @@ import memoize from 'lodash/memoize'; -import { escapeRegExp } from '@contentstack/cli-utilities'; +import { escapeRegExp, validateRegex } from '@contentstack/cli-utilities'; const errors = {}; @@ -77,7 +77,12 @@ function $t(msg: string, args: Record): string { for (const key of Object.keys(args)) { const escapedKey = escapeRegExp(key); - msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), escapeRegExp(args[key]) || escapedKey); + const escapedKeyRegex = new RegExp(`{${escapedKey}}`, 'g'); + let { status } = validateRegex(escapedKeyRegex) + if (status === 'safe') { + const sanitizedValue = args[key] ? escapeRegExp(args[key]) : ''; + msg = msg.replace(escapedKeyRegex, sanitizedValue || escapedKey); + } } return msg; diff --git a/packages/contentstack-audit/src/modules/content-types.ts b/packages/contentstack-audit/src/modules/content-types.ts index 274768ceee..4875aa801c 100644 --- a/packages/contentstack-audit/src/modules/content-types.ts +++ b/packages/contentstack-audit/src/modules/content-types.ts @@ -4,7 +4,7 @@ import isEmpty from 'lodash/isEmpty'; import { join, resolve } from 'path'; import { existsSync, readFileSync, writeFileSync } from 'fs'; -import { ux } from '@contentstack/cli-utilities'; +import { sanitizePath, ux } from '@contentstack/cli-utilities'; import { LogFn, @@ -51,11 +51,17 @@ export default class ContentType { this.fix = fix ?? false; this.ctSchema = ctSchema; this.gfSchema = gfSchema; - this.moduleName = moduleName ?? 'content-types'; + this.moduleName = this.validateModules(moduleName!, this.config.moduleConfig); this.fileName = config.moduleConfig[this.moduleName].fileName; - this.folderPath = resolve(config.basePath, config.moduleConfig[this.moduleName].dirName); + this.folderPath = resolve(sanitizePath(config.basePath), sanitizePath(config.moduleConfig[this.moduleName].dirName)); } + validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record): keyof typeof auditConfig.moduleConfig { + if (Object.keys(moduleConfig).includes(moduleName)) { + return moduleName; + } + return 'content-types' + } /** * The `run` function checks if a folder path exists, sets the schema based on the module name, * iterates over the schema and looks for references, and returns a list of missing references. @@ -115,7 +121,7 @@ export default class ContentType { if (existsSync(extensionPath)) { try { this.extensions = Object.keys(JSON.parse(readFileSync(extensionPath, 'utf8'))); - } catch (error) {} + } catch (error) { } } if (existsSync(marketplacePath)) { @@ -128,7 +134,7 @@ export default class ContentType { ) as string[]; this.extensions.push(...metaData); } - } catch (error) {} + } catch (error) { } } } @@ -183,8 +189,8 @@ export default class ContentType { ...this.validateReferenceField( [...tree, { uid: field.uid, name: child.display_name }], child as ReferenceFieldDataType, - ), - ); + ), + ); break; case 'global_field': await this.validateGlobalField( @@ -264,19 +270,19 @@ export default class ContentType { return missingRefs.length ? [ - { - tree, - data_type, - missingRefs, - display_name, - ct_uid: this.currentUid, - name: this.currentTitle, - treeStr: tree - .map(({ name }) => name) - .filter((val) => val) - .join(' ➜ '), - }, - ] + { + tree, + data_type, + missingRefs, + display_name, + ct_uid: this.currentUid, + name: this.currentTitle, + treeStr: tree + .map(({ name }) => name) + .filter((val) => val) + .join(' ➜ '), + }, + ] : []; } @@ -392,19 +398,19 @@ export default class ContentType { return missingRefs.length ? [ - { - tree, - data_type, - missingRefs, - display_name, - ct_uid: this.currentUid, - name: this.currentTitle, - treeStr: tree - .map(({ name }) => name) - .filter((val) => val) - .join(' ➜ '), - }, - ] + { + tree, + data_type, + missingRefs, + display_name, + ct_uid: this.currentUid, + name: this.currentTitle, + treeStr: tree + .map(({ name }) => name) + .filter((val) => val) + .join(' ➜ '), + }, + ] : []; } diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index bc3f5013bb..16ad893fe6 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -3,7 +3,7 @@ import find from 'lodash/find'; import values from 'lodash/values'; import isEmpty from 'lodash/isEmpty'; import { join, resolve } from 'path'; -import { ux, FsUtility } from '@contentstack/cli-utilities'; +import { ux, FsUtility, sanitizePath } from '@contentstack/cli-utilities'; import { existsSync, readFileSync, writeFileSync } from 'fs'; import auditConfig from '../config'; @@ -67,9 +67,16 @@ export default class Entries { this.fix = fix ?? false; this.ctSchema = ctSchema; this.gfSchema = gfSchema; - this.moduleName = moduleName ?? 'entries'; + this.moduleName = this.validateModules(moduleName!, this.config.moduleConfig); this.fileName = config.moduleConfig[this.moduleName].fileName; - this.folderPath = resolve(config.basePath, config.moduleConfig.entries.dirName); + this.folderPath = resolve(sanitizePath(config.basePath), sanitizePath(config.moduleConfig.entries.dirName)); + } + + validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record): keyof typeof auditConfig.moduleConfig { + if (Object.keys(moduleConfig).includes(moduleName)) { + return moduleName; + } + return 'entries' } /** @@ -193,7 +200,7 @@ export default class Entries { async fixPrerequisiteData() { this.ctSchema = (await new ContentType({ fix: true, - log: () => {}, + log: () => { }, config: this.config, moduleName: 'content-types', ctSchema: this.ctSchema, @@ -201,7 +208,7 @@ export default class Entries { }).run(true)) as ContentTypeStruct[]; this.gfSchema = (await new GlobalField({ fix: true, - log: () => {}, + log: () => { }, config: this.config, moduleName: 'global-fields', ctSchema: this.ctSchema, @@ -214,7 +221,7 @@ export default class Entries { if (existsSync(extensionPath)) { try { this.extensions = Object.keys(JSON.parse(readFileSync(extensionPath, 'utf8'))); - } catch (error) {} + } catch (error) { } } if (existsSync(marketplacePath)) { @@ -227,7 +234,7 @@ export default class Entries { ) as string[]; this.extensions.push(...metaData); } - } catch (error) {} + } catch (error) { } } } @@ -409,19 +416,19 @@ export default class Entries { return missingRefs.length ? [ - { - tree, - data_type, - missingRefs, - display_name, - ct_uid: this.currentUid, - name: this.currentTitle, - treeStr: tree - .map(({ name }) => name) - .filter((val) => val) - .join(' ➜ '), - }, - ] + { + tree, + data_type, + missingRefs, + display_name, + ct_uid: this.currentUid, + name: this.currentTitle, + treeStr: tree + .map(({ name }) => name) + .filter((val) => val) + .join(' ➜ '), + }, + ] : []; } @@ -581,19 +588,19 @@ export default class Entries { return missingRefs.length ? [ - { - tree, - data_type, - missingRefs, - display_name, - uid: this.currentUid, - name: this.currentTitle, - treeStr: tree - .map(({ name }) => name) - .filter((val) => val) - .join(' ➜ '), - }, - ] + { + tree, + data_type, + missingRefs, + display_name, + uid: this.currentUid, + name: this.currentTitle, + treeStr: tree + .map(({ name }) => name) + .filter((val) => val) + .join(' ➜ '), + }, + ] : []; } diff --git a/packages/contentstack-audit/src/modules/extensions.ts b/packages/contentstack-audit/src/modules/extensions.ts index 10d47bc9a4..d48dd4f5a5 100644 --- a/packages/contentstack-audit/src/modules/extensions.ts +++ b/packages/contentstack-audit/src/modules/extensions.ts @@ -2,7 +2,7 @@ import path, { join, resolve } from 'path'; import { existsSync, readFileSync, writeFileSync } from 'fs'; import { cloneDeep } from 'lodash'; import { LogFn, ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam, Extension } from '../types'; -import { ux } from '@contentstack/cli-utilities'; +import { ux, sanitizePath } from '@contentstack/cli-utilities'; import auditConfig from '../config'; import { $t, auditMsg, commonMsg } from '../messages'; @@ -34,14 +34,20 @@ export default class Extensions { this.fix = fix ?? false; this.ctSchema = ctSchema; this.extensionsSchema = []; - this.moduleName = moduleName ?? 'extensions'; + this.moduleName = this.validateModules(moduleName!, this.config.moduleConfig); this.fileName = config.moduleConfig[this.moduleName].fileName; - this.folderPath = resolve(config.basePath, config.moduleConfig[this.moduleName].dirName); + this.folderPath = resolve(sanitizePath(config.basePath), sanitizePath(config.moduleConfig[this.moduleName].dirName)); this.ctUidSet = new Set(['$all']); this.missingCtInExtensions = []; this.missingCts = new Set(); this.extensionsPath = ''; } + validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record): keyof typeof auditConfig.moduleConfig { + if (Object.keys(moduleConfig).includes(moduleName)) { + return moduleName; + } + return 'extensions' + } async run() { if (!existsSync(this.folderPath)) { diff --git a/packages/contentstack-audit/src/modules/workflows.ts b/packages/contentstack-audit/src/modules/workflows.ts index 3e6f48b554..b016ded7d6 100644 --- a/packages/contentstack-audit/src/modules/workflows.ts +++ b/packages/contentstack-audit/src/modules/workflows.ts @@ -2,7 +2,7 @@ import { join, resolve } from 'path'; import { existsSync, readFileSync, writeFileSync } from 'fs'; import { cloneDeep } from 'lodash'; import { LogFn, ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam, Workflow } from '../types'; -import { ux } from '@contentstack/cli-utilities'; +import { sanitizePath, ux } from '@contentstack/cli-utilities'; import auditConfig from '../config'; import { $t, auditMsg, commonMsg } from '../messages'; @@ -35,15 +35,22 @@ export default class Workflows { this.fix = fix ?? false; this.ctSchema = ctSchema; this.workflowSchema = []; - this.moduleName = moduleName ?? 'workflows'; + this.moduleName = this.validateModules(moduleName!, this.config.moduleConfig); this.fileName = config.moduleConfig[this.moduleName].fileName; - this.folderPath = resolve(config.basePath, config.moduleConfig[this.moduleName].dirName); + this.folderPath = resolve(sanitizePath(config.basePath), sanitizePath(config.moduleConfig[this.moduleName].dirName)); this.ctUidSet = new Set(['$all']); this.missingCtInWorkflows = []; this.missingCts = new Set(); this.workflowPath = ''; this.isBranchFixDone = false; } + validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record): keyof typeof auditConfig.moduleConfig { + if (Object.keys(moduleConfig).includes(moduleName)) { + return moduleName; + } + return 'workflows' + } + /** * Check whether the given path for the workflow exists or not * If path exist read diff --git a/packages/contentstack-auth/package.json b/packages/contentstack-auth/package.json index c1c81875c5..0e329ab6fb 100644 --- a/packages/contentstack-auth/package.json +++ b/packages/contentstack-auth/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", diff --git a/packages/contentstack-bootstrap/README.md b/packages/contentstack-bootstrap/README.md index 8b8c47b5b1..056b54340e 100644 --- a/packages/contentstack-bootstrap/README.md +++ b/packages/contentstack-bootstrap/README.md @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-bootstrap/1.9.2 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-bootstrap/1.9.3 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bootstrap/package.json b/packages/contentstack-bootstrap/package.json index 6879e4a464..23aef0ed30 100644 --- a/packages/contentstack-bootstrap/package.json +++ b/packages/contentstack-bootstrap/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-bootstrap", "description": "Bootstrap contentstack apps", - "version": "1.9.2", + "version": "1.9.3", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "scripts": { @@ -17,9 +17,9 @@ "test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\"" }, "dependencies": { - "@contentstack/cli-cm-seed": "~1.7.4", + "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.2.1 " diff --git a/packages/contentstack-bootstrap/src/bootstrap/index.ts b/packages/contentstack-bootstrap/src/bootstrap/index.ts index 3b71912050..b0e8e9ae0f 100644 --- a/packages/contentstack-bootstrap/src/bootstrap/index.ts +++ b/packages/contentstack-bootstrap/src/bootstrap/index.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import { cliux } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath } from '@contentstack/cli-utilities'; import { default as ContentStackSeed } from '@contentstack/cli-cm-seed/lib/commands/cm/stacks/seed'; import { AppConfig } from '../config'; @@ -58,7 +58,7 @@ export default class Bootstrap { if (options.appConfig.branch) { this.repo.branch = options.appConfig.branch; } - this.cloneDirectory = path.join(options.cloneDirectory, this.repo.name); + this.cloneDirectory = path.join(sanitizePath(options.cloneDirectory), sanitizePath(this.repo.name)); this.ghClient = new GitHubClient(this.repo, options.appConfig.private, options.accessToken); this.options = options; } diff --git a/packages/contentstack-bootstrap/src/bootstrap/utils.ts b/packages/contentstack-bootstrap/src/bootstrap/utils.ts index 12bf53ddfd..82e91b226a 100644 --- a/packages/contentstack-bootstrap/src/bootstrap/utils.ts +++ b/packages/contentstack-bootstrap/src/bootstrap/utils.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; -import { cliux, pathValidator } from '@contentstack/cli-utilities'; +import { cliux, pathValidator, sanitizePath } from '@contentstack/cli-utilities'; import { continueBootstrapCommand } from '../bootstrap/interactive'; import { AppConfig } from '../config'; import messageHandler from '../messages'; @@ -154,7 +154,7 @@ const envFileHandler = async ( case 'reactjs': case 'reactjs-starter': fileName = `.env.${environmentVariables.environment}.local`; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); content = `REACT_APP_CONTENTSTACK_API_KEY=${ environmentVariables.api_key }\nREACT_APP_CONTENTSTACK_DELIVERY_TOKEN=${environmentVariables.deliveryToken}${ @@ -173,7 +173,7 @@ const envFileHandler = async ( case 'nextjs': case 'nextjs-starter': fileName = `.env.${environmentVariables.environment}.local`; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${ environmentVariables.deliveryToken }\n${ @@ -192,7 +192,7 @@ const envFileHandler = async ( case 'gatsby': case 'gatsby-starter': fileName = `.env.${environmentVariables.environment}`; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${ environmentVariables.deliveryToken }\n${ @@ -221,7 +221,7 @@ const envFileHandler = async ( !isUSRegion && !customHost ? `,\n\t\tregion: '${region.name}'` : '' } \n\t } \n };`; fileName = `.env${environmentVariables.environment === 'production' ? '.prod' : ''}`; - filePath = pathValidator(path.join(clonedDirectory, 'src', 'environments', fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), 'src', 'environments', sanitizePath(fileName))); result = await writeEnvFile(content, filePath); break; case 'angular-starter': @@ -239,7 +239,7 @@ const envFileHandler = async ( !isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : '' }\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`; fileName = `.env${environmentVariables.environment === 'production' ? '.prod' : ''}`; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); result = await writeEnvFile(content, filePath); break; case 'nuxtjs': @@ -247,7 +247,7 @@ const envFileHandler = async ( case 'nuxt3-starter': case 'stencil-starter': fileName = production ? '.env.production' : '.env'; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); // Note: Stencil app needs all the env variables, even if they are not having values otherwise the rollup does not work properly and throws process in undefined error. content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${ environmentVariables.deliveryToken @@ -266,7 +266,7 @@ const envFileHandler = async ( break; case 'vue-starter': fileName = '.env'; - filePath = pathValidator(path.join(clonedDirectory, fileName)); + filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName))); content = `VUE_APP_CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nVUE_APP_CONTENTSTACK_DELIVERY_TOKEN=${ environmentVariables.deliveryToken }\n${ diff --git a/packages/contentstack-branches/README.md b/packages/contentstack-branches/README.md index 63fad9728c..66fd355950 100755 --- a/packages/contentstack-branches/README.md +++ b/packages/contentstack-branches/README.md @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-branches/1.0.25 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-branches/1.0.26 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-branches/package.json b/packages/contentstack-branches/package.json index 8ed1ab4d58..2de3b52cf1 100644 --- a/packages/contentstack-branches/package.json +++ b/packages/contentstack-branches/package.json @@ -1,12 +1,12 @@ { "name": "@contentstack/cli-cm-branches", "description": "Contentstack CLI plugin to do branches operations", - "version": "1.0.25", + "version": "1.0.26", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^2.9.3", "async": "^3.2.4", "big-json": "^3.2.0", diff --git a/packages/contentstack-branches/src/utils/index.ts b/packages/contentstack-branches/src/utils/index.ts index 3f73553f68..da9a10cfdb 100644 --- a/packages/contentstack-branches/src/utils/index.ts +++ b/packages/contentstack-branches/src/utils/index.ts @@ -4,7 +4,7 @@ import fs from 'fs'; import path from 'path'; import forEach from 'lodash/forEach' -import { configHandler, cliux, messageHandler } from '@contentstack/cli-utilities'; +import { configHandler, cliux, messageHandler, sanitizePath } from '@contentstack/cli-utilities'; import { MergeParams } from '../interfaces'; export const getbranchesList = (branchResult, baseBranch: string) => { @@ -40,7 +40,7 @@ export const refreshbranchConfig = async (apiKey, branchUid) => { export const writeFile = (filePath, data) => { return new Promise((resolve, reject) => { data = typeof data === 'object' ? JSON.stringify(data, null, 2) : data || '{}'; - fs.writeFile(path.resolve(filePath), data, (error) => { + fs.writeFile(path.resolve(sanitizePath(filePath)), data, (error) => { if (error) { return reject(error); } @@ -52,7 +52,7 @@ export const writeFile = (filePath, data) => { // by default file type is json export const readFile = (filePath, options = { type: 'json' }) => { return new Promise((resolve, reject) => { - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); fs.readFile(filePath, 'utf-8', (error, data) => { if (error) { reject(error); diff --git a/packages/contentstack-bulk-publish/README.md b/packages/contentstack-bulk-publish/README.md index 9cbf43b092..4535acb855 100644 --- a/packages/contentstack-bulk-publish/README.md +++ b/packages/contentstack-bulk-publish/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-bulk-publish/1.4.6 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-bulk-publish/1.4.7 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bulk-publish/copyLogs.js b/packages/contentstack-bulk-publish/copyLogs.js index 9a18d966e6..73d2585855 100644 --- a/packages/contentstack-bulk-publish/copyLogs.js +++ b/packages/contentstack-bulk-publish/copyLogs.js @@ -4,6 +4,8 @@ const path = require('path'); const logFileDir = 'logs'; const dummyDir = 'test/dummy/'; +import { sanitizePath } from '@contentstack/cli-utilities'; + if (!fs.existsSync(path.join(__dirname, logFileDir))) { fs.mkdirSync(path.join(__dirname, logFileDir)); } @@ -30,5 +32,5 @@ const logs = [ ]; logs.forEach((element) => { - fs.createReadStream(path.join(__dirname, dummyDir, element)).pipe(fs.createWriteStream(path.join(__dirname, logFileDir, element))); + fs.createReadStream(path.join(__dirname, dummyDir, sanitizePath(element))).pipe(fs.createWriteStream(path.join(__dirname, logFileDir, sanitizePath(element)))); }); diff --git a/packages/contentstack-bulk-publish/package.json b/packages/contentstack-bulk-publish/package.json index 8caa2cdc5f..8a09c9f1be 100644 --- a/packages/contentstack-bulk-publish/package.json +++ b/packages/contentstack-bulk-publish/package.json @@ -1,12 +1,12 @@ { "name": "@contentstack/cli-cm-bulk-publish", "description": "Contentstack CLI plugin for bulk publish actions", - "version": "1.4.6", + "version": "1.4.7", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "bluebird": "^3.7.2", "chalk": "^4.1.2", "dotenv": "^16.1.4", diff --git a/packages/contentstack-bulk-publish/src/consumer/publish.js b/packages/contentstack-bulk-publish/src/consumer/publish.js index ad2d0ebc11..1c05186ce1 100644 --- a/packages/contentstack-bulk-publish/src/consumer/publish.js +++ b/packages/contentstack-bulk-publish/src/consumer/publish.js @@ -9,6 +9,7 @@ const apiVersionForNRP = '3.2'; const nrpApiVersionWarning = `Provided apiVersion is invalid. ${apiVersionForNRP} is only supported value. Continuing with regular bulk-publish for now.`; const { getLoggerInstance, addLogs, getLogsDirPath } = require('../util/logger'); +const { sanitizePath } = require('@contentstack/cli-utilities'); const logsDir = getLogsDirPath(); let logger; @@ -18,7 +19,7 @@ function initializeLogger(fileName) { fileNme = fileName; fileNme = `${Date.now()}.${fileNme}`; logger = getLoggerInstance(fileNme); - return path.join(logsDir, fileNme); + return path.join(logsDir, sanitizePath(fileNme)); } /* eslint-disable camelcase */ diff --git a/packages/contentstack-bulk-publish/src/util/logger.js b/packages/contentstack-bulk-publish/src/util/logger.js index 5da2d4108a..16434dd504 100644 --- a/packages/contentstack-bulk-publish/src/util/logger.js +++ b/packages/contentstack-bulk-publish/src/util/logger.js @@ -1,3 +1,4 @@ +const { sanitizePath } = require('@contentstack/cli-utilities'); const path = require('path'); const winston = require('winston'); const cwd = process.cwd(); @@ -6,7 +7,7 @@ const logsDir = path.join(cwd, 'contentstack-cli-logs', 'bulk-publish'); let filename; module.exports.getLoggerInstance = (fileName) => { - filename = path.join(logsDir, fileName); + filename = path.join(logsDir, sanitizePath(fileName)); return winston.createLogger({ transports: [ new winston.transports.File({ filename: `${filename}.error`, level: 'error' }), @@ -17,7 +18,7 @@ module.exports.getLoggerInstance = (fileName) => { /* eslint-disable no-multi-assign */ const getFileLoggerInstance = (module.exports.getFileLoggerInstance = (fileName) => { - filename = path.join(logsDir, fileName); + filename = path.join(logsDir, sanitizePath(fileName)); return winston.createLogger({ transports: [new winston.transports.File({ filename })], }); diff --git a/packages/contentstack-clone/README.md b/packages/contentstack-clone/README.md index 659c39f34e..1a9f7681df 100644 --- a/packages/contentstack-clone/README.md +++ b/packages/contentstack-clone/README.md @@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-clone/1.10.4 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-clone/1.10.5 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index 9bb97ca7ab..ed02269c3f 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -1,15 +1,15 @@ { "name": "@contentstack/cli-cm-clone", "description": "Contentstack stack clone plugin", - "version": "1.10.4", + "version": "1.10.5", "author": "Contentstack", "bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues", "dependencies": { "@colors/colors": "^1.5.0", - "@contentstack/cli-cm-export": "~1.11.3", - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", "chalk": "^4.1.0", "child_process": "^1.0.2", diff --git a/packages/contentstack-clone/src/lib/util/log.js b/packages/contentstack-clone/src/lib/util/log.js index 7cd92de20a..7d806cd9a8 100644 --- a/packages/contentstack-clone/src/lib/util/log.js +++ b/packages/contentstack-clone/src/lib/util/log.js @@ -1,13 +1,13 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ var winston = require('winston'); var path = require('path'); var mkdirp = require('mkdirp'); -const { pathValidator } = require('@contentstack/cli-utilities'); +const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities'); var slice = Array.prototype.slice; function returnString(args) { @@ -42,10 +42,10 @@ var myCustomLevels = { }; function init(_logPath, logfileName) { - var logsDir = pathValidator(path.resolve(_logPath, 'logs', 'import')); + var logsDir = pathValidator(path.resolve(sanitizePath(_logPath), 'logs', 'import')); // Create dir if doesn't already exist mkdirp.sync(logsDir); - var logPath = path.join(logsDir, pathValidator(logfileName) + '.log'); + var logPath = path.join(sanitizePath(logsDir), pathValidator(sanitizePath(logfileName)) + '.log'); var transports = [ new winston.transports.File({ diff --git a/packages/contentstack-command/package.json b/packages/contentstack-command/package.json index 416b56494f..e5bc4bc526 100644 --- a/packages/contentstack-command/package.json +++ b/packages/contentstack-command/package.json @@ -17,7 +17,7 @@ "format": "eslint src/**/*.ts --fix" }, "dependencies": { - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "contentstack": "^3.10.1" }, "devDependencies": { diff --git a/packages/contentstack-config/package.json b/packages/contentstack-config/package.json index d9446d5019..1220d1e8ac 100644 --- a/packages/contentstack-config/package.json +++ b/packages/contentstack-config/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", diff --git a/packages/contentstack-export-to-csv/package.json b/packages/contentstack-export-to-csv/package.json index c278b295fa..0db9e82fb7 100644 --- a/packages/contentstack-export-to-csv/package.json +++ b/packages/contentstack-export-to-csv/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "chalk": "^4.1.0", "fast-csv": "^4.3.6", "inquirer": "8.2.4", diff --git a/packages/contentstack-export/README.md b/packages/contentstack-export/README.md index a1c9704db1..3a44d34a01 100755 --- a/packages/contentstack-export/README.md +++ b/packages/contentstack-export/README.md @@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-export/1.11.3 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-export/1.11.4 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index 3b38c5b03e..b5531b2be7 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -1,12 +1,12 @@ { "name": "@contentstack/cli-cm-export", "description": "Contentstack CLI plugin to export content from stack", - "version": "1.11.3", + "version": "1.11.4", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", diff --git a/packages/contentstack-export/src/export/modules-js/assets.js b/packages/contentstack-export/src/export/modules-js/assets.js index e8c3fd4e7f..798e6320fd 100644 --- a/packages/contentstack-export/src/export/modules-js/assets.js +++ b/packages/contentstack-export/src/export/modules-js/assets.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -11,7 +11,7 @@ const Promise = require('bluebird'); const _ = require('lodash'); const chalk = require('chalk'); const progress = require('progress-stream'); -const { HttpClient, configHandler } = require('@contentstack/cli-utilities'); +const { HttpClient, configHandler, validateUids, sanitizePath, validateFileName } = require('@contentstack/cli-utilities'); const { fileHelper, log, formatError } = require('../../utils'); let { default: config } = require('../../config'); @@ -282,9 +282,11 @@ module.exports = class ExportAssets { } if (version <= 0) { - const assetVersionInfoFile = path.resolve(self.assetsFolderPath, uid, '_contentstack_' + uid + '.json'); - fileHelper.writeFileSync(assetVersionInfoFile, assetVersionInfo); - return resolve(); + if(validateUids(uid)){ + const assetVersionInfoFile = path.resolve(sanitizePath(self.assetsFolderPath), sanitizePath(uid), '_contentstack_' + sanitizePath(uid) + '.json'); + fileHelper.writeFileSync(assetVersionInfoFile, assetVersionInfo); + return resolve(); + } } const queryrequestOption = { version: version, @@ -327,8 +329,11 @@ module.exports = class ExportAssets { downloadAsset(asset) { const self = this; return new Promise(async (resolve, reject) => { - const assetFolderPath = path.resolve(self.assetsFolderPath, asset.uid); - const assetFilePath = path.resolve(assetFolderPath, asset.filename); + if(!validateUids(asset.uid) && !validateFileName(asset.filename)) { + reject(`UIDs not valid`) + } + const assetFolderPath = path.resolve(sanitizePath(self.assetsFolderPath), sanitizePath(asset.uid)); + const assetFilePath = path.resolve(sanitizePath(assetFolderPath), sanitizePath(asset.filename)); if (fs.existsSync(assetFilePath)) { log( diff --git a/packages/contentstack-export/src/export/modules-js/content-types.js b/packages/contentstack-export/src/export/modules-js/content-types.js index 058525a5bf..d5dcde84ee 100644 --- a/packages/contentstack-export/src/export/modules-js/content-types.js +++ b/packages/contentstack-export/src/export/modules-js/content-types.js @@ -1,6 +1,7 @@ const path = require('path'); const chalk = require('chalk'); const { fileHelper, executeTask, formatError, log } = require('../../utils'); +const { sanitizePath } = require('@contentstack/cli-utilities'); class ContentTypesExport { constructor(exportConfig, stackAPIClient) { @@ -18,9 +19,9 @@ class ContentTypesExport { this.qs.uid = { $in: this.exportConfig.contentTypes }; } this.contentTypesPath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - this.contentTypesConfig.dirName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName) || '', + sanitizePath(this.contentTypesConfig.dirName), ); this.contentTypes = []; this.fetchConcurrency = this.contentTypesConfig.fetchConcurrency || this.exportConfig.fetchConcurrency; @@ -76,7 +77,7 @@ class ContentTypesExport { async writeContentTypes(contentTypes) { function write(contentType) { return fileHelper.writeFile( - path.join(this.contentTypesPath, `${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`), + path.join(sanitizePath(this.contentTypesPath), `${sanitizePath (contentType.uid === 'schema' ? 'schema|1' : contentType.uid)}.json`), contentType, ); } diff --git a/packages/contentstack-export/src/export/modules-js/entries.js b/packages/contentstack-export/src/export/modules-js/entries.js index e3aaf126e0..a9a9627be7 100644 --- a/packages/contentstack-export/src/export/modules-js/entries.js +++ b/packages/contentstack-export/src/export/modules-js/entries.js @@ -2,23 +2,24 @@ const path = require('path'); const chalk = require('chalk'); const { values } = require('lodash'); const { executeTask, formatError, fileHelper, log } = require('../../utils'); +const { sanitizePath } = require('@contentstack/cli-utilities'); class EntriesExport { constructor(exportConfig, stackAPIClient) { this.stackAPIClient = stackAPIClient; this.exportConfig = exportConfig; this.entriesConfig = exportConfig.modules.entries; - this.entriesRootPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.entriesConfig.dirName); + this.entriesRootPath = path.resolve((sanitizePath(exportConfig.data)), sanitizePath(exportConfig.branchName || ''), sanitizePath(this.entriesConfig.dirName)); this.localesFilePath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - exportConfig.modules.locales.dirName, - exportConfig.modules.locales.fileName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(exportConfig.modules.locales.dirName), + sanitizePath(exportConfig.modules.locales.fileName), ); this.schemaFilePath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - exportConfig.modules.content_types.dirName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(exportConfig.modules.content_types.dirName), 'schema.json', ); this.fetchConcurrency = this.entriesConfig.fetchConcurrency || exportConfig.fetchConcurrency; @@ -78,7 +79,7 @@ class EntriesExport { if (versionedEntries.length > 0) { const write = (versionedEntry) => fileHelper.writeFile( - path.join(versionedEntryPath, 'version-' + versionedEntry._version + '.json'), + path.join(sanitizePath(versionedEntryPath), 'version-' + sanitizePath(versionedEntry._version) + '.json'), versionedEntry, ); await executeTask(versionedEntries, write.bind(this), { concurrency: this.writeConcurrency }); diff --git a/packages/contentstack-export/src/export/modules-js/environments.js b/packages/contentstack-export/src/export/modules-js/environments.js index 685e0a7aba..6c8af23acf 100644 --- a/packages/contentstack-export/src/export/modules-js/environments.js +++ b/packages/contentstack-export/src/export/modules-js/environments.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ const path = require('path'); diff --git a/packages/contentstack-export/src/export/modules-js/extensions.js b/packages/contentstack-export/src/export/modules-js/extensions.js index 8dced426b5..931b6f7c46 100644 --- a/packages/contentstack-export/src/export/modules-js/extensions.js +++ b/packages/contentstack-export/src/export/modules-js/extensions.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/export/modules-js/global-fields.js b/packages/contentstack-export/src/export/modules-js/global-fields.js index 7b2ee936c3..ef32dc6457 100644 --- a/packages/contentstack-export/src/export/modules-js/global-fields.js +++ b/packages/contentstack-export/src/export/modules-js/global-fields.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -10,6 +10,7 @@ const mkdirp = require('mkdirp'); const { merge } = require('lodash'); const { formatError, log, fileHelper } = require('../../utils'); const { default: config } = require('../../config'); +const { sanitizePath } = require('@contentstack/cli-utilities'); module.exports = class ExportGlobalFields { limit = 100; @@ -34,9 +35,9 @@ module.exports = class ExportGlobalFields { this.config = merge(config, exportConfig); this.stackAPIClient = stackAPIClient; this.globalfieldsFolderPath = path.resolve( - this.config.data, - this.config.branchName || '', - this.globalfieldsConfig.dirName, + sanitizePath(this.config.data), + sanitizePath(this.config.branchName || ''), + sanitizePath(this.globalfieldsConfig.dirName), ); } diff --git a/packages/contentstack-export/src/export/modules-js/labels.js b/packages/contentstack-export/src/export/modules-js/labels.js index 03e19ef4d9..9b6f4fba20 100644 --- a/packages/contentstack-export/src/export/modules-js/labels.js +++ b/packages/contentstack-export/src/export/modules-js/labels.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/export/modules-js/locales.js b/packages/contentstack-export/src/export/modules-js/locales.js index 9aac775951..a377737d7b 100644 --- a/packages/contentstack-export/src/export/modules-js/locales.js +++ b/packages/contentstack-export/src/export/modules-js/locales.js @@ -1,6 +1,7 @@ const path = require('path'); const chalk = require('chalk'); const { formatError, log, fileHelper } = require('../../utils'); +const { sanitizePath } = require('@contentstack/cli-utilities'); class LocaleExport { constructor(exportConfig, stackAPIClient) { this.stackAPIClient = stackAPIClient; @@ -15,7 +16,7 @@ class LocaleExport { }, }; - this.localesPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.localeConfig.dirName); + this.localesPath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''), sanitizePath(this.localeConfig.dirName)); this.locales = {}; this.masterLocale = {}; this.fetchConcurrency = this.localeConfig.fetchConcurrency || this.exportConfig.fetchConcurrency; diff --git a/packages/contentstack-export/src/export/modules-js/marketplace-apps.js b/packages/contentstack-export/src/export/modules-js/marketplace-apps.js index 88c051b651..686da41e86 100644 --- a/packages/contentstack-export/src/export/modules-js/marketplace-apps.js +++ b/packages/contentstack-export/src/export/modules-js/marketplace-apps.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ const _ = require('lodash'); diff --git a/packages/contentstack-export/src/export/modules-js/stack.js b/packages/contentstack-export/src/export/modules-js/stack.js index 4f4e8329c4..d585964c04 100644 --- a/packages/contentstack-export/src/export/modules-js/stack.js +++ b/packages/contentstack-export/src/export/modules-js/stack.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/export/modules-js/webhooks.js b/packages/contentstack-export/src/export/modules-js/webhooks.js index 32c5d5c02e..ec5e559a20 100644 --- a/packages/contentstack-export/src/export/modules-js/webhooks.js +++ b/packages/contentstack-export/src/export/modules-js/webhooks.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/export/modules-js/workflows.js b/packages/contentstack-export/src/export/modules-js/workflows.js index ec9460850c..e7cd7667ff 100644 --- a/packages/contentstack-export/src/export/modules-js/workflows.js +++ b/packages/contentstack-export/src/export/modules-js/workflows.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/export/modules/content-types.ts b/packages/contentstack-export/src/export/modules/content-types.ts index 54ccdbd8c1..9e714ec9d0 100644 --- a/packages/contentstack-export/src/export/modules/content-types.ts +++ b/packages/contentstack-export/src/export/modules/content-types.ts @@ -3,6 +3,7 @@ import { ContentstackClient } from '@contentstack/cli-utilities'; import { log, formatError, fsUtil, executeTask } from '../../utils'; import { ExportConfig, ModuleClassParams } from '../../types'; import BaseClass from './base-class'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class ContentTypesExport extends BaseClass { private stackAPIClient: ReturnType; @@ -43,9 +44,9 @@ export default class ContentTypesExport extends BaseClass { } this.contentTypesDirPath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - this.contentTypesConfig.dirName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(this.contentTypesConfig.dirName), ); this.contentTypes = []; } @@ -98,7 +99,7 @@ export default class ContentTypesExport extends BaseClass { async writeContentTypes(contentTypes: Record[]) { function write(contentType: Record) { return fsUtil.writeFile( - path.join(this.contentTypesDirPath, `${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`), + path.join(sanitizePath(this.contentTypesDirPath), sanitizePath(`${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`)), contentType, ); } diff --git a/packages/contentstack-export/src/export/modules/entries.ts b/packages/contentstack-export/src/export/modules/entries.ts index b1981929cf..14964f9c77 100644 --- a/packages/contentstack-export/src/export/modules/entries.ts +++ b/packages/contentstack-export/src/export/modules/entries.ts @@ -3,6 +3,7 @@ import { ContentstackClient, FsUtility } from '@contentstack/cli-utilities'; import { log, formatError, fsUtil } from '../../utils'; import { ExportConfig, ModuleClassParams } from '../../types'; import BaseClass, { ApiOptions } from './base-class'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class EntriesExport extends BaseClass { private stackAPIClient: ReturnType; @@ -28,17 +29,17 @@ export default class EntriesExport extends BaseClass { this.stackAPIClient = stackAPIClient; this.exportConfig = exportConfig; this.entriesConfig = exportConfig.modules.entries; - this.entriesDirPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.entriesConfig.dirName); + this.entriesDirPath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''), sanitizePath(this.entriesConfig.dirName)); this.localesFilePath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - exportConfig.modules.locales.dirName, - exportConfig.modules.locales.fileName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(exportConfig.modules.locales.dirName), + sanitizePath(exportConfig.modules.locales.fileName), ); this.schemaFilePath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - exportConfig.modules.content_types.dirName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(exportConfig.modules.content_types.dirName), 'schema.json', ); } @@ -118,7 +119,7 @@ export default class EntriesExport extends BaseClass { if (Array.isArray(entriesSearchResponse.items) && entriesSearchResponse.items.length > 0) { if (options.skip === 0) { - const entryBasePath = path.join(this.entriesDirPath, options.contentType, options.locale); + const entryBasePath = path.join(sanitizePath(this.entriesDirPath), sanitizePath(options.contentType), sanitizePath(options.locale)); await fsUtil.makeDirectory(entryBasePath); this.entriesFileHelper = new FsUtility({ moduleName: 'entries', @@ -131,7 +132,7 @@ export default class EntriesExport extends BaseClass { } this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true }); if (this.entriesConfig.exportVersions) { - let versionedEntryPath = path.join(this.entriesDirPath, options.contentType, options.locale, 'versions'); + let versionedEntryPath = path.join(sanitizePath(this.entriesDirPath), sanitizePath(options.contentType),sanitizePath(options.locale), 'versions'); fsUtil.makeDirectory(versionedEntryPath); await this.fetchEntriesVersions(entriesSearchResponse.items, { locale: options.locale, @@ -152,7 +153,7 @@ export default class EntriesExport extends BaseClass { options: { locale: string; contentType: string; versionedEntryPath: string }, ): Promise { const onSuccess = ({ response, apiData: entry }: any) => { - fsUtil.writeFile(path.join(options.versionedEntryPath, `${entry.uid}.json`), response); + fsUtil.writeFile(path.join(sanitizePath(options.versionedEntryPath), sanitizePath(`${entry.uid}.json`)), response); log( this.exportConfig, `Exported versioned entries of type '${options.contentType}' locale '${options.locale}'`, diff --git a/packages/contentstack-export/src/export/modules/global-fields.ts b/packages/contentstack-export/src/export/modules/global-fields.ts index 6a364a7656..3085eeb3cd 100644 --- a/packages/contentstack-export/src/export/modules/global-fields.ts +++ b/packages/contentstack-export/src/export/modules/global-fields.ts @@ -3,6 +3,7 @@ import { ContentstackClient } from '@contentstack/cli-utilities'; import { log, formatError, fsUtil } from '../../utils'; import { ExportConfig, ModuleClassParams } from '../../types'; import BaseClass from './base-class'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class GlobalFieldsExport extends BaseClass { private stackAPIClient: ReturnType; @@ -35,9 +36,9 @@ export default class GlobalFieldsExport extends BaseClass { limit: this.globalFieldsConfig.limit, }; this.globalFieldsDirPath = path.resolve( - exportConfig.data, - exportConfig.branchName || '', - this.globalFieldsConfig.dirName, + sanitizePath(exportConfig.data), + sanitizePath(exportConfig.branchName || ''), + sanitizePath(this.globalFieldsConfig.dirName), ); this.globalFields = []; } diff --git a/packages/contentstack-export/src/export/modules/locales.ts b/packages/contentstack-export/src/export/modules/locales.ts index 5043882215..602da209bd 100644 --- a/packages/contentstack-export/src/export/modules/locales.ts +++ b/packages/contentstack-export/src/export/modules/locales.ts @@ -3,6 +3,7 @@ import { ContentstackClient } from '@contentstack/cli-utilities'; import { log, formatError, fsUtil } from '../../utils'; import { ExportConfig, ModuleClassParams } from '../../types'; import BaseClass from './base-class'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class LocaleExport extends BaseClass { private stackAPIClient: ReturnType; @@ -40,7 +41,7 @@ export default class LocaleExport extends BaseClass { BASE: this.localeConfig.requiredKeys, }, }; - this.localesPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.localeConfig.dirName); + this.localesPath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''),sanitizePath(this.localeConfig.dirName)); this.locales = {}; this.masterLocale = {}; } diff --git a/packages/contentstack-export/src/utils/basic-login.ts b/packages/contentstack-export/src/utils/basic-login.ts index e324c70f97..87e1cc5932 100644 --- a/packages/contentstack-export/src/utils/basic-login.ts +++ b/packages/contentstack-export/src/utils/basic-login.ts @@ -3,7 +3,7 @@ /* eslint-disable no-empty */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-export/src/utils/common-helper.ts b/packages/contentstack-export/src/utils/common-helper.ts index c0c45cc058..8084b86106 100644 --- a/packages/contentstack-export/src/utils/common-helper.ts +++ b/packages/contentstack-export/src/utils/common-helper.ts @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -9,6 +9,7 @@ import * as path from 'path'; import { isAuthenticated } from '@contentstack/cli-utilities'; import { ExternalConfig, ExportConfig } from '../types'; import { fsUtil } from './file-helper'; +import { sanitizePath } from '@contentstack/cli-utilities'; export const validateConfig = function (config: ExternalConfig) { if (!config.host || !config.cdn) { @@ -83,7 +84,7 @@ export const executeTask = function ( export const writeExportMetaFile = (exportConfig: ExportConfig, metaFilePath?: string) => { const exportMeta = { contentVersion: exportConfig.contentVersion, - logsPath: path.join(exportConfig.exportDir, 'logs', 'export'), + logsPath: path.join(sanitizePath(exportConfig.exportDir), 'logs', 'export'), }; - fsUtil.writeFile(path.join(metaFilePath || exportConfig.exportDir, 'export-info.json'), exportMeta); + fsUtil.writeFile(path.join(sanitizePath(metaFilePath || exportConfig.exportDir), 'export-info.json'), exportMeta); }; diff --git a/packages/contentstack-export/src/utils/file-helper.ts b/packages/contentstack-export/src/utils/file-helper.ts index a329787094..5afc464418 100644 --- a/packages/contentstack-export/src/utils/file-helper.ts +++ b/packages/contentstack-export/src/utils/file-helper.ts @@ -2,12 +2,12 @@ import * as fs from 'fs'; import * as path from 'path'; import mkdirp from 'mkdirp'; import bigJSON from 'big-json'; -import { FsUtility } from '@contentstack/cli-utilities'; +import { FsUtility, sanitizePath } from '@contentstack/cli-utilities'; export const readFileSync = function (filePath: string, parse: boolean): unknown { let data; parse = typeof parse === 'undefined' ? true : parse; - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); if (fs.existsSync(filePath)) { data = parse ? JSON.parse(fs.readFileSync(filePath, 'utf8')) : data; } @@ -17,7 +17,7 @@ export const readFileSync = function (filePath: string, parse: boolean): unknown // by default file type is json export const readFile = async (filePath: string, options = { type: 'json' }): Promise => { return new Promise((resolve, reject) => { - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); fs.readFile(filePath, 'utf-8', (error, data) => { if (error) { reject(error); @@ -35,7 +35,7 @@ export const readLargeFile = function (filePath: string, options: { type?: strin if (typeof filePath !== 'string') { return; } - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); if (fs.existsSync(filePath)) { return new Promise((resolve, reject) => { const readStream = fs.createReadStream(filePath, { encoding: 'utf-8' }); @@ -76,7 +76,7 @@ export const writeLargeFile = function (filePath: string, data: any): Promise { const stringifyStream = bigJSON.createStringifyStream({ body: data, diff --git a/packages/contentstack-export/src/utils/logger.ts b/packages/contentstack-export/src/utils/logger.ts index 944a08e9bc..39fba53adb 100644 --- a/packages/contentstack-export/src/utils/logger.ts +++ b/packages/contentstack-export/src/utils/logger.ts @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -8,7 +8,7 @@ import * as winston from 'winston'; import * as path from 'path'; import mkdirp from 'mkdirp'; import { ExportConfig } from '../types'; - +import { sanitizePath } from '@contentstack/cli-utilities' const slice = Array.prototype.slice; const ansiRegexPattern = [ @@ -24,7 +24,7 @@ function returnString(args: unknown[]) { if (item && typeof item === 'object') { try { return JSON.stringify(item).replace(/authtoken\":\d"blt................/g, 'authtoken":"blt....'); - } catch (error) {} + } catch (error) { } return item; } return item; @@ -58,12 +58,12 @@ let errorTransport; function init(_logPath: string) { if (!logger || !errorLogger) { - const logsDir = path.resolve(_logPath, 'logs', 'export'); + const logsDir = path.resolve(sanitizePath(_logPath), 'logs', 'export'); // Create dir if doesn't already exist mkdirp.sync(logsDir); successTransport = { - filename: path.join(logsDir, 'success.log'), + filename: path.join(sanitizePath(logsDir), 'success.log'), maxFiles: 20, maxsize: 1000000, tailable: true, @@ -71,7 +71,7 @@ function init(_logPath: string) { }; errorTransport = { - filename: path.join(logsDir, 'error.log'), + filename: path.join(sanitizePath(logsDir), 'error.log'), maxFiles: 20, maxsize: 1000000, tailable: true, diff --git a/packages/contentstack-export/src/utils/setup-branches.ts b/packages/contentstack-export/src/utils/setup-branches.ts index d2051f003f..e7ef011b06 100644 --- a/packages/contentstack-export/src/utils/setup-branches.ts +++ b/packages/contentstack-export/src/utils/setup-branches.ts @@ -2,6 +2,7 @@ import * as path from 'path'; import { writeFileSync, makeDirectory } from './file-helper'; import { isAuthenticated, configHandler } from '@contentstack/cli-utilities'; import { ExportConfig } from '../types'; +import { sanitizePath } from '@contentstack/cli-utilities'; const setupBranches = async (config: ExportConfig, stackAPIClient: any) => { if (typeof config !== 'object') { @@ -40,7 +41,7 @@ const setupBranches = async (config: ExportConfig, stackAPIClient: any) => { makeDirectory(config.exportDir); // create branch info file - writeFileSync(path.join(config.exportDir, 'branches.json'), branches); + writeFileSync(path.join(sanitizePath(config.exportDir), 'branches.json'), branches); // add branches list in the config.branches = branches; }; diff --git a/packages/contentstack-export/src/utils/setup-export-dir.ts b/packages/contentstack-export/src/utils/setup-export-dir.ts index 26cc3737b6..e36237fd08 100644 --- a/packages/contentstack-export/src/utils/setup-export-dir.ts +++ b/packages/contentstack-export/src/utils/setup-export-dir.ts @@ -1,12 +1,13 @@ import path from 'path'; import { ExportConfig } from '../types'; import { makeDirectory } from './file-helper'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default async function setupExportDir(exportConfig: ExportConfig) { makeDirectory(exportConfig.exportDir); if (exportConfig.branches) { return Promise.all( - exportConfig.branches.map((branch) => makeDirectory(path.join(exportConfig.exportDir, branch.uid))), + exportConfig.branches.map((branch) => makeDirectory(path.join(sanitizePath(exportConfig.exportDir), sanitizePath(branch.uid)))), ); } } diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index 6be14da3eb..515c62c35e 100644 --- a/packages/contentstack-import/README.md +++ b/packages/contentstack-import/README.md @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-import/1.15.5 darwin-arm64 node-v21.6.2 +@contentstack/cli-cm-import/1.15.6 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 79736b60bd..b7204be466 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -1,13 +1,13 @@ { "name": "@contentstack/cli-cm-import", "description": "Contentstack CLI plugin to import content into stack", - "version": "1.15.5", + "version": "1.15.6", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { - "@contentstack/cli-audit": "~1.6.1", + "@contentstack/cli-audit": "~1.6.2", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", diff --git a/packages/contentstack-import/src/import/modules-js/assets.js b/packages/contentstack-import/src/import/modules-js/assets.js index 3ed612cd7c..df621297dd 100755 --- a/packages/contentstack-import/src/import/modules-js/assets.js +++ b/packages/contentstack-import/src/import/modules-js/assets.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ const fs = require('fs'); @@ -11,6 +11,7 @@ const mkdirp = require('mkdirp'); const Promise = require('bluebird'); let { default: config } = require('../../config'); const { fileHelper, log, uploadAssetHelper } = require('../../utils'); +const { sanitizePath, validateUids, validateFileName } = require('@contentstack/cli-utilities'); module.exports = class ImportAssets { assets; @@ -88,7 +89,10 @@ module.exports = class ImportAssets { // the asset has been already imported return void 0; } - let currentAssetFolderPath = path.join(self.assetsFolderPath, assetUid); + if(!validateUids(assetUid)){ + reject(`UID Not Valid`) + } + let currentAssetFolderPath = path.join(sanitizePath(self.assetsFolderPath), sanitizePath(assetUid)); if (fs.existsSync(currentAssetFolderPath)) { // if this is true, means, the exported asset data is versioned // hence, upload each asset with its version @@ -100,7 +104,10 @@ module.exports = class ImportAssets { let uidContainer = {}; let urlContainer = {}; - let assetPath = path.resolve(currentAssetFolderPath, self.assets[assetUid].filename); + if(!validateFileName(self.assets[assetUid].filename)){ + reject(`File Name Not Valid`) + } + let assetPath = path.resolve(sanitizePath(currentAssetFolderPath), sanitizePath(self.assets[assetUid].filename)); if (self.assets[assetUid].parent_uid && typeof self.assets[assetUid].parent_uid === 'string') { if (self.mappedFolderUids.hasOwnProperty(self.assets[assetUid].parent_uid)) { @@ -179,8 +186,11 @@ module.exports = class ImportAssets { uploadVersionedAssets(uid, assetFolderPath) { let self = this; return new Promise(function (resolve, reject) { + if(!validateUids(uid)){ + reject(`UID not valid`) + } let versionedAssetMetadata = fileHelper.readFileSync( - path.join(assetFolderPath, '_contentstack_' + uid + '.json'), + path.join(sanitizePath(assetFolderPath), '_contentstack_' + sanitizePath(uid) + '.json'), ); // using last version, find asset's parent let lastVersion = versionedAssetMetadata[versionedAssetMetadata.length - 1]; @@ -207,7 +217,10 @@ module.exports = class ImportAssets { versionedAssetMetadata, function () { let assetMetadata = versionedAssetMetadata[counter]; - let assetPath = path.join(assetFolderPath, assetMetadata.filename); + if(!validateFileName(assetMetadata.filename)){ + reject(`File Name not valid`) + } + let assetPath = path.join(sanitizePath(assetFolderPath), sanitizePath(assetMetadata.filename)); if (++counter === 1) { return self diff --git a/packages/contentstack-import/src/import/modules-js/content-types.js b/packages/contentstack-import/src/import/modules-js/content-types.js index 7a1f000068..0c7e1df68a 100755 --- a/packages/contentstack-import/src/import/modules-js/content-types.js +++ b/packages/contentstack-import/src/import/modules-js/content-types.js @@ -3,6 +3,7 @@ const path = require('path'); const chalk = require('chalk'); const { cloneDeep, find, findIndex } = require('lodash'); const { fileHelper, log, executeTask, formatError, schemaTemplate, lookupExtension } = require('../../utils'); +const { sanitizePath } = require('@contentstack/cli-utilities'); class ContentTypesImport { constructor(importConfig, stackAPIClient) { @@ -12,12 +13,12 @@ class ContentTypesImport { this.globalFieldConfig = importConfig.modules.globalfields; this.importConcurrency = this.contentTypeConfig.importConcurrency || this.importConfig.importConcurrency; this.writeConcurrency = this.contentTypeConfig.writeConcurrency || this.importConfig.writeConcurrency; - this.contentTypesFolderPath = path.join(this.importConfig.data, this.contentTypeConfig.dirName); - this.mapperFolderPath = path.join(this.importConfig.data, 'mapper', 'content_types'); - this.existingContentTypesPath = path.join(this.mapperFolderPath, 'success.json'); - this.globalFieldsFolderPath = path.resolve(this.importConfig.data, this.globalFieldConfig.dirName); - this.globalFieldMapperFolderPath = path.join(importConfig.data, 'mapper', 'global_fields', 'success.json'); - this.globalFieldPendingPath = path.join(importConfig.data, 'mapper', 'global_fields', 'pending_global_fields.js'); + this.contentTypesFolderPath = path.join(sanitizePath(this.importConfig.data), sanitizePath(this.contentTypeConfig.dirName)); + this.mapperFolderPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'content_types'); + this.existingContentTypesPath = path.join(sanitizePath(this.mapperFolderPath), 'success.json'); + this.globalFieldsFolderPath = path.resolve(sanitizePath(this.importConfig.data),sanitizePath(this.globalFieldConfig.dirName)); + this.globalFieldMapperFolderPath = path.join(sanitizePath(importConfig.data), 'mapper', 'global_fields', 'success.json'); + this.globalFieldPendingPath = path.join(sanitizePath(importConfig.data), 'mapper', 'global_fields', 'pending_global_fields.js'); this.ignoredFilesInContentTypesFolder = new Map([ ['__master.json', 'true'], ['__priority.json', 'true'], diff --git a/packages/contentstack-import/src/import/modules-js/entries.js b/packages/contentstack-import/src/import/modules-js/entries.js index 72a4a12f13..9583d447e7 100755 --- a/packages/contentstack-import/src/import/modules-js/entries.js +++ b/packages/contentstack-import/src/import/modules-js/entries.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -20,6 +20,7 @@ const { lookupEntries, } = require('../../utils'); const { default: config } = require('../../config'); +const { sanitizePath } = require('@contentstack/cli-utilities'); const addlogs = log; module.exports = class ImportEntries { mappedAssetUidPath; @@ -838,7 +839,7 @@ module.exports = class ImportEntries { return resolve(); } self.mappedUids[query.entry.uid] = response.body.entries[0].uid; - let _ePath = path.join(this.entryMapperPath, query.locale, query.content_type, 'success.json'); + let _ePath = path.join(sanitizePath(this.entryMapperPath), sanitizePath(query.locale), sanitizePath(query.content_type), 'success.json'); let entries = fileHelper.readFileSync(_ePath); entries.push(query.entry); fileHelper.writeFileSync(_ePath, entries); diff --git a/packages/contentstack-import/src/import/modules-js/environments.js b/packages/contentstack-import/src/import/modules-js/environments.js index d56650fe4e..3da28de070 100755 --- a/packages/contentstack-import/src/import/modules-js/environments.js +++ b/packages/contentstack-import/src/import/modules-js/environments.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/extensions.js b/packages/contentstack-import/src/import/modules-js/extensions.js index 42145aec2d..47f1031b9c 100644 --- a/packages/contentstack-import/src/import/modules-js/extensions.js +++ b/packages/contentstack-import/src/import/modules-js/extensions.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/global-fields.js b/packages/contentstack-import/src/import/modules-js/global-fields.js index e830271aa2..12ea4a4d86 100644 --- a/packages/contentstack-import/src/import/modules-js/global-fields.js +++ b/packages/contentstack-import/src/import/modules-js/global-fields.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/labels.js b/packages/contentstack-import/src/import/modules-js/labels.js index 32dc585cd7..b685f78d23 100644 --- a/packages/contentstack-import/src/import/modules-js/labels.js +++ b/packages/contentstack-import/src/import/modules-js/labels.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/locales.js b/packages/contentstack-import/src/import/modules-js/locales.js index fd8eba0cf4..1b2d12828c 100755 --- a/packages/contentstack-import/src/import/modules-js/locales.js +++ b/packages/contentstack-import/src/import/modules-js/locales.js @@ -1,7 +1,7 @@ /* eslint-disable no-prototype-builtins */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/marketplace-apps.js b/packages/contentstack-import/src/import/modules-js/marketplace-apps.js index 44ac6102a7..a651cb8aef 100644 --- a/packages/contentstack-import/src/import/modules-js/marketplace-apps.js +++ b/packages/contentstack-import/src/import/modules-js/marketplace-apps.js @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ const fs = require('fs'); diff --git a/packages/contentstack-import/src/import/modules-js/webhooks.js b/packages/contentstack-import/src/import/modules-js/webhooks.js index 5d89090631..fb5c573e47 100644 --- a/packages/contentstack-import/src/import/modules-js/webhooks.js +++ b/packages/contentstack-import/src/import/modules-js/webhooks.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules-js/workflows.js b/packages/contentstack-import/src/import/modules-js/workflows.js index f782201075..494dbc3c41 100644 --- a/packages/contentstack-import/src/import/modules-js/workflows.js +++ b/packages/contentstack-import/src/import/modules-js/workflows.js @@ -1,6 +1,6 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/import/modules/content-types.ts b/packages/contentstack-import/src/import/modules/content-types.ts index cf4a573195..0590d93ac4 100644 --- a/packages/contentstack-import/src/import/modules/content-types.ts +++ b/packages/contentstack-import/src/import/modules/content-types.ts @@ -1,7 +1,7 @@ /* eslint-disable no-prototype-builtins */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -11,6 +11,7 @@ import { fsUtil, log, formatError, schemaTemplate, lookupExtension, lookUpTaxono import { ImportConfig, ModuleClassParams } from '../../types'; import BaseClass, { ApiOptions } from './base-class'; import { updateFieldRules } from '../../utils/content-type-helper'; +import { sanitizePath } from '@contentstack/cli-utilities'; export default class ContentTypesImport extends BaseClass { private cTsMapperPath: string; @@ -59,13 +60,13 @@ export default class ContentTypesImport extends BaseClass { this.cTsConfig = importConfig.modules['content-types']; this.gFsConfig = importConfig.modules['global-fields']; this.reqConcurrency = this.cTsConfig.writeConcurrency || this.importConfig.writeConcurrency; - this.cTsFolderPath = path.join(this.importConfig.data, this.cTsConfig.dirName); - this.cTsMapperPath = path.join(this.importConfig.data, 'mapper', 'content_types'); - this.cTsSuccessPath = path.join(this.cTsMapperPath, 'success.json'); - this.gFsFolderPath = path.resolve(this.importConfig.data, this.gFsConfig.dirName); - this.gFsMapperFolderPath = path.join(importConfig.data, 'mapper', 'global_fields', 'success.json'); - this.gFsPendingPath = path.join(importConfig.data, 'mapper', 'global_fields', 'pending_global_fields.js'); - this.marketplaceAppMapperPath = path.join(this.importConfig.data, 'mapper', 'marketplace_apps', 'uid-mapping.json'); + this.cTsFolderPath = path.join(sanitizePath(this.importConfig.data), sanitizePath(this.cTsConfig.dirName)); + this.cTsMapperPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'content_types'); + this.cTsSuccessPath = path.join(sanitizePath(this.cTsMapperPath), 'success.json'); + this.gFsFolderPath = path.resolve(sanitizePath(this.importConfig.data), sanitizePath(this.gFsConfig.dirName)); + this.gFsMapperFolderPath = path.join(sanitizePath(importConfig.data), 'mapper', 'global_fields', 'success.json'); + this.gFsPendingPath = path.join(sanitizePath(importConfig.data), 'mapper', 'global_fields', 'pending_global_fields.js'); + this.marketplaceAppMapperPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'marketplace_apps', 'uid-mapping.json'); this.ignoredFilesInContentTypesFolder = new Map([ ['__master.json', 'true'], ['__priority.json', 'true'], @@ -79,8 +80,8 @@ export default class ContentTypesImport extends BaseClass { this.gFs = []; this.createdGFs = []; this.pendingGFs = []; - this.taxonomiesPath = path.join(importConfig.data, 'mapper/taxonomies', 'success.json'); - this.extPendingPath = path.join(importConfig.data, 'mapper', 'extensions', 'pending_extensions.js'); + this.taxonomiesPath = path.join(sanitizePath(importConfig.data), 'mapper/taxonomies', 'success.json'); + this.extPendingPath = path.join(sanitizePath(importConfig.data), 'mapper', 'extensions', 'pending_extensions.js'); } async start(): Promise { diff --git a/packages/contentstack-import/src/import/modules/entries.ts b/packages/contentstack-import/src/import/modules/entries.ts index b3a9372c93..bae0769e41 100644 --- a/packages/contentstack-import/src/import/modules/entries.ts +++ b/packages/contentstack-import/src/import/modules/entries.ts @@ -1,13 +1,13 @@ /* eslint-disable no-prototype-builtins */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ import * as path from 'path'; import { isEmpty, values, cloneDeep, find, indexOf, forEach } from 'lodash'; -import { FsUtility } from '@contentstack/cli-utilities'; +import { FsUtility, sanitizePath } from '@contentstack/cli-utilities'; import { fsUtil, log, @@ -61,22 +61,22 @@ export default class EntriesImport extends BaseClass { constructor({ importConfig, stackAPIClient }: ModuleClassParams) { super({ importConfig, stackAPIClient }); - this.assetUidMapperPath = path.resolve(importConfig.data, 'mapper', 'assets', 'uid-mapping.json'); - this.assetUrlMapperPath = path.resolve(importConfig.data, 'mapper', 'assets', 'url-mapping.json'); - this.entriesMapperPath = path.resolve(importConfig.data, 'mapper', 'entries'); - this.envPath = path.resolve(importConfig.data, 'environments', 'environments.json'); - this.entriesUIDMapperPath = path.join(this.entriesMapperPath, 'uid-mapping.json'); - this.uniqueUidMapperPath = path.join(this.entriesMapperPath, 'unique-mapping.json'); - this.modifiedCTsPath = path.join(this.entriesMapperPath, 'modified-schemas.json'); - this.marketplaceAppMapperPath = path.join(this.importConfig.data, 'mapper', 'marketplace_apps', 'uid-mapping.json'); - this.taxonomiesPath = path.join(this.importConfig.data, 'mapper', 'taxonomies', 'terms', 'success.json'); + this.assetUidMapperPath = path.resolve(sanitizePath(importConfig.data), 'mapper', 'assets', 'uid-mapping.json'); + this.assetUrlMapperPath = path.resolve(sanitizePath(importConfig.data), 'mapper', 'assets', 'url-mapping.json'); + this.entriesMapperPath = path.resolve(sanitizePath(importConfig.data), 'mapper', 'entries'); + this.envPath = path.resolve(sanitizePath(importConfig.data), 'environments', 'environments.json'); + this.entriesUIDMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'uid-mapping.json'); + this.uniqueUidMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'unique-mapping.json'); + this.modifiedCTsPath = path.join(sanitizePath(this.entriesMapperPath), 'modified-schemas.json'); + this.marketplaceAppMapperPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'marketplace_apps', 'uid-mapping.json'); + this.taxonomiesPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'taxonomies', 'terms', 'success.json'); this.entriesConfig = importConfig.modules.entries; - this.entriesPath = path.resolve(importConfig.data, this.entriesConfig.dirName); - this.cTsPath = path.resolve(importConfig.data, importConfig.modules['content-types'].dirName); + this.entriesPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(this.entriesConfig.dirName)); + this.cTsPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(importConfig.modules['content-types'].dirName)); this.localesPath = path.resolve( - importConfig.data, - importConfig.modules.locales.dirName, - importConfig.modules.locales.fileName, + sanitizePath(importConfig.data), + sanitizePath(importConfig.modules.locales.dirName), + sanitizePath(importConfig.modules.locales.fileName), ); this.importConcurrency = this.entriesConfig.importConcurrency || importConfig.importConcurrency; this.entriesUidMapper = {}; @@ -336,7 +336,7 @@ export default class EntriesImport extends BaseClass { ); entry.uid = oldUid; entry.entryOldUid = oldUid; - entry.sourceEntryFilePath = path.join(basePath, additionalInfo.entryFileName); // stores source file path temporarily + entry.sourceEntryFilePath = path.join(sanitizePath(basePath), sanitizePath(additionalInfo.entryFileName)); // stores source file path temporarily entriesCreateFileHelper.writeIntoFile({ [oldUid]: entry } as any, { mapKeyVal: true }); } else { log(this.importConfig, `Created entry: '${entry.title}' of content type ${cTUid} in locale ${locale}`, 'info'); @@ -348,7 +348,7 @@ export default class EntriesImport extends BaseClass { this.autoCreatedEntries.push({ cTUid, locale, entryUid: response.uid }); } this.entriesUidMapper[entry.uid] = response.uid; - entry.sourceEntryFilePath = path.join(basePath, additionalInfo.entryFileName); // stores source file path temporarily + entry.sourceEntryFilePath = path.join(sanitizePath(basePath), sanitizePath(additionalInfo.entryFileName)); // stores source file path temporarily entry.entryOldUid = entry.uid; // stores old uid temporarily entriesCreateFileHelper.writeIntoFile({ [entry.uid]: entry } as any, { mapKeyVal: true }); } @@ -360,7 +360,7 @@ export default class EntriesImport extends BaseClass { if (error?.errors?.title || error?.errors?.uid) { if (this.importConfig.replaceExisting) { entry.entryOldUid = uid; - entry.sourceEntryFilePath = path.join(basePath, additionalInfo.entryFileName); // stores source file path temporarily + entry.sourceEntryFilePath = path.join(sanitizePath(basePath), sanitizePath(additionalInfo.entryFileName)); // stores source file path temporarily existingEntriesFileHelper.writeIntoFile({ [uid]: entry } as any, { mapKeyVal: true }); } if (!this.importConfig.skipExisting) { diff --git a/packages/contentstack-import/src/import/modules/global-fields.ts b/packages/contentstack-import/src/import/modules/global-fields.ts index 4cb4789cd1..a4e32e95bb 100644 --- a/packages/contentstack-import/src/import/modules/global-fields.ts +++ b/packages/contentstack-import/src/import/modules/global-fields.ts @@ -1,13 +1,13 @@ /* eslint-disable no-prototype-builtins */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ import * as path from 'path'; import { isEmpty, cloneDeep } from 'lodash'; -import { cliux } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath } from '@contentstack/cli-utilities'; import { GlobalFieldData } from '@contentstack/management/types/stack/globalField'; import { fsUtil, log, formatError, fileHelper, lookupExtension, removeReferenceFields } from '../../utils'; import { ImportConfig, ModuleClassParams } from '../../types'; @@ -50,13 +50,13 @@ export default class ImportGlobalFields extends BaseClass { this.pendingGFs = []; this.existingGFs = []; this.reqConcurrency = this.gFsConfig.writeConcurrency || this.config.writeConcurrency; - this.gFsMapperPath = path.resolve(this.config.data, 'mapper', 'global_fields'); - this.gFsFolderPath = path.resolve(this.config.data, this.gFsConfig.dirName); - this.gFsFailsPath = path.resolve(this.config.data, 'mapper', 'global_fields', 'fails.json'); - this.gFsSuccessPath = path.resolve(this.config.data, 'mapper', 'global_fields', 'success.json'); - this.gFsUidMapperPath = path.resolve(this.config.data, 'mapper', 'global_fields', 'uid-mapping.json'); - this.gFsPendingPath = path.resolve(this.config.data, 'mapper', 'global_fields', 'pending_global_fields.js'); - this.marketplaceAppMapperPath = path.join(this.config.data, 'mapper', 'marketplace_apps', 'uid-mapping.json'); + this.gFsMapperPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'global_fields'); + this.gFsFolderPath = path.resolve(sanitizePath(this.config.data), sanitizePath(this.gFsConfig.dirName)); + this.gFsFailsPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'global_fields', 'fails.json'); + this.gFsSuccessPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'global_fields', 'success.json'); + this.gFsUidMapperPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'global_fields', 'uid-mapping.json'); + this.gFsPendingPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'global_fields', 'pending_global_fields.js'); + this.marketplaceAppMapperPath = path.join(sanitizePath(this.config.data), 'mapper', 'marketplace_apps', 'uid-mapping.json'); } async start(): Promise { diff --git a/packages/contentstack-import/src/import/modules/locales.ts b/packages/contentstack-import/src/import/modules/locales.ts index 5c417d8256..789471132c 100644 --- a/packages/contentstack-import/src/import/modules/locales.ts +++ b/packages/contentstack-import/src/import/modules/locales.ts @@ -1,13 +1,13 @@ /* eslint-disable no-prototype-builtins */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ import * as path from 'path'; import { values, isEmpty, filter, pick } from 'lodash'; -import { cliux } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath } from '@contentstack/cli-utilities'; import { fsUtil, log, formatError, fileHelper } from '../../utils'; import { ImportConfig, ModuleClassParams } from '../../types'; import BaseClass from './base-class'; @@ -49,11 +49,11 @@ export default class ImportLocales extends BaseClass { this.createdLocales = []; this.failedLocales = []; this.reqConcurrency = this.localeConfig.writeConcurrency || this.config.writeConcurrency; - this.langMapperPath = path.resolve(this.config.data, 'mapper', 'languages'); - this.langFolderPath = path.resolve(this.config.data, this.localeConfig.dirName); - this.langFailsPath = path.resolve(this.config.data, 'mapper', 'languages', 'fails.json'); - this.langSuccessPath = path.resolve(this.config.data, 'mapper', 'languages', 'success.json'); - this.langUidMapperPath = path.resolve(this.config.data, 'mapper', 'languages', 'uid-mapper.json'); + this.langMapperPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'languages'); + this.langFolderPath = path.resolve(sanitizePath(this.config.data), sanitizePath(this.localeConfig.dirName)); + this.langFailsPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'languages', 'fails.json'); + this.langSuccessPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'languages', 'success.json'); + this.langUidMapperPath = path.resolve(sanitizePath(this.config.data), 'mapper', 'languages', 'uid-mapper.json'); } async start(): Promise { diff --git a/packages/contentstack-import/src/utils/asset-helper.ts b/packages/contentstack-import/src/utils/asset-helper.ts index 48bf419a5f..924028243e 100644 --- a/packages/contentstack-import/src/utils/asset-helper.ts +++ b/packages/contentstack-import/src/utils/asset-helper.ts @@ -1,7 +1,7 @@ import Bluebird from 'bluebird'; import * as url from 'url'; import * as path from 'path'; -import { ContentstackClient, managementSDKClient } from '@contentstack/cli-utilities'; +import { ContentstackClient, managementSDKClient, validateRegex } from '@contentstack/cli-utilities'; import { ImportConfig } from '../types'; const debug = require('debug')('util:requests'); let _ = require('lodash'); @@ -266,8 +266,12 @@ export const lookupAssets = function ( let uid = mappedAssetUids[assetUid]; if (typeof uid !== 'undefined') { const escapedAssetUid = assetUid.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - entry = entry.replace(new RegExp(escapedAssetUid, 'img'), uid); - matchedUids.push(assetUid); + const regex = new RegExp(`\\b${escapedAssetUid}\\b`, 'img'); + let { status } = validateRegex(new RegExp(regex, 'img')) + if (status === 'safe') { + entry = entry.replace(regex, uid); + matchedUids.push(assetUid); + } } else { unmatchedUids.push(assetUid); } diff --git a/packages/contentstack-import/src/utils/backup-handler.ts b/packages/contentstack-import/src/utils/backup-handler.ts index 15eda75004..ae8afc8782 100755 --- a/packages/contentstack-import/src/utils/backup-handler.ts +++ b/packages/contentstack-import/src/utils/backup-handler.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { copy } from 'fs-extra'; -import { cliux } from '@contentstack/cli-utilities'; +import { cliux, sanitizePath } from '@contentstack/cli-utilities'; import { fileHelper, trace } from './index'; import { ImportConfig } from '../types'; @@ -14,7 +14,7 @@ export default async function backupHandler(importConfig: ImportConfig): Promise const subDir = isSubDirectory(importConfig); if (subDir) { - backupDirPath = path.resolve(importConfig.contentDir, '..', '_backup_' + Math.floor(Math.random() * 1000)); + backupDirPath = path.resolve(sanitizePath(importConfig.contentDir), '..', '_backup_' + Math.floor(Math.random() * 1000)); if (importConfig.createBackupDir) { cliux.print( `Warning!!! Provided backup directory path is a sub directory of the content directory, Cannot copy to a sub directory. Hence new backup directory created - ${backupDirPath}`, diff --git a/packages/contentstack-import/src/utils/common-helper.ts b/packages/contentstack-import/src/utils/common-helper.ts index ed402fcf42..bee4d6981b 100644 --- a/packages/contentstack-import/src/utils/common-helper.ts +++ b/packages/contentstack-import/src/utils/common-helper.ts @@ -1,13 +1,13 @@ /* eslint-disable no-console */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ import * as _ from 'lodash'; import * as path from 'path'; -import { HttpClient, managementSDKClient, isAuthenticated } from '@contentstack/cli-utilities'; +import { HttpClient, managementSDKClient, isAuthenticated, sanitizePath } from '@contentstack/cli-utilities'; import { readFileSync, readdirSync, readFile } from './file-helper'; import chalk from 'chalk'; import { log } from './logger'; @@ -65,9 +65,9 @@ export const sanitizeStack = (importConfig: ImportConfig) => { const newStackVersion = stackDetails.data.stack.settings.version; const newStackDate = new Date(newStackVersion).toString(); const stackFilePath = path.join( - importConfig.data, - importConfig.modules.stack.dirName, - importConfig.modules.stack.fileName, + sanitizePath(importConfig.data), + sanitizePath(importConfig.modules.stack.dirName), + sanitizePath(importConfig.modules.stack.fileName), ); const oldStackDetails = readFileSync(stackFilePath); @@ -184,7 +184,7 @@ export const formatError = (error: any) => { } else { error = JSON.parse(error.message); } - } catch (e) {} + } catch (e) { } let message = error?.errorMessage || error?.error_message || error?.message || error; if (error && error.errors && Object.keys(error.errors).length > 0) { Object.keys(error.errors).forEach((e) => { @@ -244,12 +244,12 @@ export const formatDate = (date: Date = new Date()) => { .getDate() .toString() .padStart(2, '0')}T${date.getHours().toString().padStart(2, '0')}-${date - .getMinutes() - .toString() - .padStart(2, '0')}-${date.getSeconds().toString().padStart(2, '0')}-${date - .getMilliseconds() - .toString() - .padStart(3, '0')}Z`; + .getMinutes() + .toString() + .padStart(2, '0')}-${date.getSeconds().toString().padStart(2, '0')}-${date + .getMilliseconds() + .toString() + .padStart(3, '0')}Z`; return formattedDate; }; diff --git a/packages/contentstack-import/src/utils/content-type-helper.ts b/packages/contentstack-import/src/utils/content-type-helper.ts index d096392229..3e3b30ef35 100644 --- a/packages/contentstack-import/src/utils/content-type-helper.ts +++ b/packages/contentstack-import/src/utils/content-type-helper.ts @@ -46,7 +46,7 @@ export const schemaTemplate = { /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-import/src/utils/entries-helper.ts b/packages/contentstack-import/src/utils/entries-helper.ts index 1cf6e84581..206afa4c5f 100644 --- a/packages/contentstack-import/src/utils/entries-helper.ts +++ b/packages/contentstack-import/src/utils/entries-helper.ts @@ -7,7 +7,7 @@ import * as path from 'path'; import * as _ from 'lodash'; import config from '../config'; import * as fileHelper from './file-helper'; -import { escapeRegExp } from '@contentstack/cli-utilities'; +import { escapeRegExp, validateRegex } from '@contentstack/cli-utilities'; import { EntryJsonRTEFieldDataType } from '../types/entries'; @@ -87,14 +87,17 @@ export const lookupEntries = function ( uids.push(_entry[_parent[j]].uid); } } else { - _entry = _entry[_parent[j]]; - let _keys = _.clone(_parent).splice(j + 1, len); - if (Array.isArray(_entry)) { - for (let i = 0, _i = _entry?.length; i < _i; i++) { - update(_keys, form_id, _entry[i]); + const key = _parent[j]; + if (Object.prototype.hasOwnProperty.call(_entry, key)) { + _entry = _entry[key]; + let _keys = _.clone(_parent).splice(j + 1, len); + if (Array.isArray(_entry)) { + for (let i = 0, _i = _entry?.length; i < _i; i++) { + update(_keys, form_id, _entry[i]); + } + } else if (!(_entry instanceof Object)) { + break; } - } else if (!(_entry instanceof Object)) { - break; } } } @@ -202,8 +205,12 @@ export const lookupEntries = function ( if (mappedUids.hasOwnProperty(uid)) { const sanitizedUid = escapeRegExp(uid); const escapedMappedUid = escapeRegExp(mappedUids[uid]); - entry = entry.replace(new RegExp(sanitizedUid, 'img'), escapedMappedUid); - mapped.push(uid); + const uidRegex = new RegExp(`\\b${sanitizedUid}\\b`, 'img'); + let { status } = validateRegex(uidRegex); + if (status === 'safe') { + entry = entry.replace(uidRegex, escapedMappedUid); + mapped.push(uid); + } } else { unmapped.push(uid); } @@ -572,7 +579,11 @@ export const restoreJsonRteEntryRefs = ( }; function updateUids(str: string, match: string, uidMapper: Record) { - return str.replace(new RegExp(match, 'g'), (match: string) => uidMapper[match]); + const sanitizedMatch = escapeRegExp(match); + const regex = new RegExp(`\\b${sanitizedMatch}\\b`, 'g'); + let { status } = validateRegex(regex); + if (status === 'safe') + return str.replace(regex, (matchedString) => uidMapper[matchedString]); } function setDirtyTrue(jsonRteChild: any) { diff --git a/packages/contentstack-import/src/utils/extension-helper.ts b/packages/contentstack-import/src/utils/extension-helper.ts index 976d1b326a..073fcc1551 100644 --- a/packages/contentstack-import/src/utils/extension-helper.ts +++ b/packages/contentstack-import/src/utils/extension-helper.ts @@ -4,7 +4,7 @@ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ import { join } from 'node:path'; diff --git a/packages/contentstack-import/src/utils/file-helper.ts b/packages/contentstack-import/src/utils/file-helper.ts index a8446e93cb..e5c613b90d 100644 --- a/packages/contentstack-import/src/utils/file-helper.ts +++ b/packages/contentstack-import/src/utils/file-helper.ts @@ -2,11 +2,11 @@ import * as fs from 'fs'; import * as path from 'path'; import mkdirp from 'mkdirp'; import * as bigJSON from 'big-json'; -import { FsUtility } from '@contentstack/cli-utilities'; +import { FsUtility, sanitizePath } from '@contentstack/cli-utilities'; export const readFileSync = function (filePath: string, parse: boolean = true): any { let data; - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); if (fs.existsSync(filePath)) { try { data = parse ? JSON.parse(fs.readFileSync(filePath, 'utf-8')) : data; @@ -20,7 +20,7 @@ export const readFileSync = function (filePath: string, parse: boolean = true): // by default file type is json export const readFile = async (filePath: string, options = { type: 'json' }): Promise => { return new Promise((resolve, reject) => { - filePath = path.resolve(filePath); + filePath = path.resolve(sanitizePath(filePath)); fs.readFile(filePath, 'utf-8', (error, data) => { if (error) { if (error.code === 'ENOENT') { @@ -41,7 +41,7 @@ export const readLargeFile = function (filePath: string, opts?: any): Promise { const readStream = fs.createReadStream(filePath, { encoding: 'utf-8' }); @@ -82,7 +82,7 @@ export const writeLargeFile = function (filePath: string, data: any): Promise { const stringifyStream = bigJSON.createStringifyStream({ body: data, @@ -117,7 +117,7 @@ export const readdirSync = function (dirPath: string): any { export const isFolderExist = async (folderPath: string): Promise => { return new Promise((resolve, reject) => { - folderPath = path.resolve(folderPath); + folderPath = path.resolve(sanitizePath(folderPath)); fs.access(folderPath, (error) => { if (error) { return resolve(false); diff --git a/packages/contentstack-import/src/utils/import-config-handler.ts b/packages/contentstack-import/src/utils/import-config-handler.ts index 546bfd8a18..48ee0231ba 100644 --- a/packages/contentstack-import/src/utils/import-config-handler.ts +++ b/packages/contentstack-import/src/utils/import-config-handler.ts @@ -1,7 +1,7 @@ import merge from 'merge'; import * as path from 'path'; import { omit, filter, includes, isArray } from 'lodash'; -import { configHandler, isAuthenticated, cliux } from '@contentstack/cli-utilities'; +import { configHandler, isAuthenticated, cliux, sanitizePath } from '@contentstack/cli-utilities'; import defaultConfig from '../config'; import { readFile, fileExistsSync } from './file-helper'; import { askContentDir, askAPIKey } from './interactive'; @@ -81,7 +81,7 @@ const setupConfig = async (importCmdFlags: any): Promise => { if (importCmdFlags['branch']) { config.branchName = importCmdFlags['branch']; - config.branchDir = path.join(config.contentDir, config.branchName); + config.branchDir = path.join(sanitizePath(config.contentDir), sanitizePath (config.branchName)); } if (importCmdFlags['module']) { config.moduleName = importCmdFlags['module']; diff --git a/packages/contentstack-import/src/utils/log.ts b/packages/contentstack-import/src/utils/log.ts index 7c3923a3f8..aac6d63457 100644 --- a/packages/contentstack-import/src/utils/log.ts +++ b/packages/contentstack-import/src/utils/log.ts @@ -1,6 +1,6 @@ import { join } from 'path'; import { LogEntry } from 'winston/index'; -import { Logger, pathValidator } from '@contentstack/cli-utilities'; +import { Logger, pathValidator, sanitizePath } from '@contentstack/cli-utilities'; import { LogsType, MessageType } from '@contentstack/cli-utilities/lib/logger'; import { ImportConfig } from '../types'; @@ -26,7 +26,7 @@ export function log(entryOrMessage: MessageType, logType?: LogsType, hidden?: bo export function initLogger(config?: ImportConfig | undefined) { if (!logger) { - const basePath = pathValidator(join(config?.cliLogsPath ?? process.cwd(), 'logs', 'import')); + const basePath = pathValidator(join(sanitizePath(config?.cliLogsPath ?? process.cwd()), 'logs', 'import')); logger = new Logger(Object.assign(config ?? {}, { basePath })); } diff --git a/packages/contentstack-import/src/utils/logger.ts b/packages/contentstack-import/src/utils/logger.ts index d3542c11a1..782e07c2c3 100644 --- a/packages/contentstack-import/src/utils/logger.ts +++ b/packages/contentstack-import/src/utils/logger.ts @@ -1,6 +1,6 @@ /*! * Contentstack Export - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ @@ -8,6 +8,7 @@ import * as winston from 'winston'; import * as path from 'path'; import mkdirp from 'mkdirp'; import { ImportConfig } from '../types'; +import { sanitizePath } from '@contentstack/cli-utilities'; const slice = Array.prototype.slice; @@ -58,9 +59,9 @@ let errorTransport; function init(_logPath: string) { if (!logger || !errorLogger) { - const logsDir = path.resolve(_logPath, 'logs', 'import'); + const logsDir = path.resolve(sanitizePath(_logPath), 'logs', 'import'); successTransport = { - filename: path.join(logsDir, 'success.log'), + filename: path.join(sanitizePath(logsDir), 'success.log'), maxFiles: 20, maxsize: 1000000, tailable: true, @@ -68,7 +69,7 @@ function init(_logPath: string) { }; errorTransport = { - filename: path.join(logsDir, 'error.log'), + filename: path.join(sanitizePath(logsDir), 'error.log'), maxFiles: 20, maxsize: 1000000, tailable: true, diff --git a/packages/contentstack-import/src/utils/login-handler.ts b/packages/contentstack-import/src/utils/login-handler.ts index e908417619..996e7797a8 100644 --- a/packages/contentstack-import/src/utils/login-handler.ts +++ b/packages/contentstack-import/src/utils/login-handler.ts @@ -3,7 +3,7 @@ /* eslint-disable no-empty */ /*! * Contentstack Import - * Copyright (c) 2019 Contentstack LLC + * Copyright (c) 2024 Contentstack LLC * MIT Licensed */ diff --git a/packages/contentstack-launch/package.json b/packages/contentstack-launch/package.json index 86bb7515b5..48cf5261a2 100755 --- a/packages/contentstack-launch/package.json +++ b/packages/contentstack-launch/package.json @@ -19,7 +19,7 @@ "dependencies": { "@apollo/client": "^3.7.9", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", diff --git a/packages/contentstack-migrate-rte/package.json b/packages/contentstack-migrate-rte/package.json index ec89c5665d..4dbe13a682 100644 --- a/packages/contentstack-migrate-rte/package.json +++ b/packages/contentstack-migrate-rte/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/json-rte-serializer": "~2.0.4", "collapse-whitespace": "^1.1.7", "chalk": "^4.1.2", diff --git a/packages/contentstack-migration/README.md b/packages/contentstack-migration/README.md index d84a0a1325..4178a77674 100644 --- a/packages/contentstack-migration/README.md +++ b/packages/contentstack-migration/README.md @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-migration/1.5.5 darwin-arm64 node-v21.6.2 +@contentstack/cli-migration/1.5.6 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js index 33d9c25229..d02ddc2d68 100644 --- a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js +++ b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js @@ -1,6 +1,8 @@ const fs = require('fs'); const chalk = require('chalk'); const path = require('path'); +const { validateRegex } = require('@contentstack/cli-utilities'); + module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config }) => { const modules = ['entries', 'assets', 'extensions', 'marketplace_apps']; @@ -8,14 +10,14 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf let uidMapping = {}; modules.forEach((module) => { - const mappingFilePath = path.join(filePath, 'mapper', module, 'uid-mapping.json'); + const mappingFilePath = path.join(sanitizePath(filePath), 'mapper', sanitizePath(module), 'uid-mapping.json'); if (fs.existsSync(mappingFilePath)) { - const mappedIds = JSON.parse(fs.readFileSync(mappingFilePath, 'utf-8')); + const mappedIds = JSON.parse(fs.readFileSync(sanitizePath(mappingFilePath), 'utf-8')); if (module === 'marketplace_apps') { Object.values(mappedIds).forEach((ids) => Object.assign(uidMapping, ids)); } else { - Object.assign(uidMapping, mappedIds); + Object.assign(uidMapping, sanitizeObject(mappedIds)); } } }); @@ -23,6 +25,16 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf return uidMapping; }; + const sanitizeObject = (obj) => { + const sanitized = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + sanitized[key] = obj[key]; + } + } + return sanitized; + } + const getEntries = async (ct) => { try { let entries = []; @@ -62,9 +74,12 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf matches.forEach((m) => { if (oldUids.includes(m)) { let regex = new RegExp(m, 'g'); - stringifiedEntry = stringifiedEntry.replace(regex, uidMapping[m]); - console.log(chalk.green(`Replacing the UID '${m}' with '${uidMapping[m]}'...`)); - isUpdated = true; + let { status } = validateRegex(regex); + if (status === 'safe') { + stringifiedEntry = stringifiedEntry.replace(regex, uidMapping[m]); + console.log(chalk.green(`Replacing the UID '${m}' with '${uidMapping[m]}'...`)); + isUpdated = true; + } } }); return { stringifiedEntry, isUpdated }; diff --git a/packages/contentstack-migration/examples/change-master-locale/01-change-master-locale.js b/packages/contentstack-migration/examples/change-master-locale/01-change-master-locale.js index 56adb1458b..48652ba10d 100644 --- a/packages/contentstack-migration/examples/change-master-locale/01-change-master-locale.js +++ b/packages/contentstack-migration/examples/change-master-locale/01-change-master-locale.js @@ -2,7 +2,7 @@ let fs = require('fs').promises; let path = require('path') let crypto = require('crypto') let supportedLocales = require('./locales.json') -const { pathValidator } = require('@contentstack/cli-utilities') +const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities') module.exports = async ({migration, config}) => { let changeMasterLocale = { @@ -51,10 +51,10 @@ module.exports = async ({migration, config}) => { let contentTypes = await fs.readdir(pathValidator(path.resolve(config.data_dir, 'entries'))) let sourceMasterLocaleEntries, targetMasterLocaleEntries for (let contentType of contentTypes) { - sourceMasterLocaleEntries = await fs.readFile(pathValidator(path.resolve(config.data_dir, `entries/${contentType}/${masterLocale}.json`)), {encoding: 'utf8'}) + sourceMasterLocaleEntries = await fs.readFile(pathValidator(path.resolve(sanitizePath(config.data_dir), `entries/${sanitizePath(contentType)}/${sanitizePath(masterLocale)}.json`)), {encoding: 'utf8'}) sourceMasterLocaleEntries = JSON.parse(sourceMasterLocaleEntries) - targetMasterLocaleEntries = await fs.readFile(pathValidator(path.resolve(config.data_dir, `entries/${contentType}/${config.target_locale}.json`)), { encoding: 'utf8', flag: 'a+'}) + targetMasterLocaleEntries = await fs.readFile(pathValidator(path.resolve(sanitizePath(config.data_dir), `entries/${sanitizePath(contentType)}/${sanitizePath(config.target_locale)}.json`)), { encoding: 'utf8', flag: 'a+'}) if (targetMasterLocaleEntries.length === 0) { targetMasterLocaleEntries = {} } else { diff --git a/packages/contentstack-migration/examples/change-master-locale/02-change-master-locale-new-file-structure.js b/packages/contentstack-migration/examples/change-master-locale/02-change-master-locale-new-file-structure.js index 475e1643c7..e4ca3f6550 100644 --- a/packages/contentstack-migration/examples/change-master-locale/02-change-master-locale-new-file-structure.js +++ b/packages/contentstack-migration/examples/change-master-locale/02-change-master-locale-new-file-structure.js @@ -3,7 +3,7 @@ let { existsSync } = require('fs'); let path = require('path'); let crypto = require('crypto'); let supportedLocales = require('./locales.json'); -const { pathValidator, FsUtility } = require('@contentstack/cli-utilities'); +const { pathValidator, FsUtility, sanitizePath } = require('@contentstack/cli-utilities'); module.exports = async ({ migration, config }) => { let changeMasterLocale = { @@ -18,9 +18,9 @@ module.exports = async ({ migration, config }) => { } async function tailorData() { - let locales = await fs.readFile(pathValidator(path.resolve(config.data_dir, 'locales/locales.json')), 'utf-8'); + let locales = await fs.readFile(pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/locales.json')), 'utf-8'); let masterLocale = await fs.readFile( - pathValidator(path.resolve(config.data_dir, 'locales/master-locale.json')), + pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/master-locale.json')), 'utf-8', ); @@ -49,7 +49,7 @@ module.exports = async ({ migration, config }) => { await handleEntries(masterLocale); await fs.writeFile( - pathValidator(path.resolve(config.data_dir, 'locales/locales.json')), + pathValidator(path.resolve(sanitizePath(config.data_dir), 'locales/locales.json')), JSON.stringify(locales), ); masterLocale = await fs.readFile( @@ -67,20 +67,20 @@ module.exports = async ({ migration, config }) => { } async function handleEntries(masterLocale) { - let contentTypes = await fs.readdir(pathValidator(path.resolve(config.data_dir, 'entries'))); + let contentTypes = await fs.readdir(pathValidator(path.resolve(sanitizePath(config.data_dir), 'entries'))); for (let contentType of contentTypes) { let sourceMasterLocaleEntries, targetMasterLocaleEntries; sourceMasterLocaleEntries = await fs.readFile( - pathValidator(path.resolve(config.data_dir, `entries/${contentType}/${masterLocale}/index.json`)), + pathValidator(path.resolve(sanitizePath(config.data_dir), sanitizePath(`entries/${contentType}/${masterLocale}/index.json`))), { encoding: 'utf8' }, ); sourceMasterLocaleEntries = await fs.readFile( pathValidator( path.resolve( - config.data_dir, - `entries/${contentType}/${masterLocale}/${Object.values(JSON.parse(sourceMasterLocaleEntries))}`, + sanitizePath(config.data_dir), + `entries/${sanitizePath(contentType)}/${sanitizePath(masterLocale)}/${Object.values(JSON.parse(sanitizePath(sourceMasterLocaleEntries)))}`, ), ), { encoding: 'utf8' }, diff --git a/packages/contentstack-migration/package.json b/packages/contentstack-migration/package.json index adf38e3bae..c3ad965971 100644 --- a/packages/contentstack-migration/package.json +++ b/packages/contentstack-migration/package.json @@ -1,11 +1,11 @@ { "name": "@contentstack/cli-migration", - "version": "1.5.5", + "version": "1.5.6", "author": "@contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", "callsites": "^3.1.0", "cardinal": "^2.1.1", diff --git a/packages/contentstack-migration/src/commands/cm/stacks/migration.js b/packages/contentstack-migration/src/commands/cm/stacks/migration.js index cf591102bb..23b2c46257 100644 --- a/packages/contentstack-migration/src/commands/cm/stacks/migration.js +++ b/packages/contentstack-migration/src/commands/cm/stacks/migration.js @@ -19,6 +19,7 @@ const { flags, isAuthenticated, pathValidator, + sanitizePath, } = require('@contentstack/cli-utilities'); const { ApiError, SchemaValidator, MigrationError, FieldValidator } = require('../../../validators'); @@ -180,7 +181,7 @@ class MigrationCommand extends Command { const file = element; if (extname(file) === '.js') { // eslint-disable-next-line no-await-in-loop - await this.execSingleFile(pathValidator(resolve(filePath, file)), mapInstance); + await this.execSingleFile(pathValidator(resolve(sanitizePath(filePath), sanitizePath(file))), mapInstance); } } } catch (error) { diff --git a/packages/contentstack-migration/src/utils/callsite.js b/packages/contentstack-migration/src/utils/callsite.js index f4d0d82d09..2fc036841a 100644 --- a/packages/contentstack-migration/src/utils/callsite.js +++ b/packages/contentstack-migration/src/utils/callsite.js @@ -2,10 +2,10 @@ const getCallsites = require('callsites'); const { parse, resolve } = require('path'); -const { pathValidator } = require('@contentstack/cli-utilities'); +const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities'); function getFileDirectory(path) { - const parentPath = pathValidator(resolve(path, '../')); // Assuming that will be 2 folders up + const parentPath = pathValidator(resolve(sanitizePath(path), '../')); // Assuming that will be 2 folders up return parse(parentPath).dir; } diff --git a/packages/contentstack-migration/src/utils/logger.js b/packages/contentstack-migration/src/utils/logger.js index d6f96953c1..3f875049e6 100644 --- a/packages/contentstack-migration/src/utils/logger.js +++ b/packages/contentstack-migration/src/utils/logger.js @@ -4,7 +4,7 @@ const { createLogger, format, transports } = require('winston'); const { resolve, join } = require('path'); const { slice } = Array.prototype; const { stringify } = JSON; -const { pathValidator } = require('@contentstack/cli-utilities'); +const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities'); const { combine, label, printf, colorize } = format; @@ -33,7 +33,7 @@ function init(logFileName) { // Create dir if does not exist makeDir(logsDir); - const logPath = pathValidator(join(logsDir, logFileName + '.log')); + const logPath = pathValidator(join(sanitizePath(logsDir), sanitizePath(logFileName) + '.log')); const logger = createLogger({ format: combine(colorize(), label({ label: 'Migration' }), customFormat), transports: [new transports.File({ filename: logPath })], diff --git a/packages/contentstack-migration/src/utils/migration-logger.js b/packages/contentstack-migration/src/utils/migration-logger.js index 0417f1e637..59fa0fb939 100644 --- a/packages/contentstack-migration/src/utils/migration-logger.js +++ b/packages/contentstack-migration/src/utils/migration-logger.js @@ -1,14 +1,15 @@ const winston = require('winston'); const path = require('path'); +const { sanitizePath } = require('@contentstack/cli-utilities'); module.exports = class MigrationLogger { constructor(filePath) { - this.filePath = path.join(filePath, 'migration-logs'); + this.filePath = path.join(sanitizePath(filePath), 'migration-logs'); this.logger = winston.createLogger({ levels: { error: 1 }, transports: [ new winston.transports.File({ level: 'error', - filename: path.join(this.filePath, 'error.logs'), + filename: path.join(sanitizePath(this.filePath), 'error.logs'), format: winston.format.combine(winston.format.timestamp(), winston.format.json()), }), ], diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index f23f387402..b7fc7bec8d 100644 --- a/packages/contentstack-seed/package.json +++ b/packages/contentstack-seed/package.json @@ -1,13 +1,13 @@ { "name": "@contentstack/cli-cm-seed", "description": "create a Stack from existing content types, entries, assets, etc.", - "version": "1.7.4", + "version": "1.7.5", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.1.13", diff --git a/packages/contentstack-seed/src/seed/importer.ts b/packages/contentstack-seed/src/seed/importer.ts index a12d731834..ddeece2f49 100644 --- a/packages/contentstack-seed/src/seed/importer.ts +++ b/packages/contentstack-seed/src/seed/importer.ts @@ -1,7 +1,7 @@ import * as process from 'process'; import * as path from 'path'; import ImportCommand from '@contentstack/cli-cm-import'; -import { pathValidator } from '@contentstack/cli-utilities'; +import { pathValidator, sanitizePath } from '@contentstack/cli-utilities'; const STACK_FOLDER = 'stack'; @@ -16,7 +16,7 @@ export interface ImporterOptions { } export async function run(options: ImporterOptions) { - const importPath = pathValidator(path.resolve(options.tmpPath, STACK_FOLDER)); + const importPath = pathValidator(path.resolve(sanitizePath(options.tmpPath), STACK_FOLDER)); const args = options.alias ? ['-k', options.api_key, '-d', importPath, '--alias', options.alias!] diff --git a/packages/contentstack-utilities/package.json b/packages/contentstack-utilities/package.json index 90943b2623..687731af98 100644 --- a/packages/contentstack-utilities/package.json +++ b/packages/contentstack-utilities/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-utilities", - "version": "1.6.1", + "version": "1.6.2", "description": "Utilities for contentstack projects", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -55,7 +55,8 @@ "unique-string": "^2.0.0", "uuid": "^9.0.0", "winston": "^3.7.2", - "xdg-basedir": "^4.0.0" + "xdg-basedir": "^4.0.0", + "recheck": "^4.4.5" }, "devDependencies": { "@contentstack/cli-dev-dependencies": "^1.2.4", diff --git a/packages/contentstack-utilities/src/helpers.ts b/packages/contentstack-utilities/src/helpers.ts index 144770fe9a..4fe9289138 100644 --- a/packages/contentstack-utilities/src/helpers.ts +++ b/packages/contentstack-utilities/src/helpers.ts @@ -1,3 +1,4 @@ +import { checkSync } from "recheck"; import authHandler from './auth-handler'; import { HttpClient, cliux, configHandler } from '.'; export const isAuthenticated = () => authHandler.isAuthenticated(); @@ -16,13 +17,13 @@ export const isManagementTokenValid = async (stackAPIKey, managementToken) => { const response = (await httpClient.get(`${configHandler.get('region').cma}/v3/environments?limit=1`))?.data; if (response?.environments) { return { valid: true } - } else if(response?.error_code) { + } else if (response?.error_code) { return { valid: false, message: response.error_message }; } else { - throw typeof response === "string"? response : ""; + throw typeof response === "string" ? response : ""; } } catch (error) { - return { valid: 'failedToCheck',message:`Failed to check the validity of the Management token. ${error}`}; + return { valid: 'failedToCheck', message: `Failed to check the validity of the Management token. ${error}` }; } } @@ -53,3 +54,15 @@ export const validatePath = (input: string) => { // To escape special characters in a string export const escapeRegExp = (str: string) => str?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + +// To remove the relative path +export const sanitizePath = (str: string) => str?.replace(/^(\.\.(\/|\\|$))+/, ''); + +// To validate the UIDs of assets +export const validateUids = (uid) => /^[a-zA-Z0-9]+$/.test(uid); + +// Validate File name +export const validateFileName = (fileName) => /^[a-zA-Z0-9-_\.]+$/.test(fileName); + +// Validate Regex for ReDDos +export const validateRegex = (str) => checkSync(str, ""); \ No newline at end of file diff --git a/packages/contentstack-utilities/src/logger.ts b/packages/contentstack-utilities/src/logger.ts index e457e22395..a5eba73772 100644 --- a/packages/contentstack-utilities/src/logger.ts +++ b/packages/contentstack-utilities/src/logger.ts @@ -3,7 +3,7 @@ import { klona } from 'klona/full'; import path, { normalize } from 'path'; import winston, { LogEntry } from 'winston'; -import { cliux as ux, PrintOptions, messageHandler } from './index'; +import { cliux as ux, PrintOptions, messageHandler, sanitizePath } from './index'; export class LoggerService { name: string; @@ -19,7 +19,7 @@ export class LoggerService { const logger = winston.createLogger({ transports: [ new winston.transports.File({ - filename: path.resolve(process.env.CS_CLI_LOG_PATH || `${pathToLog}/logs`, `${name}.log`), + filename: path.resolve(sanitizePath(process.env.CS_CLI_LOG_PATH) || `${sanitizePath(pathToLog)}/logs`, `${sanitizePath(name)}.log`), }), ], format: winston.format.combine( diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 22992dcfcb..5708bb2fa4 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.18.1 darwin-arm64 node-v21.6.2 +@contentstack/cli/1.18.2 darwin-arm64 node-v21.6.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 5d17343d5e..e0219c520e 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli", "description": "Command-line tool (CLI) to interact with Contentstack", - "version": "1.18.1", + "version": "1.18.2", "author": "Contentstack", "bin": { "csdx": "./bin/run.js" @@ -22,22 +22,22 @@ "prepack": "pnpm compile && oclif manifest && oclif readme" }, "dependencies": { - "@contentstack/cli-audit": "~1.6.1", + "@contentstack/cli-audit": "~1.6.2", "@contentstack/cli-auth": "~1.3.18", - "@contentstack/cli-cm-bootstrap": "~1.9.2", - "@contentstack/cli-cm-branches": "~1.0.25", - "@contentstack/cli-cm-bulk-publish": "~1.4.6", - "@contentstack/cli-cm-export": "~1.11.3", - "@contentstack/cli-cm-clone": "~1.10.4", + "@contentstack/cli-cm-bootstrap": "~1.9.3", + "@contentstack/cli-cm-branches": "~1.0.26", + "@contentstack/cli-cm-bulk-publish": "~1.4.7", + "@contentstack/cli-cm-export": "~1.11.4", + "@contentstack/cli-cm-clone": "~1.10.5", "@contentstack/cli-cm-export-to-csv": "~1.7.1", - "@contentstack/cli-cm-import": "~1.15.5", + "@contentstack/cli-cm-import": "~1.15.6", "@contentstack/cli-cm-migrate-rte": "~1.4.17", - "@contentstack/cli-cm-seed": "~1.7.4", + "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-launch": "~1.0.18", - "@contentstack/cli-migration": "~1.5.5", - "@contentstack/cli-utilities": "~1.6.1", + "@contentstack/cli-migration": "~1.5.6", + "@contentstack/cli-utilities": "~1.6.2", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", diff --git a/packages/contentstack/src/utils/context-handler.ts b/packages/contentstack/src/utils/context-handler.ts index 6632c9a6a7..7319aae80c 100644 --- a/packages/contentstack/src/utils/context-handler.ts +++ b/packages/contentstack/src/utils/context-handler.ts @@ -1,6 +1,6 @@ import * as shortUUID from 'short-uuid'; import * as path from 'path'; -import { configHandler, pathValidator } from '@contentstack/cli-utilities'; +import { configHandler, pathValidator, sanitizePath } from '@contentstack/cli-utilities'; import { machineIdSync } from 'node-machine-id'; export default class CsdxContext { @@ -48,7 +48,7 @@ export default class CsdxContext { this.plugin.name = command.pluginName; this.plugin.config = { ...((this.plugin.pjson && this.plugin.pjson.csdxConfig) || {}) }; this.messageFilePath = pathValidator( - path.resolve(this.plugin.root, this.plugin.config.messageFilePath || './messages/index.json'), + path.resolve(sanitizePath(this.plugin.root), sanitizePath(this.plugin.config.messageFilePath) || './messages/index.json'), ); this.info.shortCommandName = this.plugin?.config?.shortCommandName?.[cliOpts.id]; analyticsInfo.push(this.info.shortCommandName || cliOpts.id); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index efd80ea9ae..5ccb0eef76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,22 +10,22 @@ importers: packages/contentstack: specifiers: - '@contentstack/cli-audit': ~1.6.1 + '@contentstack/cli-audit': ~1.6.2 '@contentstack/cli-auth': ~1.3.18 - '@contentstack/cli-cm-bootstrap': ~1.9.2 - '@contentstack/cli-cm-branches': ~1.0.25 - '@contentstack/cli-cm-bulk-publish': ~1.4.6 - '@contentstack/cli-cm-clone': ~1.10.4 - '@contentstack/cli-cm-export': ~1.11.3 + '@contentstack/cli-cm-bootstrap': ~1.9.3 + '@contentstack/cli-cm-branches': ~1.0.26 + '@contentstack/cli-cm-bulk-publish': ~1.4.7 + '@contentstack/cli-cm-clone': ~1.10.5 + '@contentstack/cli-cm-export': ~1.11.4 '@contentstack/cli-cm-export-to-csv': ~1.7.1 - '@contentstack/cli-cm-import': ~1.15.5 + '@contentstack/cli-cm-import': ~1.15.6 '@contentstack/cli-cm-migrate-rte': ~1.4.17 - '@contentstack/cli-cm-seed': ~1.7.4 + '@contentstack/cli-cm-seed': ~1.7.5 '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-config': ~1.6.4 '@contentstack/cli-launch': ~1.0.18 - '@contentstack/cli-migration': ~1.5.5 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-migration': ~1.5.6 + '@contentstack/cli-utilities': ~1.6.2 '@contentstack/management': ~1.15.3 '@oclif/core': ^3.26.5 '@oclif/plugin-help': ^5 @@ -123,7 +123,7 @@ importers: specifiers: '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-dev-dependencies': ^1.2.4 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/plugin-help': ^5 '@oclif/plugin-plugins': ^5.0.0 '@oclif/test': ^2.5.6 @@ -187,7 +187,7 @@ importers: packages/contentstack-auth: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@fancy-test/nock': ^0.1.1 '@oclif/plugin-help': ^5.1.19 '@oclif/test': ^2.5.6 @@ -249,9 +249,9 @@ importers: packages/contentstack-bootstrap: specifiers: - '@contentstack/cli-cm-seed': ~1.7.4 + '@contentstack/cli-cm-seed': ~1.7.5 '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 '@types/inquirer': ^9.0.3 '@types/mkdirp': ^1.0.1 @@ -304,7 +304,7 @@ importers: '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-config': ~1.6.4 '@contentstack/cli-dev-dependencies': ~1.2.4 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/core': ^2.9.3 '@oclif/plugin-help': ^5.1.19 '@oclif/test': ^2.5.6 @@ -380,7 +380,7 @@ importers: packages/contentstack-bulk-publish: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 bluebird: ^3.7.2 chai: ^4.2.0 @@ -423,10 +423,10 @@ importers: packages/contentstack-clone: specifiers: '@colors/colors': ^1.5.0 - '@contentstack/cli-cm-export': ~1.11.3 - '@contentstack/cli-cm-import': ~1.15.5 + '@contentstack/cli-cm-export': ~1.11.4 + '@contentstack/cli-cm-import': ~1.15.6 '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 async: ^3.2.4 chai: ^4.2.0 @@ -479,7 +479,7 @@ importers: packages/contentstack-command: specifiers: - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 '@types/chai': ^4.2.18 '@types/mkdirp': ^1.0.1 @@ -521,7 +521,7 @@ importers: packages/contentstack-config: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 '@types/chai': ^4.2.18 '@types/inquirer': ^9.0.3 @@ -610,7 +610,7 @@ importers: '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-config': ~1.6.4 '@contentstack/cli-dev-dependencies': ~1.2.4 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/core': ^3.26.5 '@oclif/plugin-help': ^5.1.19 '@oclif/test': ^2.5.6 @@ -688,7 +688,7 @@ importers: packages/contentstack-export-to-csv: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 '@types/chai': ^4.3.6 '@types/mocha': ^10.0.1 @@ -730,9 +730,9 @@ importers: packages/contentstack-import: specifiers: - '@contentstack/cli-audit': ~1.6.1 + '@contentstack/cli-audit': ~1.6.2 '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@contentstack/management': ~1.15.3 '@oclif/core': ^3.26.5 '@oclif/test': ^2.5.6 @@ -821,7 +821,7 @@ importers: specifiers: '@apollo/client': ^3.7.9 '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/core': ^3.26.5 '@oclif/plugin-help': ^5 '@oclif/plugin-plugins': ^5.0.0 @@ -897,7 +897,7 @@ importers: packages/contentstack-migrate-rte: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@contentstack/json-rte-serializer': ~2.0.4 '@oclif/test': ^2.5.6 chai: ^4.3.4 @@ -944,7 +944,7 @@ importers: packages/contentstack-migration: specifiers: '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 async: ^3.2.4 callsites: ^3.1.0 @@ -990,9 +990,9 @@ importers: packages/contentstack-seed: specifiers: - '@contentstack/cli-cm-import': ~1.15.5 + '@contentstack/cli-cm-import': ~1.15.6 '@contentstack/cli-command': ~1.2.18 - '@contentstack/cli-utilities': ~1.6.1 + '@contentstack/cli-utilities': ~1.6.2 '@oclif/plugin-help': ^5.1.19 '@types/inquirer': ^9.0.3 '@types/jest': ^26.0.15 @@ -1081,6 +1081,7 @@ importers: nyc: ^15.1.0 open: ^8.4.2 ora: ^5.4.0 + recheck: ^4.4.5 rimraf: ^2.7.1 rxjs: ^6.6.7 sinon: ^15.0.1 @@ -1112,6 +1113,7 @@ importers: mkdirp: 1.0.4 open: 8.4.2 ora: 5.4.1 + recheck: 4.4.5 rxjs: 6.6.7 traverse: 0.6.9 unique-string: 2.0.0 @@ -12530,6 +12532,46 @@ packages: picomatch: 2.3.1 dev: true + /recheck-jar/4.4.5: + resolution: {integrity: sha512-a2kMzcfr+ntT0bObNLY22EUNV6Z6WeZ+DybRmPOUXVWzGcqhRcrK74tpgrYt3FdzTlSh85pqoryAPmrNkwLc0g==} + requiresBuild: true + dev: false + optional: true + + /recheck-linux-x64/4.4.5: + resolution: {integrity: sha512-s8OVPCpiSGw+tLCxH3eei7Zp2AoL22kXqLmEtWXi0AnYNwfuTjZmeLn2aQjW8qhs8ZPSkxS7uRIRTeZqR5Fv/Q==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /recheck-macos-x64/4.4.5: + resolution: {integrity: sha512-Ouup9JwwoKCDclt3Na8+/W2pVbt8FRpzjkDuyM32qTR2TOid1NI+P1GA6/VQAKEOjvaxgGjxhcP/WqAjN+EULA==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /recheck-windows-x64/4.4.5: + resolution: {integrity: sha512-mkpzLHu9G9Ztjx8HssJh9k/Xm1d1d/4OoT7etHqFk+k1NGzISCRXBD22DqYF9w8+J4QEzTAoDf8icFt0IGhOEQ==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /recheck/4.4.5: + resolution: {integrity: sha512-J80Ykhr+xxWtvWrfZfPpOR/iw2ijvb4WY8d9AVoN8oHsPP07JT1rCAalUSACMGxM1cvSocb6jppWFjVS6eTTrA==} + engines: {node: '>=14'} + optionalDependencies: + recheck-jar: 4.4.5 + recheck-linux-x64: 4.4.5 + recheck-macos-x64: 4.4.5 + recheck-windows-x64: 4.4.5 + dev: false + /rechoir/0.6.2: resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==} engines: {node: '>= 0.10'}