@solongate/proxy 0.6.0 → 0.6.2

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.
Files changed (3) hide show
  1. package/dist/index.js +31 -12
  2. package/dist/init.js +31 -12
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -664,10 +664,7 @@ function installHooks() {
664
664
  const auditPath = join(hooksDir, "audit.mjs");
665
665
  writeFileSync2(auditPath, AUDIT_SCRIPT);
666
666
  console.log(` Created ${auditPath}`);
667
- const claudeDir = resolve2(".claude");
668
- mkdirSync(claudeDir, { recursive: true });
669
- const settingsPath = join(claudeDir, "settings.json");
670
- const settings = {
667
+ const hookSettings = {
671
668
  hooks: {
672
669
  PreToolUse: [
673
670
  {
@@ -687,19 +684,28 @@ function installHooks() {
687
684
  ]
688
685
  }
689
686
  };
690
- let existing = {};
691
- try {
692
- existing = JSON.parse(readFileSync3(settingsPath, "utf-8"));
693
- } catch {
687
+ const clients = [
688
+ { name: "Claude Code", dir: ".claude" },
689
+ { name: "Cursor", dir: ".cursor" }
690
+ ];
691
+ for (const client of clients) {
692
+ const clientDir = resolve2(client.dir);
693
+ mkdirSync(clientDir, { recursive: true });
694
+ const settingsPath = join(clientDir, "settings.json");
695
+ let existing = {};
696
+ try {
697
+ existing = JSON.parse(readFileSync3(settingsPath, "utf-8"));
698
+ } catch {
699
+ }
700
+ const merged = { ...existing, hooks: hookSettings.hooks };
701
+ writeFileSync2(settingsPath, JSON.stringify(merged, null, 2) + "\n");
702
+ console.log(` Created ${settingsPath}`);
694
703
  }
695
- const merged = { ...existing, hooks: settings.hooks };
696
- writeFileSync2(settingsPath, JSON.stringify(merged, null, 2) + "\n");
697
- console.log(` Created ${settingsPath}`);
698
704
  console.log("");
699
705
  console.log(" Hooks installed:");
700
706
  console.log(" guard.mjs \u2192 blocks policy-violating calls (pre-execution)");
701
707
  console.log(" audit.mjs \u2192 logs all calls to dashboard (post-execution)");
702
- console.log(" .claude/settings.json \u2192 hooks activated for Claude Code");
708
+ console.log(" Activated for: Claude Code, Cursor");
703
709
  }
704
710
  function ensureEnvFile() {
705
711
  const envPath = resolve2(".env");
@@ -1125,6 +1131,19 @@ process.stdin.on('end', async () => {
1125
1131
  const data = JSON.parse(input);
1126
1132
  const args = data.tool_input || {};
1127
1133
 
1134
+ // \u2500\u2500 Self-protection: block access to hook files and settings \u2500\u2500
1135
+ const allStrings = scanStrings(args).map(s => s.replace(/\\\\\\\\/g, '/').toLowerCase());
1136
+ const protectedPaths = ['.solongate', '.claude/settings.json', '.cursor/settings.json', 'policy.json'];
1137
+ for (const s of allStrings) {
1138
+ for (const p of protectedPaths) {
1139
+ if (s.includes(p)) {
1140
+ const msg = 'SOLONGATE: Access to protected file "' + p + '" is blocked';
1141
+ process.stderr.write(msg);
1142
+ process.exit(2);
1143
+ }
1144
+ }
1145
+ }
1146
+
1128
1147
  // Load policy
1129
1148
  let policy;
1130
1149
  try {
package/dist/init.js CHANGED
@@ -320,6 +320,19 @@ process.stdin.on('end', async () => {
320
320
  const data = JSON.parse(input);
321
321
  const args = data.tool_input || {};
322
322
 
323
+ // \u2500\u2500 Self-protection: block access to hook files and settings \u2500\u2500
324
+ const allStrings = scanStrings(args).map(s => s.replace(/\\\\\\\\/g, '/').toLowerCase());
325
+ const protectedPaths = ['.solongate', '.claude/settings.json', '.cursor/settings.json', 'policy.json'];
326
+ for (const s of allStrings) {
327
+ for (const p of protectedPaths) {
328
+ if (s.includes(p)) {
329
+ const msg = 'SOLONGATE: Access to protected file "' + p + '" is blocked';
330
+ process.stderr.write(msg);
331
+ process.exit(2);
332
+ }
333
+ }
334
+ }
335
+
323
336
  // Load policy
324
337
  let policy;
325
338
  try {
@@ -417,10 +430,7 @@ function installHooks() {
417
430
  const auditPath = join(hooksDir, "audit.mjs");
418
431
  writeFileSync(auditPath, AUDIT_SCRIPT);
419
432
  console.log(` Created ${auditPath}`);
420
- const claudeDir = resolve(".claude");
421
- mkdirSync(claudeDir, { recursive: true });
422
- const settingsPath = join(claudeDir, "settings.json");
423
- const settings = {
433
+ const hookSettings = {
424
434
  hooks: {
425
435
  PreToolUse: [
426
436
  {
@@ -440,19 +450,28 @@ function installHooks() {
440
450
  ]
441
451
  }
442
452
  };
443
- let existing = {};
444
- try {
445
- existing = JSON.parse(readFileSync(settingsPath, "utf-8"));
446
- } catch {
453
+ const clients = [
454
+ { name: "Claude Code", dir: ".claude" },
455
+ { name: "Cursor", dir: ".cursor" }
456
+ ];
457
+ for (const client of clients) {
458
+ const clientDir = resolve(client.dir);
459
+ mkdirSync(clientDir, { recursive: true });
460
+ const settingsPath = join(clientDir, "settings.json");
461
+ let existing = {};
462
+ try {
463
+ existing = JSON.parse(readFileSync(settingsPath, "utf-8"));
464
+ } catch {
465
+ }
466
+ const merged = { ...existing, hooks: hookSettings.hooks };
467
+ writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + "\n");
468
+ console.log(` Created ${settingsPath}`);
447
469
  }
448
- const merged = { ...existing, hooks: settings.hooks };
449
- writeFileSync(settingsPath, JSON.stringify(merged, null, 2) + "\n");
450
- console.log(` Created ${settingsPath}`);
451
470
  console.log("");
452
471
  console.log(" Hooks installed:");
453
472
  console.log(" guard.mjs \u2192 blocks policy-violating calls (pre-execution)");
454
473
  console.log(" audit.mjs \u2192 logs all calls to dashboard (post-execution)");
455
- console.log(" .claude/settings.json \u2192 hooks activated for Claude Code");
474
+ console.log(" Activated for: Claude Code, Cursor");
456
475
  }
457
476
  function ensureEnvFile() {
458
477
  const envPath = resolve(".env");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "MCP security proxy — protect any MCP server with customizable policies, path/command constraints, rate limiting, and audit logging. Zero code changes required.",
5
5
  "type": "module",
6
6
  "bin": {