@solongate/proxy 0.6.6 → 0.6.8
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.
- package/dist/index.js +30 -5
- package/dist/init.js +14 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -88,6 +88,7 @@ function parseArgs(argv) {
|
|
|
88
88
|
let upstreamUrl;
|
|
89
89
|
let upstreamTransport;
|
|
90
90
|
let port;
|
|
91
|
+
let policyId;
|
|
91
92
|
let separatorIndex = args.indexOf("--");
|
|
92
93
|
const flags = separatorIndex >= 0 ? args.slice(0, separatorIndex) : args;
|
|
93
94
|
const upstreamArgs = separatorIndex >= 0 ? args.slice(separatorIndex + 1) : [];
|
|
@@ -126,6 +127,10 @@ function parseArgs(argv) {
|
|
|
126
127
|
case "--port":
|
|
127
128
|
port = parseInt(flags[++i], 10);
|
|
128
129
|
break;
|
|
130
|
+
case "--policy-id":
|
|
131
|
+
case "--id":
|
|
132
|
+
policyId = flags[++i];
|
|
133
|
+
break;
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
if (apiKey && /^\$\{.+\}$/.test(apiKey)) {
|
|
@@ -173,7 +178,8 @@ function parseArgs(argv) {
|
|
|
173
178
|
apiKey: apiKey ?? fileConfig.apiKey,
|
|
174
179
|
apiUrl: apiUrl ?? fileConfig.apiUrl,
|
|
175
180
|
port: port ?? fileConfig.port,
|
|
176
|
-
policyPath: resolvePolicyPath(cfgPolicySource) ?? void 0
|
|
181
|
+
policyPath: resolvePolicyPath(cfgPolicySource) ?? void 0,
|
|
182
|
+
policyId: policyId ?? fileConfig.policyId
|
|
177
183
|
};
|
|
178
184
|
}
|
|
179
185
|
if (upstreamUrl) {
|
|
@@ -193,7 +199,8 @@ function parseArgs(argv) {
|
|
|
193
199
|
apiKey,
|
|
194
200
|
apiUrl,
|
|
195
201
|
port,
|
|
196
|
-
policyPath: resolvedPolicyPath ?? void 0
|
|
202
|
+
policyPath: resolvedPolicyPath ?? void 0,
|
|
203
|
+
policyId
|
|
197
204
|
};
|
|
198
205
|
}
|
|
199
206
|
if (upstreamArgs.length === 0) {
|
|
@@ -217,7 +224,8 @@ function parseArgs(argv) {
|
|
|
217
224
|
apiKey,
|
|
218
225
|
apiUrl,
|
|
219
226
|
port,
|
|
220
|
-
policyPath: resolvedPolicyPath ?? void 0
|
|
227
|
+
policyPath: resolvedPolicyPath ?? void 0,
|
|
228
|
+
policyId
|
|
221
229
|
};
|
|
222
230
|
}
|
|
223
231
|
function resolvePolicyPath(source) {
|
|
@@ -1158,6 +1166,20 @@ process.stdin.on('end', async () => {
|
|
|
1158
1166
|
for (const p of protectedPaths) {
|
|
1159
1167
|
if (s.includes(p)) {
|
|
1160
1168
|
const msg = 'SOLONGATE: Access to protected file "' + p + '" is blocked';
|
|
1169
|
+
if (API_KEY && API_KEY.startsWith('sg_live_')) {
|
|
1170
|
+
try {
|
|
1171
|
+
await fetch(API_URL + '/api/v1/audit-logs', {
|
|
1172
|
+
method: 'POST',
|
|
1173
|
+
headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
|
|
1174
|
+
body: JSON.stringify({
|
|
1175
|
+
tool: data.tool_name || '', arguments: args,
|
|
1176
|
+
decision: 'DENY', reason: msg,
|
|
1177
|
+
source: 'claude-code-guard',
|
|
1178
|
+
}),
|
|
1179
|
+
signal: AbortSignal.timeout(3000),
|
|
1180
|
+
});
|
|
1181
|
+
} catch {}
|
|
1182
|
+
}
|
|
1161
1183
|
process.stderr.write(msg);
|
|
1162
1184
|
process.exit(2);
|
|
1163
1185
|
}
|
|
@@ -3722,10 +3744,12 @@ var PolicySyncManager = class {
|
|
|
3722
3744
|
pollTimer = null;
|
|
3723
3745
|
watcher = null;
|
|
3724
3746
|
isLiveKey;
|
|
3747
|
+
policyId;
|
|
3725
3748
|
constructor(opts) {
|
|
3726
3749
|
this.localPath = opts.localPath;
|
|
3727
3750
|
this.apiKey = opts.apiKey;
|
|
3728
3751
|
this.apiUrl = opts.apiUrl;
|
|
3752
|
+
this.policyId = opts.policyId;
|
|
3729
3753
|
this.pollIntervalMs = opts.pollIntervalMs ?? 6e4;
|
|
3730
3754
|
this.onPolicyUpdate = opts.onPolicyUpdate;
|
|
3731
3755
|
this.currentPolicy = opts.initialPolicy;
|
|
@@ -3827,7 +3851,7 @@ var PolicySyncManager = class {
|
|
|
3827
3851
|
*/
|
|
3828
3852
|
async onPollTick() {
|
|
3829
3853
|
try {
|
|
3830
|
-
const cloudPolicy = await fetchCloudPolicy(this.apiKey, this.apiUrl);
|
|
3854
|
+
const cloudPolicy = await fetchCloudPolicy(this.apiKey, this.apiUrl, this.policyId);
|
|
3831
3855
|
const cloudVer = cloudPolicy.version ?? 0;
|
|
3832
3856
|
if (cloudVer <= this.localVersion && this.policiesEqual(cloudPolicy, this.currentPolicy)) {
|
|
3833
3857
|
return;
|
|
@@ -3981,7 +4005,7 @@ var SolonGateProxy = class {
|
|
|
3981
4005
|
}
|
|
3982
4006
|
if (!this.config.apiKey.startsWith("sg_test_")) {
|
|
3983
4007
|
try {
|
|
3984
|
-
const cloudPolicy = await fetchCloudPolicy(this.config.apiKey, apiUrl);
|
|
4008
|
+
const cloudPolicy = await fetchCloudPolicy(this.config.apiKey, apiUrl, this.config.policyId);
|
|
3985
4009
|
this.config.policy = cloudPolicy;
|
|
3986
4010
|
log2(`Loaded cloud policy: ${cloudPolicy.name} (${cloudPolicy.rules.length} rules)`);
|
|
3987
4011
|
} catch (err) {
|
|
@@ -4296,6 +4320,7 @@ var SolonGateProxy = class {
|
|
|
4296
4320
|
apiUrl,
|
|
4297
4321
|
pollIntervalMs: 6e4,
|
|
4298
4322
|
initialPolicy: this.config.policy,
|
|
4323
|
+
policyId: this.config.policyId,
|
|
4299
4324
|
onPolicyUpdate: (policy) => {
|
|
4300
4325
|
this.config.policy = policy;
|
|
4301
4326
|
this.gate.loadPolicy(policy);
|
package/dist/init.js
CHANGED
|
@@ -347,6 +347,20 @@ process.stdin.on('end', async () => {
|
|
|
347
347
|
for (const p of protectedPaths) {
|
|
348
348
|
if (s.includes(p)) {
|
|
349
349
|
const msg = 'SOLONGATE: Access to protected file "' + p + '" is blocked';
|
|
350
|
+
if (API_KEY && API_KEY.startsWith('sg_live_')) {
|
|
351
|
+
try {
|
|
352
|
+
await fetch(API_URL + '/api/v1/audit-logs', {
|
|
353
|
+
method: 'POST',
|
|
354
|
+
headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
|
|
355
|
+
body: JSON.stringify({
|
|
356
|
+
tool: data.tool_name || '', arguments: args,
|
|
357
|
+
decision: 'DENY', reason: msg,
|
|
358
|
+
source: 'claude-code-guard',
|
|
359
|
+
}),
|
|
360
|
+
signal: AbortSignal.timeout(3000),
|
|
361
|
+
});
|
|
362
|
+
} catch {}
|
|
363
|
+
}
|
|
350
364
|
process.stderr.write(msg);
|
|
351
365
|
process.exit(2);
|
|
352
366
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
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": {
|