Replace spawn with execFile for memory-safe command execution (#1068)

This commit is contained in:
tanzhenxin
2025-11-20 15:04:00 +08:00
committed by GitHub
parent a15b84e2a1
commit 442a9aed58
20 changed files with 620 additions and 969 deletions

View File

@@ -447,7 +447,11 @@ describe('loggers', () => {
});
it('should log ripgrep fallback event', () => {
const event = new RipgrepFallbackEvent();
const event = new RipgrepFallbackEvent(
false,
false,
'ripgrep is not available',
);
logRipgrepFallback(mockConfig, event);
@@ -460,13 +464,13 @@ describe('loggers', () => {
'session.id': 'test-session-id',
'user.email': 'test-user@example.com',
'event.name': EVENT_RIPGREP_FALLBACK,
error: undefined,
error: 'ripgrep is not available',
}),
);
});
it('should log ripgrep fallback event with an error', () => {
const event = new RipgrepFallbackEvent('rg not found');
const event = new RipgrepFallbackEvent(false, false, 'rg not found');
logRipgrepFallback(mockConfig, event);

View File

@@ -314,7 +314,7 @@ export function logRipgrepFallback(
config: Config,
event: RipgrepFallbackEvent,
): void {
QwenLogger.getInstance(config)?.logRipgrepFallbackEvent();
QwenLogger.getInstance(config)?.logRipgrepFallbackEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {

View File

@@ -38,6 +38,7 @@ import type {
ModelSlashCommandEvent,
ExtensionDisableEvent,
AuthEvent,
RipgrepFallbackEvent,
} from '../types.js';
import { EndSessionEvent } from '../types.js';
import type {
@@ -778,8 +779,16 @@ export class QwenLogger {
this.flushIfNeeded();
}
logRipgrepFallbackEvent(): void {
const rumEvent = this.createActionEvent('misc', 'ripgrep_fallback', {});
logRipgrepFallbackEvent(event: RipgrepFallbackEvent): void {
const rumEvent = this.createActionEvent('misc', 'ripgrep_fallback', {
snapshots: JSON.stringify({
platform: process.platform,
arch: process.arch,
use_ripgrep: event.use_ripgrep,
use_builtin_ripgrep: event.use_builtin_ripgrep,
error: event.error ?? undefined,
}),
});
this.enqueueLogEvent(rumEvent);
this.flushIfNeeded();

View File

@@ -318,10 +318,20 @@ export class FlashFallbackEvent implements BaseTelemetryEvent {
export class RipgrepFallbackEvent implements BaseTelemetryEvent {
'event.name': 'ripgrep_fallback';
'event.timestamp': string;
use_ripgrep: boolean;
use_builtin_ripgrep: boolean;
error?: string;
constructor(public error?: string) {
constructor(
use_ripgrep: boolean,
use_builtin_ripgrep: boolean,
error?: string,
) {
this['event.name'] = 'ripgrep_fallback';
this['event.timestamp'] = new Date().toISOString();
this.use_ripgrep = use_ripgrep;
this.use_builtin_ripgrep = use_builtin_ripgrep;
this.error = error;
}
}