mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 10:16:49 +00:00
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:
@@ -156,7 +156,7 @@ _ccs_completion() {
|
||||
case "${prev}" in
|
||||
env)
|
||||
# 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
|
||||
env_opts="$env_opts $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
@@ -197,6 +197,11 @@ export async function handleEnvCommand(args: string[]): Promise<void> {
|
||||
const format = formatStr as OutputFormat;
|
||||
|
||||
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
|
||||
const shell = detectShell(shellStr === 'zsh' ? 'bash' : shellStr);
|
||||
|
||||
|
||||
@@ -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', () => {
|
||||
expect(formatExportLine('fish', 'VAL', "it's here")).toBe("set -gx VAL 'it'\\''s here'");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user