mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 06:15:03 +00:00
fix(websearch): avoid shell for legacy CLI fallbacks (#1267)
* fix(websearch): avoid shell for legacy CLI fallbacks * style: apply prettier formatting
This commit is contained in:
1 parent
14cbe8fb67
commit
2115742caf
2 files changed
+21
-3
No files matched your search
@@ -874,7 +874,10 @@ function runGeminiCommand(args, timeoutMs) {
|
|||||||
timeout: timeoutMs,
|
timeout: timeoutMs,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
shell: isWindows,
|
// Never route query-derived prompts through a shell. Node concatenates
|
||||||
|
// arguments for shell-backed Windows spawns, which lets shell metacharacters
|
||||||
|
// in WebSearch queries escape the intended CLI invocation.
|
||||||
|
shell: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
@@ -929,7 +932,10 @@ function tryOpenCodeSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
|
|||||||
timeout: timeoutSec * 1000,
|
timeout: timeoutSec * 1000,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
shell: isWindows,
|
// Never route query-derived prompts through a shell. Node concatenates
|
||||||
|
// arguments for shell-backed Windows spawns, which lets shell metacharacters
|
||||||
|
// in WebSearch queries escape the intended CLI invocation.
|
||||||
|
shell: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -965,7 +971,10 @@ function tryGrokSearch(query, timeoutSec = DEFAULT_TIMEOUT_SEC) {
|
|||||||
timeout: timeoutSec * 1000,
|
timeout: timeoutSec * 1000,
|
||||||
maxBuffer: 1024 * 1024 * 2,
|
maxBuffer: 1024 * 1024 * 2,
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
shell: isWindows,
|
// Never route query-derived prompts through a shell. Node concatenates
|
||||||
|
// arguments for shell-backed Windows spawns, which lets shell metacharacters
|
||||||
|
// in WebSearch queries escape the intended CLI invocation.
|
||||||
|
shell: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
|||||||
@@ -131,6 +131,15 @@ function runHookWithMockedFetch(mode: 'success' | 'empty' | 'non-result' | 'fail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe('websearch-transformer legacy CLI safety', () => {
|
||||||
|
it('does not enable shell execution for query-derived legacy CLI prompts', () => {
|
||||||
|
const source = readFileSync(hookPath, 'utf8');
|
||||||
|
|
||||||
|
expect(source).not.toContain('shell: isWindows');
|
||||||
|
expect(source.match(/shell: false/g) || []).toHaveLength(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('websearch-transformer hook helpers', () => {
|
describe('websearch-transformer hook helpers', () => {
|
||||||
it('parses Retry-After seconds and HTTP dates', () => {
|
it('parses Retry-After seconds and HTTP dates', () => {
|
||||||
expect(hook.parseRetryAfterSeconds('2')).toBe(2);
|
expect(hook.parseRetryAfterSeconds('2')).toBe(2);
|
||||||
|
|||||||
Reference in new issue
Block a user