Security: fix eslint for DevExtreme#33631
Conversation
There was a problem hiding this comment.
Pull request overview
Updates demo utility scripts to execute external tooling in a safer/more lint-compliant way (moving away from string-based shell execution) as part of a security/eslint fix.
Changes:
ts-to-js-converter: switch TypeScript compilation fromexec("tsc ...")toexecFile(...)with argument arrays.create-bundles(Angular): switch Angular build invocation fromexec(...)tospawn(...)with platform-specific command/args.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/demos/utils/ts-to-js-converter/converter.ts | Uses execFile + argv arrays for running tsc during TS→JS conversion. |
| apps/demos/utils/create-bundles/Angular/bundler.ts | Uses spawn + argv arrays for running npm run build-angular during Angular demo bundling. |
Comments suppressed due to low confidence (1)
apps/demos/utils/create-bundles/Angular/bundler.ts:59
spawncan emit anerrorevent (e.g. ENOENT whennpm/cmdisn't found). In that case theclosehandler may never fire, sores()is never called and the batch processing hangs. Add anngBuildProcess.on('error', ...)handler that reports the failure and resolves/rejects appropriately.
const isWin = process.platform === 'win32';
const [npmCmd, npmArgs] = isWin
? ['cmd', ['/c', 'npm.cmd', 'run', 'build-angular', '--', getProjectNameByDemo(demo)]]
: ['npm', ['run', 'build-angular', '--', getProjectNameByDemo(demo)]];
const ngBuildProcess = spawn(npmCmd, npmArgs);
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ngBuildProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
ngBuildProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
res();
});
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
apps/demos/utils/create-bundles/Angular/bundler.ts:59
spawn(...)can emit anerrorevent (e.g., ifnpm/cmdcannot be started). In that case, theclosehandler may never run andres()won’t be called, causingprocessDemo()to hang indefinitely. Add anngBuildProcess.on('error', ...)handler that logs the error and callsres()(or otherwise terminates the batch).
const ngBuildProcess = spawn(npmCmd, npmArgs);
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ngBuildProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
ngBuildProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
res();
});
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sergei Burkatskii <sergei.burkatskii@devexpress.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
apps/demos/utils/create-bundles/Angular/bundler.ts:54
spawn()can emit anerrorevent (e.g., ifnpm/npm.cmdis not found). Right now there is nongBuildProcess.on('error', ...)handler, which can cause an unhandled error and preventres()from being called. Add anerrorhandler that logs/propagates the failure and resolves/rejects appropriately.
const isWin = process.platform === 'win32';
const npmCmd = isWin ? 'npm.cmd' : 'npm';
const npmArgs = ['run', 'build-angular', '--', getProjectNameByDemo(demo)];
const ngBuildProcess = spawn(npmCmd, npmArgs);
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ngBuildProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
| const ngBuildProcess = spawn(npmCmd, npmArgs); | ||
| ngBuildProcess.stdout.on('data', (data) => { | ||
| console.log(`stdout: ${data}`); | ||
| }); |
There was a problem hiding this comment.
I think it is not related to the current changes
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
apps/demos/utils/create-bundles/Angular/bundler.ts:58
- The Angular build result is treated as success regardless of whether
npm run build-angularfails. Theclosehandler always callsres()and ignores non-zero exit codes, and there’s also noerrorhandler for cases likenpmnot being found (which would leave the Promise unresolved). Please propagate failures (e.g., reject/throw oncode !== 0and handle theerrorevent) so the batching script can fail fast instead of continuing with broken bundles.
const isWin = process.platform === 'win32';
const npmCmd = isWin ? 'npm.cmd' : 'npm';
const npmArgs = ['run', 'build-angular', '--', getProjectNameByDemo(demo)];
const ngBuildProcess = spawn(npmCmd, npmArgs);
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ngBuildProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
ngBuildProcess.on('close', (code) => {
console.log(`child process exited with code ${code}`);
res();
});
No description provided.