log-llm-config 1.3.13 → 1.3.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.
@@ -334,26 +334,31 @@ function assertSafeSqliteIdentifiersForItemTable(table, keyColumn, valueColumn)
334
334
  complianceRunnerDiag('sqlite_update: rejected unsafe SQL identifier(s)');
335
335
  return false;
336
336
  }
337
+ /**
338
+ * Canonical Cursor restart_command strings — single source for buildDeferredCursorRestartCommand + allowlist.
339
+ *
340
+ * - **SQLite / state.vscdb (deferred):** autofix queued ItemTable writes; restart runs `apply_deferred_vscdb` then reopens Cursor.
341
+ * - **JSON settings files:** autofix wrote normal config JSON; restart is kill + reopen only (no deferred apply).
342
+ *
343
+ * Exact-match only: `spawn('sh', ['-c', cmd])` runs the whole string; substring checks would allow
344
+ * appending `; arbitrary shell` after a trusted prefix.
345
+ */
346
+ const TRUSTED_CURSOR_SQLITE_DEFERRED_RESTART_COMMAND = 'REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export REPO_ROOT CURSOR_PROJECT="$REPO_ROOT" && ' +
347
+ "nohup bash -c 'sleep 2; if [ -f \"$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\" ]; then node \"$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\"; else npx --yes -p log-llm-config apply-deferred-vscdb; fi || true; open -a Cursor \"$CURSOR_PROJECT\"' >/dev/null 2>&1 & killall -9 Cursor";
348
+ const TRUSTED_CURSOR_JSON_SETTINGS_RESTART_COMMAND = 'CURSOR_PROJECT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export CURSOR_PROJECT && nohup bash -c \'sleep 2 && open -a Cursor "$CURSOR_PROJECT"\' >/dev/null 2>&1 & killall -9 Cursor';
349
+ const TRUSTED_CLAUDE_RESTART_COMMAND = "nohup bash -c 'sleep 2 && open -a Claude' >/dev/null 2>&1 & pkill -x 'Claude'";
337
350
  /**
338
351
  * Autofix restart_command allowlist: manifest strings are attacker-controlled if JSON is tampered.
339
- * Deferred vscdb path always uses buildDeferredCursorRestartCommand(); this guards non-deferred restarts.
352
+ * SQLite-deferred Cursor path always uses {@link buildDeferredCursorRestartCommand}; manifests may still
353
+ * embed the JSON-settings-only Cursor template when `restart_required` applies to file-based autofix.
340
354
  */
341
355
  export function isTrustedRestartCommandForAutofix(cmd) {
342
356
  const t = cmd.trim();
343
357
  if (!t)
344
358
  return false;
345
- const deferredPrefix = 'REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export REPO_ROOT CURSOR_PROJECT="$REPO_ROOT" && ';
346
- const legacyCursorPrefix = 'CURSOR_PROJECT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export CURSOR_PROJECT && ';
347
- const legacyCursorSnippet = 'nohup bash -c \'sleep 2 && open -a Cursor "$CURSOR_PROJECT"\'';
348
- const deferred = t.startsWith(deferredPrefix) &&
349
- (t.includes('apply_deferred_vscdb') || t.includes('apply-deferred-vscdb')) &&
350
- t.includes('killall -9 Cursor') &&
351
- t.includes('open -a Cursor');
352
- const legacyCursor = t.startsWith(legacyCursorPrefix) &&
353
- t.includes(legacyCursorSnippet) &&
354
- t.includes('killall -9 Cursor');
355
- const claude = t.startsWith("nohup bash -c 'sleep 2 && open -a Claude'") && t.includes("pkill -x 'Claude'");
356
- return deferred || legacyCursor || claude;
359
+ return (t === TRUSTED_CURSOR_SQLITE_DEFERRED_RESTART_COMMAND ||
360
+ t === TRUSTED_CURSOR_JSON_SETTINGS_RESTART_COMMAND ||
361
+ t === TRUSTED_CLAUDE_RESTART_COMMAND);
357
362
  }
358
363
  /** Legacy Cursor: dedicated ItemTable row `composerState`. Current Cursor: nested under reactive `applicationUser` blob. */
359
364
  function cursorVscdbHasUsableComposerStateRow(dbPath, sqliteOp) {
@@ -711,17 +716,16 @@ export async function applyDeferredVscdbFromDisk() {
711
716
  }
712
717
  }
713
718
  /**
714
- * macOS Cursor: SIGKILL, apply queued vscdb writes, reopen project.
719
+ * macOS Cursor: after deferred **SQLite / state.vscdb** autofix — apply queued writes, SIGKILL, reopen project.
715
720
  *
716
- * When `restart_required` implies deferred state.vscdb, `applyAutofixViolations` replaces any
717
- * `restart_command` from remediation specs with this string (see compliance_check.ts). Spec JSON
718
- * still documents a simpler Cursor reopen for non-code readers; that template is not executed on the deferred path.
721
+ * When autofix used the deferred vscdb path, `applyAutofixViolations` replaces any manifest `restart_command`
722
+ * with this string (see compliance_check.ts). For **JSON settings-file** remediations only, the trusted template
723
+ * is the JSON-settings-only Cursor template (kill + reopen, no `apply_deferred_vscdb`).
719
724
  */
720
725
  export function buildDeferredCursorRestartCommand() {
721
726
  // Prefer monorepo path when hooks run from optimus-secure-fdn; otherwise `npx -p log-llm-config apply-deferred-vscdb`
722
727
  // (package bin) so published installs work without a local npx_packages copy.
723
- return ('REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd) && export REPO_ROOT CURSOR_PROJECT="$REPO_ROOT" && ' +
724
- "nohup bash -c 'sleep 2; if [ -f \"$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\" ]; then node \"$REPO_ROOT/npx_packages/log-llm-config/dist/apply_deferred_vscdb.js\"; else npx --yes -p log-llm-config apply-deferred-vscdb; fi || true; open -a Cursor \"$CURSOR_PROJECT\"' >/dev/null 2>&1 & killall -9 Cursor");
728
+ return TRUSTED_CURSOR_SQLITE_DEFERRED_RESTART_COMMAND;
725
729
  }
726
730
  function sqliteRowGroupKey(dbPath, op) {
727
731
  return `${dbPath}|${op.table}|${op.key_column}|${op.value_column}|${op.target_key}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.3.13",
3
+ "version": "1.3.16",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {