@ia-ccun/code-agent-cli 0.0.51-beta.1 → 0.0.51-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -144,7 +144,7 @@ if (config.banner === '__default__' || config.banner !== '') {
144
144
  // 检查新版本
145
145
  async function checkForUpdates() {
146
146
  try {
147
- const { execSync } = await import('child_process');
147
+ const { execFileSync } = await import('child_process');
148
148
  // 读取本地版本 - 向上查找 package.json
149
149
  let rootDir = __dirname;
150
150
  let localVersion = null;
@@ -158,9 +158,9 @@ async function checkForUpdates() {
158
158
  }
159
159
  if (!localVersion) return;
160
160
 
161
- // 获取当前 registry
162
- const registry = execSync('npm config get registry', { encoding: 'utf8', stdio: 'pipe' }).trim();
163
- const latestVersion = execSync(`npm view @ia-ccun/code-agent-cli version --registry=${registry}`, { encoding: 'utf8', stdio: 'pipe' }).trim();
161
+ // 🔒 Security: Use execFileSync instead of execSync to prevent command injection
162
+ const registry = execFileSync('npm', ['config', 'get', 'registry'], { encoding: 'utf8', stdio: 'pipe' }).trim();
163
+ const latestVersion = execFileSync('npm', ['view', '@ia-ccun/code-agent-cli', 'version', '--registry=' + registry], { encoding: 'utf8', stdio: 'pipe' }).trim();
164
164
 
165
165
  // 比较版本号
166
166
  const localParts = localVersion.split('.').map(Number);
@@ -175,7 +175,8 @@ async function checkForUpdates() {
175
175
  try {
176
176
  const cacheDir = join(process.env.HOME || process.env.USERPROFILE, '.aicode-cli');
177
177
  if (!existsSync(cacheDir)) {
178
- execSync(`mkdir -p "${cacheDir}"`, { stdio: 'pipe' });
178
+ // 🔒 Security: Use execFileSync for mkdir instead of execSync
179
+ execFileSync('mkdir', ['-p', cacheDir], { stdio: 'pipe' });
179
180
  }
180
181
  const cacheData = {
181
182
  localVersion,