Skip to content

DX - 1995 - Updated SanitizePath Regex #1745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
705 changes: 416 additions & 289 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.9.0",
"version": "1.9.1",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -18,7 +18,7 @@
"/oclif.manifest.json"
],
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@oclif/plugin-help": "^5.2.20",
"@oclif/plugin-plugins": "^5.4.34",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-auth",
"description": "Contentstack CLI plugin for authentication activities",
"version": "1.3.24",
"version": "1.3.25",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -22,7 +22,7 @@
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "1.13.2",
"version": "1.13.3",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -17,8 +17,8 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~1.10.2",
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-cm-seed": "~1.10.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"inquirer": "8.2.6",
"mkdirp": "^1.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.3.0",
"version": "1.3.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@oclif/core": "^3.27.0",
"chalk": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@contentstack/cli-cm-bulk-publish",
"description": "Contentstack CLI plugin for bulk publish actions",
"version": "1.7.3",
"version": "1.7.4",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"chalk": "^4.1.2",
"dotenv": "^16.4.7",
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@contentstack/cli-cm-clone",
"description": "Contentstack stack clone plugin",
"version": "1.13.2",
"version": "1.13.3",
"author": "Contentstack",
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~1.15.0",
"@contentstack/cli-cm-import": "~1.20.0",
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-cm-export": "~1.15.2",
"@contentstack/cli-cm-import": "~1.20.1",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"chalk": "^4.1.2",
"inquirer": "8.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-command/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-command",
"description": "Contentstack CLI plugin for configuration",
"version": "1.3.3",
"version": "1.3.4",
"author": "Contentstack",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-config",
"description": "Contentstack CLI plugin for configuration",
"version": "1.10.0",
"version": "1.10.1",
"author": "Contentstack",
"scripts": {
"build": "npm run clean && npm run compile",
Expand All @@ -21,7 +21,7 @@
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
},
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"lodash": "^4.17.21"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export-to-csv/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@contentstack/cli-cm-export-to-csv",
"description": "Export entities to csv",
"version": "1.7.3",
"version": "1.7.4",
"author": "Abhinav Gupta @abhinav-from-contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"fast-csv": "^4.3.6",
"inquirer": "8.2.6",
Expand Down
10 changes: 5 additions & 5 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@contentstack/cli-cm-export",
"description": "Contentstack CLI plugin to export content from stack",
"version": "1.15.1",
"version": "1.15.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-variants": "~1.1.5",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-variants": "~1.1.6",
"@contentstack/cli-utilities": "~1.9.0",
"@oclif/core": "^3.27.0",
"async": "^3.2.6",
Expand All @@ -21,8 +21,8 @@
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-auth": "~1.3.24",
"@contentstack/cli-config": "~1.10.0",
"@contentstack/cli-auth": "~1.3.25",
"@contentstack/cli-config": "~1.10.1",
"@contentstack/cli-dev-dependencies": "~1.2.4",
"@oclif/plugin-help": "^5.2.20",
"@oclif/test": "^4.1.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from 'path';
import { Command } from '@contentstack/cli-command';
import {
cliux,
messageHandler,
printFlagDeprecation,
managementSDKClient,
flags,
ContentstackClient,
FlagInput,
pathValidator,
sanitizePath,
} from '@contentstack/cli-utilities';
import { ModuleExporter } from '../../../export';
import { setupExportConfig, log, formatError, writeExportMetaFile } from '../../../utils';
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class ExportCommand extends Command {
exportConfig.region = this.region;
exportConfig.developerHubBaseUrl = this.developerHubUrl;
if (this.personalizeUrl) exportConfig.modules.personalize.baseURL[exportConfig.region.name] = this.personalizeUrl;
exportDir = exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir;
exportDir = sanitizePath(exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir);
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
await moduleExporter.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import merge from 'merge';
import * as path from 'path';
import { configHandler, isAuthenticated, FlagInput, cliux } from '@contentstack/cli-utilities';
import { configHandler, isAuthenticated, FlagInput, cliux, sanitizePath } from '@contentstack/cli-utilities';
import defaultConfig from '../config';
import { readFile } from './file-helper';
import { askExportDir, askAPIKey } from './interactive';
Expand All @@ -15,14 +15,14 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
const externalConfig = await readFile(exportCmdFlags['config']);
config = merge.recursive(config, externalConfig);
}
config.exportDir = exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await askExportDir());
config.exportDir = sanitizePath(exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await askExportDir()));

