fix(env): add missing CLIProxy profiles to bash completion and shell validation

- Add iflow, kiro, ghcp, claude to bash completion env block
- Add --shell flag validation matching --format pattern
- Add backtick injection test case
This commit is contained in:
Tam Nhu Tran committed 2026-02-11 10:50:55 +07:00
1 parent 38bd562687
commit 6d9351dcbc
3 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ _ccs_completion() {
case "${prev}" in case "${prev}" in
env) env)
# Complete with profile names and flags (inline profiles since $cliproxy_profiles is out of scope) # Complete with profile names and flags (inline profiles since $cliproxy_profiles is out of scope)
local env_opts="--format --shell --help -h gemini codex agy qwen" local env_opts="--format --shell --help -h gemini codex agy qwen iflow kiro ghcp claude"
if [[ -f ~/.ccs/config.json ]]; then if [[ -f ~/.ccs/config.json ]]; then
env_opts="$env_opts $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)" env_opts="$env_opts $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
fi fi
+5
View File
@@ -197,6 +197,11 @@ export async function handleEnvCommand(args: string[]): Promise<void> {
const format = formatStr as OutputFormat; const format = formatStr as OutputFormat;
const shellStr = parseFlag(args, 'shell') || 'auto'; const shellStr = parseFlag(args, 'shell') || 'auto';
const validShellInputs = ['auto', 'bash', 'zsh', 'fish', 'powershell'];
if (!validShellInputs.includes(shellStr)) {
console.error(fail(`Invalid shell: ${shellStr}. Use: ${validShellInputs.join(', ')}`));
process.exit(1);
}
// zsh uses the same syntax as bash // zsh uses the same syntax as bash
const shell = detectShell(shellStr === 'zsh' ? 'bash' : shellStr); const shell = detectShell(shellStr === 'zsh' ? 'bash' : shellStr);
+6
View File
@@ -103,6 +103,12 @@ describe('env-command', () => {
); );
}); });
it('prevents backtick injection in values', () => {
expect(formatExportLine('bash', 'TOKEN', 'safe`whoami`')).toBe(
"export TOKEN='safe`whoami`'"
);
});
it('escapes single quotes in fish values', () => { it('escapes single quotes in fish values', () => {
expect(formatExportLine('fish', 'VAL', "it's here")).toBe("set -gx VAL 'it'\\''s here'"); expect(formatExportLine('fish', 'VAL', "it's here")).toBe("set -gx VAL 'it'\\''s here'");
}); });