feat(workshop-console): ▶ claude + 크롬 버튼 — claude --chrome(Claude-in-Chrome 연동) 자동 실행, 허용 목록은 고정 문자열 두 개뿐
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5877d03419
commit
e1a3afbd02
4 files changed
+11
-5
No files matched your search
@@ -40,7 +40,10 @@ export function resolveWorkshopCwd(workspace: string | undefined, projectId: unk
|
||||
}
|
||||
|
||||
// pty_spawn 에서 자동 실행을 허용하는 명령 — 허용 목록에 있는 것만(임의 명령 주입 방지).
|
||||
// 'claude-chrome' 은 클라이언트가 보내는 이름표일 뿐이고 실제 입력되는 명령은 아래 고정 문자열이다(Claude-in-Chrome 연동 플래그).
|
||||
export function allowedAutorun(v: unknown): string | null {
|
||||
return v === 'claude' ? 'claude' : null;
|
||||
if (v === 'claude') return 'claude';
|
||||
if (v === 'claude-chrome') return 'claude --chrome';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ describe('resolveWorkshopCwd', () => {
|
||||
});
|
||||
|
||||
describe('allowedAutorun', () => {
|
||||
test('claude만 허용한다', () => {
|
||||
test('claude와 크롬 연동 claude만 허용하고, 입력되는 명령은 고정 문자열이다', () => {
|
||||
assert.equal(allowedAutorun('claude'), 'claude');
|
||||
assert.equal(allowedAutorun('claude-chrome'), 'claude --chrome');
|
||||
});
|
||||
test('그 밖의 명령·주입 시도는 모두 null', () => {
|
||||
for (const bad of ['rm -rf /', 'claude; id', 'claude && ls', 'bash', '', undefined, 1, ['claude']]) {
|
||||
for (const bad of ['rm -rf /', 'claude; id', 'claude && ls', 'claude --chrome', 'claude-chrome; id', 'bash', '', undefined, 1, ['claude']]) {
|
||||
assert.equal(allowedAutorun(bad), null, JSON.stringify(bad));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
<div class="rb-console-bar">
|
||||
<span id="console-proj" class="rb-console-proj"></span>
|
||||
<button class="hdr-btn" onclick="consoleStart('claude')">▶ claude 시작</button>
|
||||
<button class="hdr-btn" onclick="consoleStart('claude-chrome')" title="claude --chrome — 서버의 크롬(확장 프로그램)을 조작하는 도구까지 연결">▶ claude + 크롬</button>
|
||||
<button class="hdr-btn" onclick="consoleStart('shell')">🐚 셸</button>
|
||||
<button class="hdr-btn" onclick="consoleStop()">■ 종료</button>
|
||||
<button class="hdr-btn" onclick="consoleClear()" title="화면 지우기(세션은 유지)">🧹 지우기</button>
|
||||
|
||||
@@ -84,9 +84,10 @@ async function consoleStart(mode) {
|
||||
consoleShellId = 'wsc_' + Date.now().toString(36);
|
||||
consoleTerm.reset();
|
||||
consoleRefit();
|
||||
const autorun = mode === 'claude' ? 'claude' : mode === 'claude-chrome' ? 'claude-chrome' : null;
|
||||
consoleSend({ type: 'pty_spawn', shellId: consoleShellId, cols: consoleTerm.cols, rows: consoleTerm.rows,
|
||||
workshopProjectId: proj.id, ...(mode === 'claude' ? { autorun: 'claude' } : {}) });
|
||||
consoleStatus((mode === 'claude' ? 'Claude Code' : '셸') + ' 실행 중 — ' + proj.name, '#22c55e');
|
||||
workshopProjectId: proj.id, ...(autorun ? { autorun } : {}) });
|
||||
consoleStatus((mode === 'claude' ? 'Claude Code' : mode === 'claude-chrome' ? 'Claude Code + 크롬' : '셸') + ' 실행 중 — ' + proj.name, '#22c55e');
|
||||
consoleTerm.focus();
|
||||
}
|
||||
const CONSOLE_HINT = '\x1b[90m▶ claude 시작을 누르면 이 프로젝트 폴더에서 Claude Code가 실행됩니다.\x1b[0m\r\n';
|
||||
|
||||
Reference in new issue
Block a user