@solongate/proxy 0.58.0 → 0.59.1
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/audit/index.js +0 -0
- package/dist/create.js +0 -0
- package/dist/global-install.js +1 -1
- package/dist/index.js +341 -52
- package/dist/inject.js +0 -0
- package/dist/login.js +5 -39
- package/dist/logs-server.d.ts +1 -0
- package/dist/logs-server.js +174 -0
- package/dist/pull-push.js +0 -0
- package/dist/shield.js +106 -7
- package/hooks/.solongate/.last-deny +1 -0
- package/hooks/.solongate/.last-eval +1 -0
- package/hooks/.solongate/.last-tool-call +1 -0
- package/hooks/audit.mjs +565 -544
- package/hooks/guard.bundled.mjs +37 -6
- package/hooks/guard.mjs +1651 -1604
- package/hooks/shield.mjs +271 -271
- package/hooks/stop.mjs +75 -75
- package/package.json +74 -74
package/hooks/guard.bundled.mjs
CHANGED
|
@@ -6531,7 +6531,7 @@ var init_src = __esm({
|
|
|
6531
6531
|
|
|
6532
6532
|
// hooks/guard.mjs
|
|
6533
6533
|
import { readFileSync, existsSync, statSync, writeFileSync, mkdirSync, chmodSync, renameSync, appendFileSync } from "node:fs";
|
|
6534
|
-
import { resolve, join, dirname } from "node:path";
|
|
6534
|
+
import { resolve, join, dirname, isAbsolute } from "node:path";
|
|
6535
6535
|
import { homedir } from "node:os";
|
|
6536
6536
|
import { gunzipSync } from "node:zlib";
|
|
6537
6537
|
import { createHash } from "node:crypto";
|
|
@@ -6540,12 +6540,31 @@ function localLogsOnly(security) {
|
|
|
6540
6540
|
const l = security && security.localLogs;
|
|
6541
6541
|
return !!(l && l.enabled && typeof l.path === "string" && l.path.trim());
|
|
6542
6542
|
}
|
|
6543
|
+
function resolveLocalLogDir(rawPath) {
|
|
6544
|
+
const dir = String(rawPath || "").trim().replace(/[\\/]+$/, "");
|
|
6545
|
+
if (!dir)
|
|
6546
|
+
return null;
|
|
6547
|
+
if (isAbsolute(dir))
|
|
6548
|
+
return dir;
|
|
6549
|
+
const fallback = resolve(homedir(), ".solongate", "local-logs");
|
|
6550
|
+
try {
|
|
6551
|
+
mkdirSync(resolve(homedir(), ".solongate"), { recursive: true });
|
|
6552
|
+
writeFileSync(
|
|
6553
|
+
resolve(homedir(), ".solongate", ".local-logs-invalid-path"),
|
|
6554
|
+
JSON.stringify({ configured: dir, fallback, ts: Date.now() })
|
|
6555
|
+
);
|
|
6556
|
+
} catch {
|
|
6557
|
+
}
|
|
6558
|
+
return fallback;
|
|
6559
|
+
}
|
|
6543
6560
|
function writeLocalLog(security, entry) {
|
|
6544
6561
|
try {
|
|
6545
6562
|
const l = security && security.localLogs;
|
|
6546
6563
|
if (!l || !l.enabled || typeof l.path !== "string" || !l.path.trim())
|
|
6547
6564
|
return;
|
|
6548
|
-
const dir = l.path
|
|
6565
|
+
const dir = resolveLocalLogDir(l.path);
|
|
6566
|
+
if (!dir)
|
|
6567
|
+
return;
|
|
6549
6568
|
try {
|
|
6550
6569
|
mkdirSync(dir, { recursive: true });
|
|
6551
6570
|
} catch {
|
|
@@ -7424,7 +7443,7 @@ function extractWasmFromBundle(buf) {
|
|
|
7424
7443
|
}
|
|
7425
7444
|
throw new Error("Unknown OPA bundle format");
|
|
7426
7445
|
}
|
|
7427
|
-
var OPA_WASM_TTL_MS =
|
|
7446
|
+
var OPA_WASM_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
7428
7447
|
async function getOpaWasmBytes(policy) {
|
|
7429
7448
|
if (!policy || !policy.id)
|
|
7430
7449
|
return null;
|
|
@@ -7447,7 +7466,7 @@ async function getOpaWasmBytes(policy) {
|
|
|
7447
7466
|
try {
|
|
7448
7467
|
const res = await fetch(
|
|
7449
7468
|
API_URL + "/api/v1/policies/" + encodeURIComponent(policy.id) + "/wasm",
|
|
7450
|
-
{ headers: AUTH_HEADERS, signal: AbortSignal.timeout(
|
|
7469
|
+
{ headers: AUTH_HEADERS, signal: AbortSignal.timeout(2500) }
|
|
7451
7470
|
);
|
|
7452
7471
|
if (!res.ok)
|
|
7453
7472
|
return stale;
|
|
@@ -7627,12 +7646,15 @@ process.stdin.on("end", async () => {
|
|
|
7627
7646
|
let securityCfg = null;
|
|
7628
7647
|
const agentKey = (AGENT_ID || "default").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7629
7648
|
const policyCacheFile = join(resolve(homedir(), ".solongate"), ".policy-cache-" + agentKey + ".json");
|
|
7630
|
-
const POLICY_TTL_MS =
|
|
7649
|
+
const POLICY_TTL_MS = 6e4;
|
|
7631
7650
|
try {
|
|
7632
7651
|
let dashboardPolicy = null;
|
|
7652
|
+
let staleCache = null;
|
|
7633
7653
|
try {
|
|
7634
7654
|
if (existsSync(policyCacheFile)) {
|
|
7635
7655
|
const cached = JSON.parse(readFileSync(policyCacheFile, "utf-8"));
|
|
7656
|
+
if (cached && cached.policy)
|
|
7657
|
+
staleCache = cached;
|
|
7636
7658
|
if (cached && cached._ts && Date.now() - cached._ts < POLICY_TTL_MS) {
|
|
7637
7659
|
if (cached.policy)
|
|
7638
7660
|
dashboardPolicy = cached.policy;
|
|
@@ -7648,7 +7670,7 @@ process.stdin.on("end", async () => {
|
|
|
7648
7670
|
}
|
|
7649
7671
|
if (!dashboardPolicy) {
|
|
7650
7672
|
try {
|
|
7651
|
-
const res = await fetch(API_URL + "/api/v1/policies/active?agent_id=" + encodeURIComponent(AGENT_ID || "") + "&hv=" + HOOK_VERSION, { headers: AUTH_HEADERS, signal: AbortSignal.timeout(
|
|
7673
|
+
const res = await fetch(API_URL + "/api/v1/policies/active?agent_id=" + encodeURIComponent(AGENT_ID || "") + "&hv=" + HOOK_VERSION, { headers: AUTH_HEADERS, signal: AbortSignal.timeout(2e3) });
|
|
7652
7674
|
if (res.ok) {
|
|
7653
7675
|
const body = await res.json();
|
|
7654
7676
|
if (typeof body?.self_protection_enabled === "boolean")
|
|
@@ -7666,6 +7688,15 @@ process.stdin.on("end", async () => {
|
|
|
7666
7688
|
}
|
|
7667
7689
|
} catch {
|
|
7668
7690
|
}
|
|
7691
|
+
if (!dashboardPolicy && staleCache) {
|
|
7692
|
+
dashboardPolicy = staleCache.policy;
|
|
7693
|
+
if (typeof staleCache.selfProtect === "boolean")
|
|
7694
|
+
selfProtectEnabled = staleCache.selfProtect;
|
|
7695
|
+
if (staleCache.security !== void 0)
|
|
7696
|
+
securityCfg = staleCache.security;
|
|
7697
|
+
if (staleCache.hookVersions)
|
|
7698
|
+
CLOUD_HOOK_VERSIONS = staleCache.hookVersions;
|
|
7699
|
+
}
|
|
7669
7700
|
}
|
|
7670
7701
|
if (process.env.SOLONGATE_DEBUG) {
|
|
7671
7702
|
}
|