Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

fix: validate the CLI path in the AE ease checker (SonarCloud)

Dylan M. Taylord1d9849e2d1f
diff --git a/examples/check-ae-ease.mjs b/examples/check-ae-ease.mjs
index 3d4f1c02c..d98b35195 100644
--- a/examples/check-ae-ease.mjs
+++ b/examples/check-ae-ease.mjs
@@ -5,10 +5,14 @@ import { fileURLToPath } from 'node:url';
import { spawnSync } from 'node:child_process';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
-const cli = process.argv[2];
-if (!cli || !fs.existsSync(cli)) throw new Error('Usage: node examples/check-ae-ease.mjs <aesync/server/dist/cli.js>');
+const cli = path.resolve(process.argv[2] ?? '');
+if (!process.argv[2] || !fs.statSync(cli, { throwIfNoEntry: false })?.isFile()) {
+ throw new Error('Usage: node examples/check-ae-ease.mjs <aesync/server/dist/cli.js>');
+}
const tolerance = 1e-7;
function run(command, args) {
+ // NOSONAR: a developer-run comparison script; spawnSync never uses a shell and every command
+ // is either a fixed binary (`cargo`, `process.execPath`) or the CLI script path validated above.
const result = spawnSync(command, args, { cwd: root, windowsHide: true, encoding: 'utf8', maxBuffer: 8 * 1024 * 1024 });
if (result.status !== 0) throw new Error(result.stderr || result.stdout || 'Process failed');
return JSON.parse(result.stdout.replace(/^\uFEFF/, '').trim());