thevoidforge 21.0.14 → 21.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { request as httpsRequest } from 'node:https';
|
|
2
2
|
import { addRoute } from '../router.js';
|
|
3
|
-
import { vaultSet, vaultExists, vaultUnlock, vaultKeys, vaultPath, vaultLock } from '../lib/vault.js';
|
|
3
|
+
import { vaultSet, vaultGet, vaultExists, vaultUnlock, vaultKeys, vaultPath, vaultLock } from '../lib/vault.js';
|
|
4
4
|
import { parseJsonBody } from '../lib/body-parser.js';
|
|
5
5
|
import { clearModelCache } from '../lib/anthropic.js';
|
|
6
6
|
import { sendJson } from '../lib/http-helpers.js';
|
|
@@ -183,11 +183,16 @@ addRoute('POST', '/api/credentials/unlock', async (req, res) => {
|
|
|
183
183
|
clearVaultFailures(ip);
|
|
184
184
|
sessionPassword = body.password;
|
|
185
185
|
touchVaultAccess(); // SEC-R2-004: Start auto-lock timer
|
|
186
|
-
// Check what's already stored
|
|
186
|
+
// Check what's already stored + load API key into process.env for PTY sessions
|
|
187
187
|
let hasAnthropic = false;
|
|
188
188
|
try {
|
|
189
189
|
const keys = await vaultKeys(sessionPassword);
|
|
190
190
|
hasAnthropic = keys.includes('anthropic-api-key');
|
|
191
|
+
if (hasAnthropic) {
|
|
192
|
+
const storedKey = await vaultGet(sessionPassword, 'anthropic-api-key');
|
|
193
|
+
if (storedKey)
|
|
194
|
+
process.env['ANTHROPIC_API_KEY'] = storedKey;
|
|
195
|
+
}
|
|
191
196
|
}
|
|
192
197
|
catch {
|
|
193
198
|
// Fresh vault
|
|
@@ -220,6 +225,8 @@ addRoute('POST', '/api/credentials/anthropic', async (req, res) => {
|
|
|
220
225
|
return;
|
|
221
226
|
}
|
|
222
227
|
await vaultSet(sessionPassword, 'anthropic-api-key', apiKey);
|
|
228
|
+
// Make the key available to PTY sessions spawned by this server process
|
|
229
|
+
process.env['ANTHROPIC_API_KEY'] = apiKey;
|
|
223
230
|
clearModelCache();
|
|
224
231
|
sendJson(res, 200, { stored: true });
|
|
225
232
|
});
|
|
@@ -27,6 +27,15 @@ const MAX_SESSIONS_REMOTE = 20; // 5 per project, 20 total across all projects
|
|
|
27
27
|
const IDLE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
|
|
28
28
|
// SEC-004/QA-003: Whitelist of allowed initial commands — prevent arbitrary command injection
|
|
29
29
|
const ALLOWED_INITIAL_COMMANDS = ['claude', 'claude --dangerously-skip-permissions', 'bash', 'zsh', 'sh', 'npm run dev', 'npm start', 'npm test'];
|
|
30
|
+
// Also allow claude with slash commands (e.g., "claude /campaign --blitz")
|
|
31
|
+
function isAllowedCommand(cmd) {
|
|
32
|
+
if (ALLOWED_INITIAL_COMMANDS.includes(cmd))
|
|
33
|
+
return true;
|
|
34
|
+
// Allow: claude [slash-command] [flags]
|
|
35
|
+
if (/^claude\s+\/[a-z]/.test(cmd))
|
|
36
|
+
return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
30
39
|
// SEC-013: Safe environment keys — no credential leakage into PTY sessions
|
|
31
40
|
// ANTHROPIC_API_KEY included only in local mode (user's own key).
|
|
32
41
|
// In remote mode, operator's API key must NOT leak to deployer-role users.
|
|
@@ -98,6 +107,7 @@ export async function createSession(projectDir, projectName, label, initialComma
|
|
|
98
107
|
// For scaffold/spec purposes, we document the intent
|
|
99
108
|
safeEnv['VOIDFORGE_REMOTE'] = '1';
|
|
100
109
|
}
|
|
110
|
+
console.log(` PTY spawn: shell=${shell} cwd=${projectDir} cmd=${initialCommand ?? '(none)'} PATH=${safeEnv['PATH']?.slice(0, 80) ?? 'UNSET'}`);
|
|
101
111
|
const ptyProcess = nodePty.spawn(shell, [], spawnOptions);
|
|
102
112
|
const session = {
|
|
103
113
|
id,
|
|
@@ -142,7 +152,8 @@ export async function createSession(projectDir, projectName, label, initialComma
|
|
|
142
152
|
audit('terminal_start', '', username, { sessionId: id, project: projectName, label }).catch(() => { });
|
|
143
153
|
}
|
|
144
154
|
// SEC-004/QA-003: Validate initial command against whitelist
|
|
145
|
-
if (initialCommand && !
|
|
155
|
+
if (initialCommand && !isAllowedCommand(initialCommand)) {
|
|
156
|
+
console.log(` PTY: rejected command "${initialCommand}" (not in whitelist)`);
|
|
146
157
|
initialCommand = undefined;
|
|
147
158
|
}
|
|
148
159
|
// Auto-run initial command after a short delay (let shell init complete)
|