const pattern = /[*$%#<>{}!&?]/g;
if (pattern.test(config.exportDir)) {
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
color: 'yellow',
});
config.exportDir = await askExportDir();
config.exportDir = sanitizePath(await askExportDir());
}
config.exportDir = config.exportDir.replace(/['"]/g, '');
config.exportDir = path.resolve(config.exportDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function init(_logPath: string) {
}

export const log = async (config: ExportConfig, message: any, type: string) => {
const logsPath = config.cliLogsPath || config.data;
const logsPath = sanitizePath(config.cliLogsPath || config.data);
// ignoring the type argument, as we are not using it to create a logfile anymore
if (type !== 'error') {
// removed type argument from init method
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-import-setup/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@contentstack/cli-cm-import-setup",
"description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
"version": "1.1.1",
"version": "1.1.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@oclif/core": "^3.27.0",
"big-json": "^3.2.0",
"chalk": "^4.1.2",
"fs-extra": "^11.1.1",
"fs-extra": "^11.3.0",
"lodash": "^4.17.21",
"merge": "^2.1.1",
"mkdirp": "^1.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
// config = merge.recursive(config, externalConfig);
// }

config.contentDir = importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir());
config.contentDir = sanitizePath(importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir()));
const pattern = /[*$%#<>{}!&?]/g;
if (pattern.test(config.contentDir)) {
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
color: 'yellow',
});
config.contentDir = await askContentDir();
config.contentDir = sanitizePath(await askContentDir());
}
config.contentDir = config.contentDir.replace(/['"]/g, '');
config.contentDir = path.resolve(config.contentDir);
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.20.1",
"version": "1.20.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.9.0",
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-audit": "~1.9.1",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@contentstack/management": "~1.18.4",
"@contentstack/cli-variants": "~1.1.5",
"@contentstack/cli-variants": "~1.1.6",
"@oclif/core": "^3.27.0",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config = merge.recursive(config, externalConfig);
}

config.contentDir = importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir());
config.contentDir = sanitizePath(importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir()));
const pattern = /[*$%#<>{}!&?]/g;
if (pattern.test(config.contentDir)) {
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
color: 'yellow',
});
config.contentDir = await askContentDir();
config.contentDir = sanitizePath(await askContentDir());
}
config.contentDir = config.contentDir.replace(/['"]/g, '');
config.contentDir = path.resolve(config.contentDir);
Expand Down
3 changes: 1 addition & 2 deletions packages/contentstack-import/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import * as winston from 'winston';
import * as path from 'path';
import mkdirp from 'mkdirp';
import { ImportConfig } from '../types';
import { sanitizePath, redactObject } from '@contentstack/cli-utilities';

Expand Down Expand Up @@ -140,7 +139,7 @@ function init(_logPath: string) {
}

export const log = async (config: ImportConfig, message: any, type: string) => {
config.cliLogsPath = config.cliLogsPath || config.data || path.join(__dirname, 'logs');
config.cliLogsPath = sanitizePath(config.cliLogsPath || config.data || path.join(__dirname, 'logs'));
// ignoring the type argument, as we are not using it to create a logfile anymore
if (type !== 'error') {
// removed type argument from init method
Expand Down
12 changes: 6 additions & 6 deletions packages/contentstack-migrate-rte/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "@contentstack/cli-cm-migrate-rte",
"description": "Contentstack CLI plugin to migrate HTML RTE to JSON RTE",
"version": "1.4.21",
"version": "1.4.22",
"author": "contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@contentstack/json-rte-serializer": "~2.0.11",
"@contentstack/json-rte-serializer": "~2.0.12",
"collapse-whitespace": "^1.1.7",
"chalk": "^4.1.2",
"jsdom": "^20.0.3",
"jsonschema": "^1.4.1",
"jsonschema": "^1.5.0",
"lodash": "^4.17.21",
"nock": "^13.5.5",
"nock": "^13.5.6",
"omit-deep-lodash": "^1.1.7",
"sinon": "^19.0.2"
},
"devDependencies": {
"@oclif/test": "^4.1.6",
"@oclif/test": "^4.1.9",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint-config-oclif": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-migration/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@contentstack/cli-migration",
"version": "1.6.5",
"version": "1.6.6",
"author": "@contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"async": "^3.2.6",
"callsites": "^3.1.0",
Expand All @@ -15,7 +15,7 @@
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.6",
"@oclif/test": "^4.1.9",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"jsdoc-to-markdown": "^8.0.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@contentstack/cli-cm-seed",
"description": "create a Stack from existing content types, entries, assets, etc.",
"version": "1.10.2",
"version": "1.10.3",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.20.0",
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-cm-import": "~1.20.1",
"@contentstack/cli-command": "~1.3.4",
"@contentstack/cli-utilities": "~1.9.0",
"@contentstack/management": "~1.18.4",
"inquirer": "8.2.6",
Expand Down
Loading