@probelabs/visor 0.1.138-ee → 0.1.139
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 +47 -1732
- package/dist/output/traces/run-2026-02-24T09-10-20-312Z.ndjson +138 -0
- package/dist/output/traces/run-2026-02-24T09-11-09-877Z.ndjson +1442 -0
- package/dist/providers/mcp-check-provider.d.ts.map +1 -1
- package/dist/providers/workflow-check-provider.d.ts.map +1 -1
- package/dist/sdk/check-provider-registry-DGL4AGIV.mjs +29 -0
- package/dist/sdk/{check-provider-registry-B5X3AL4Z.mjs → check-provider-registry-EHLKMSLE.mjs} +3 -3
- package/dist/sdk/{check-provider-registry-XRD3J74K.mjs → check-provider-registry-QDSFKMQN.mjs} +2 -2
- package/dist/sdk/chunk-AZEZKZV3.mjs +443 -0
- package/dist/sdk/chunk-AZEZKZV3.mjs.map +1 -0
- package/dist/sdk/chunk-F7UJSECZ.mjs +739 -0
- package/dist/sdk/chunk-F7UJSECZ.mjs.map +1 -0
- package/dist/sdk/chunk-GTEY4DVM.mjs +40247 -0
- package/dist/sdk/{chunk-3CREE2RR.mjs.map → chunk-GTEY4DVM.mjs.map} +1 -1
- package/dist/sdk/chunk-HUKN7UKV.mjs +1502 -0
- package/dist/sdk/chunk-HUKN7UKV.mjs.map +1 -0
- package/dist/sdk/{chunk-3CREE2RR.mjs → chunk-TJXIVJ37.mjs} +30 -18
- package/dist/sdk/{chunk-SUZCXRJ4.mjs.map → chunk-TJXIVJ37.mjs.map} +1 -1
- package/dist/sdk/{chunk-SUZCXRJ4.mjs → chunk-UYMFCE4F.mjs} +36 -24
- package/dist/sdk/chunk-UYMFCE4F.mjs.map +1 -0
- package/dist/sdk/failure-condition-evaluator-TBEIP7RD.mjs +17 -0
- package/dist/sdk/github-frontend-KERJN37X.mjs +1356 -0
- package/dist/sdk/github-frontend-KERJN37X.mjs.map +1 -0
- package/dist/sdk/{host-RF2UEKMG.mjs → host-HYYJTFCQ.mjs} +2 -2
- package/dist/sdk/routing-MCP7FOF6.mjs +25 -0
- package/dist/sdk/{schedule-tool-handler-WHB5AGLT.mjs → schedule-tool-handler-7FGVBTTW.mjs} +2 -2
- package/dist/sdk/schedule-tool-handler-OBFDMIHE.mjs +39 -0
- package/dist/sdk/schedule-tool-handler-OBFDMIHE.mjs.map +1 -0
- package/dist/sdk/{schedule-tool-handler-47KJUUJH.mjs → schedule-tool-handler-S3R5YY5S.mjs} +3 -3
- package/dist/sdk/schedule-tool-handler-S3R5YY5S.mjs.map +1 -0
- package/dist/sdk/sdk.js +298 -1544
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +5 -5
- package/dist/sdk/trace-helpers-7VRDBNXM.mjs +25 -0
- package/dist/sdk/trace-helpers-7VRDBNXM.mjs.map +1 -0
- package/dist/sdk/{workflow-check-provider-D375GDQS.mjs → workflow-check-provider-A6J5AEK4.mjs} +3 -3
- package/dist/sdk/workflow-check-provider-A6J5AEK4.mjs.map +1 -0
- package/dist/sdk/{workflow-check-provider-MIFPOENL.mjs → workflow-check-provider-O2NXWYDY.mjs} +2 -2
- package/dist/sdk/workflow-check-provider-O2NXWYDY.mjs.map +1 -0
- package/dist/sdk/workflow-check-provider-XNNNVDAG.mjs +29 -0
- package/dist/sdk/workflow-check-provider-XNNNVDAG.mjs.map +1 -0
- package/dist/state-machine/workflow-projection.d.ts.map +1 -1
- package/dist/traces/run-2026-02-24T09-10-20-312Z.ndjson +138 -0
- package/dist/traces/run-2026-02-24T09-11-09-877Z.ndjson +1442 -0
- package/dist/types/workflow.d.ts +2 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/sdk/knex-store-HPXJILBL.mjs +0 -411
- package/dist/sdk/knex-store-HPXJILBL.mjs.map +0 -1
- package/dist/sdk/loader-ZC5G3JGJ.mjs +0 -89
- package/dist/sdk/loader-ZC5G3JGJ.mjs.map +0 -1
- package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs +0 -655
- package/dist/sdk/opa-policy-engine-S2S2ULEI.mjs.map +0 -1
- package/dist/sdk/validator-XTZJZZJH.mjs +0 -134
- package/dist/sdk/validator-XTZJZZJH.mjs.map +0 -1
- /package/dist/sdk/{check-provider-registry-B5X3AL4Z.mjs.map → check-provider-registry-DGL4AGIV.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-XRD3J74K.mjs.map → check-provider-registry-EHLKMSLE.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-47KJUUJH.mjs.map → check-provider-registry-QDSFKMQN.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-WHB5AGLT.mjs.map → failure-condition-evaluator-TBEIP7RD.mjs.map} +0 -0
- /package/dist/sdk/{host-RF2UEKMG.mjs.map → host-HYYJTFCQ.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-D375GDQS.mjs.map → routing-MCP7FOF6.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-MIFPOENL.mjs.map → schedule-tool-handler-7FGVBTTW.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.env.VISOR_VERSION = '0.1.
|
|
2
|
+
process.env.VISOR_VERSION = '0.1.139';
|
|
3
3
|
process.env.PROBE_VERSION = '0.6.0-rc257';
|
|
4
|
-
process.env.VISOR_COMMIT_SHA = '
|
|
5
|
-
process.env.VISOR_COMMIT_SHORT = '
|
|
4
|
+
process.env.VISOR_COMMIT_SHA = 'aa10b1837c5ab4db49ff46f5391606063e95d13b';
|
|
5
|
+
process.env.VISOR_COMMIT_SHORT = 'aa10b18';
|
|
6
6
|
/******/ (() => { // webpackBootstrap
|
|
7
7
|
/******/ var __webpack_modules__ = ({
|
|
8
8
|
|
|
@@ -161177,7 +161177,7 @@ async function handleDumpPolicyInput(checkId, argv) {
|
|
|
161177
161177
|
let PolicyInputBuilder;
|
|
161178
161178
|
try {
|
|
161179
161179
|
// @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
|
|
161180
|
-
const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(
|
|
161180
|
+
const mod = await Promise.resolve().then(() => __importStar(__nccwpck_require__(71370)));
|
|
161181
161181
|
PolicyInputBuilder = mod.PolicyInputBuilder;
|
|
161182
161182
|
}
|
|
161183
161183
|
catch {
|
|
@@ -166952,1690 +166952,6 @@ class DependencyResolver {
|
|
|
166952
166952
|
exports.DependencyResolver = DependencyResolver;
|
|
166953
166953
|
|
|
166954
166954
|
|
|
166955
|
-
/***/ }),
|
|
166956
|
-
|
|
166957
|
-
/***/ 50069:
|
|
166958
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
166959
|
-
|
|
166960
|
-
"use strict";
|
|
166961
|
-
|
|
166962
|
-
/**
|
|
166963
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
166964
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
166965
|
-
* in compliance with the Elastic License 2.0.
|
|
166966
|
-
*/
|
|
166967
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
166968
|
-
if (k2 === undefined) k2 = k;
|
|
166969
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
166970
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
166971
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
166972
|
-
}
|
|
166973
|
-
Object.defineProperty(o, k2, desc);
|
|
166974
|
-
}) : (function(o, m, k, k2) {
|
|
166975
|
-
if (k2 === undefined) k2 = k;
|
|
166976
|
-
o[k2] = m[k];
|
|
166977
|
-
}));
|
|
166978
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
166979
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
166980
|
-
}) : function(o, v) {
|
|
166981
|
-
o["default"] = v;
|
|
166982
|
-
});
|
|
166983
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
166984
|
-
var ownKeys = function(o) {
|
|
166985
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
166986
|
-
var ar = [];
|
|
166987
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
166988
|
-
return ar;
|
|
166989
|
-
};
|
|
166990
|
-
return ownKeys(o);
|
|
166991
|
-
};
|
|
166992
|
-
return function (mod) {
|
|
166993
|
-
if (mod && mod.__esModule) return mod;
|
|
166994
|
-
var result = {};
|
|
166995
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
166996
|
-
__setModuleDefault(result, mod);
|
|
166997
|
-
return result;
|
|
166998
|
-
};
|
|
166999
|
-
})();
|
|
167000
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167001
|
-
exports.LicenseValidator = void 0;
|
|
167002
|
-
const crypto = __importStar(__nccwpck_require__(76982));
|
|
167003
|
-
const fs = __importStar(__nccwpck_require__(79896));
|
|
167004
|
-
const path = __importStar(__nccwpck_require__(16928));
|
|
167005
|
-
class LicenseValidator {
|
|
167006
|
-
/** Ed25519 public key for license verification (PEM format). */
|
|
167007
|
-
static PUBLIC_KEY = '-----BEGIN PUBLIC KEY-----\n' +
|
|
167008
|
-
'MCowBQYDK2VwAyEAI/Zd08EFmgIdrDm/HXd0l3/5GBt7R1PrdvhdmEXhJlU=\n' +
|
|
167009
|
-
'-----END PUBLIC KEY-----\n';
|
|
167010
|
-
cache = null;
|
|
167011
|
-
static CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
167012
|
-
static GRACE_PERIOD = 72 * 3600 * 1000; // 72 hours after expiry
|
|
167013
|
-
/**
|
|
167014
|
-
* Load and validate license from environment or file.
|
|
167015
|
-
*
|
|
167016
|
-
* Resolution order:
|
|
167017
|
-
* 1. VISOR_LICENSE env var (JWT string)
|
|
167018
|
-
* 2. VISOR_LICENSE_FILE env var (path to file)
|
|
167019
|
-
* 3. .visor-license in project root (cwd)
|
|
167020
|
-
* 4. .visor-license in ~/.config/visor/
|
|
167021
|
-
*/
|
|
167022
|
-
async loadAndValidate() {
|
|
167023
|
-
// Return cached result if still fresh
|
|
167024
|
-
if (this.cache && Date.now() - this.cache.validatedAt < LicenseValidator.CACHE_TTL) {
|
|
167025
|
-
return this.cache.payload;
|
|
167026
|
-
}
|
|
167027
|
-
const token = this.resolveToken();
|
|
167028
|
-
if (!token)
|
|
167029
|
-
return null;
|
|
167030
|
-
const payload = this.verifyAndDecode(token);
|
|
167031
|
-
if (!payload)
|
|
167032
|
-
return null;
|
|
167033
|
-
this.cache = { payload, validatedAt: Date.now() };
|
|
167034
|
-
return payload;
|
|
167035
|
-
}
|
|
167036
|
-
/** Check if a specific feature is licensed */
|
|
167037
|
-
hasFeature(feature) {
|
|
167038
|
-
if (!this.cache)
|
|
167039
|
-
return false;
|
|
167040
|
-
return this.cache.payload.features.includes(feature);
|
|
167041
|
-
}
|
|
167042
|
-
/** Check if license is valid (with grace period) */
|
|
167043
|
-
isValid() {
|
|
167044
|
-
if (!this.cache)
|
|
167045
|
-
return false;
|
|
167046
|
-
const now = Date.now();
|
|
167047
|
-
const expiryMs = this.cache.payload.exp * 1000;
|
|
167048
|
-
return now < expiryMs + LicenseValidator.GRACE_PERIOD;
|
|
167049
|
-
}
|
|
167050
|
-
/** Check if the license is within its grace period (expired but still valid) */
|
|
167051
|
-
isInGracePeriod() {
|
|
167052
|
-
if (!this.cache)
|
|
167053
|
-
return false;
|
|
167054
|
-
const now = Date.now();
|
|
167055
|
-
const expiryMs = this.cache.payload.exp * 1000;
|
|
167056
|
-
return now >= expiryMs && now < expiryMs + LicenseValidator.GRACE_PERIOD;
|
|
167057
|
-
}
|
|
167058
|
-
resolveToken() {
|
|
167059
|
-
// 1. Direct env var
|
|
167060
|
-
if (process.env.VISOR_LICENSE) {
|
|
167061
|
-
return process.env.VISOR_LICENSE.trim();
|
|
167062
|
-
}
|
|
167063
|
-
// 2. File path from env (validate against path traversal)
|
|
167064
|
-
if (process.env.VISOR_LICENSE_FILE) {
|
|
167065
|
-
// path.resolve() produces an absolute path with all '..' segments resolved,
|
|
167066
|
-
// so a separate resolved.includes('..') check is unnecessary.
|
|
167067
|
-
const resolved = path.resolve(process.env.VISOR_LICENSE_FILE);
|
|
167068
|
-
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
167069
|
-
const allowedPrefixes = [path.normalize(process.cwd())];
|
|
167070
|
-
if (home)
|
|
167071
|
-
allowedPrefixes.push(path.normalize(path.join(home, '.config', 'visor')));
|
|
167072
|
-
// Resolve symlinks so an attacker cannot create a symlink inside an
|
|
167073
|
-
// allowed prefix that points to an arbitrary file outside it.
|
|
167074
|
-
let realPath;
|
|
167075
|
-
try {
|
|
167076
|
-
realPath = fs.realpathSync(resolved);
|
|
167077
|
-
}
|
|
167078
|
-
catch {
|
|
167079
|
-
return null; // File doesn't exist or isn't accessible
|
|
167080
|
-
}
|
|
167081
|
-
const isSafe = allowedPrefixes.some(prefix => realPath === prefix || realPath.startsWith(prefix + path.sep));
|
|
167082
|
-
if (!isSafe)
|
|
167083
|
-
return null;
|
|
167084
|
-
return this.readFile(realPath);
|
|
167085
|
-
}
|
|
167086
|
-
// 3. .visor-license in cwd
|
|
167087
|
-
const cwdPath = path.join(process.cwd(), '.visor-license');
|
|
167088
|
-
const cwdToken = this.readFile(cwdPath);
|
|
167089
|
-
if (cwdToken)
|
|
167090
|
-
return cwdToken;
|
|
167091
|
-
// 4. ~/.config/visor/.visor-license
|
|
167092
|
-
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
167093
|
-
if (home) {
|
|
167094
|
-
const configPath = path.join(home, '.config', 'visor', '.visor-license');
|
|
167095
|
-
const configToken = this.readFile(configPath);
|
|
167096
|
-
if (configToken)
|
|
167097
|
-
return configToken;
|
|
167098
|
-
}
|
|
167099
|
-
return null;
|
|
167100
|
-
}
|
|
167101
|
-
readFile(filePath) {
|
|
167102
|
-
try {
|
|
167103
|
-
return fs.readFileSync(filePath, 'utf-8').trim();
|
|
167104
|
-
}
|
|
167105
|
-
catch {
|
|
167106
|
-
return null;
|
|
167107
|
-
}
|
|
167108
|
-
}
|
|
167109
|
-
verifyAndDecode(token) {
|
|
167110
|
-
try {
|
|
167111
|
-
const parts = token.split('.');
|
|
167112
|
-
if (parts.length !== 3)
|
|
167113
|
-
return null;
|
|
167114
|
-
const [headerB64, payloadB64, signatureB64] = parts;
|
|
167115
|
-
// Decode header to verify algorithm
|
|
167116
|
-
const header = JSON.parse(Buffer.from(headerB64, 'base64url').toString());
|
|
167117
|
-
if (header.alg !== 'EdDSA')
|
|
167118
|
-
return null;
|
|
167119
|
-
// Verify signature
|
|
167120
|
-
const data = `${headerB64}.${payloadB64}`;
|
|
167121
|
-
const signature = Buffer.from(signatureB64, 'base64url');
|
|
167122
|
-
const publicKey = crypto.createPublicKey(LicenseValidator.PUBLIC_KEY);
|
|
167123
|
-
// Validate that the loaded public key is actually Ed25519 (OID 1.3.101.112).
|
|
167124
|
-
// This prevents algorithm-confusion attacks if the embedded key were ever
|
|
167125
|
-
// swapped to a different type.
|
|
167126
|
-
if (publicKey.asymmetricKeyType !== 'ed25519') {
|
|
167127
|
-
return null;
|
|
167128
|
-
}
|
|
167129
|
-
// Ed25519 verification: algorithm must be null because EdDSA performs its
|
|
167130
|
-
// own internal hashing (SHA-512) — passing a digest algorithm here would
|
|
167131
|
-
// cause Node.js to throw. The key type is validated above.
|
|
167132
|
-
const isValid = crypto.verify(null, Buffer.from(data), publicKey, signature);
|
|
167133
|
-
if (!isValid)
|
|
167134
|
-
return null;
|
|
167135
|
-
// Decode payload
|
|
167136
|
-
const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
|
|
167137
|
-
// Validate required fields
|
|
167138
|
-
if (!payload.org ||
|
|
167139
|
-
!Array.isArray(payload.features) ||
|
|
167140
|
-
typeof payload.exp !== 'number' ||
|
|
167141
|
-
typeof payload.iat !== 'number' ||
|
|
167142
|
-
!payload.sub) {
|
|
167143
|
-
return null;
|
|
167144
|
-
}
|
|
167145
|
-
// Check expiry (with grace period)
|
|
167146
|
-
const now = Date.now();
|
|
167147
|
-
const expiryMs = payload.exp * 1000;
|
|
167148
|
-
if (now >= expiryMs + LicenseValidator.GRACE_PERIOD) {
|
|
167149
|
-
return null;
|
|
167150
|
-
}
|
|
167151
|
-
return payload;
|
|
167152
|
-
}
|
|
167153
|
-
catch {
|
|
167154
|
-
return null;
|
|
167155
|
-
}
|
|
167156
|
-
}
|
|
167157
|
-
}
|
|
167158
|
-
exports.LicenseValidator = LicenseValidator;
|
|
167159
|
-
|
|
167160
|
-
|
|
167161
|
-
/***/ }),
|
|
167162
|
-
|
|
167163
|
-
/***/ 87068:
|
|
167164
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
167165
|
-
|
|
167166
|
-
"use strict";
|
|
167167
|
-
|
|
167168
|
-
/**
|
|
167169
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
167170
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
167171
|
-
* in compliance with the Elastic License 2.0.
|
|
167172
|
-
*/
|
|
167173
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
167174
|
-
if (k2 === undefined) k2 = k;
|
|
167175
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
167176
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
167177
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
167178
|
-
}
|
|
167179
|
-
Object.defineProperty(o, k2, desc);
|
|
167180
|
-
}) : (function(o, m, k, k2) {
|
|
167181
|
-
if (k2 === undefined) k2 = k;
|
|
167182
|
-
o[k2] = m[k];
|
|
167183
|
-
}));
|
|
167184
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
167185
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
167186
|
-
}) : function(o, v) {
|
|
167187
|
-
o["default"] = v;
|
|
167188
|
-
});
|
|
167189
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
167190
|
-
var ownKeys = function(o) {
|
|
167191
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
167192
|
-
var ar = [];
|
|
167193
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
167194
|
-
return ar;
|
|
167195
|
-
};
|
|
167196
|
-
return ownKeys(o);
|
|
167197
|
-
};
|
|
167198
|
-
return function (mod) {
|
|
167199
|
-
if (mod && mod.__esModule) return mod;
|
|
167200
|
-
var result = {};
|
|
167201
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
167202
|
-
__setModuleDefault(result, mod);
|
|
167203
|
-
return result;
|
|
167204
|
-
};
|
|
167205
|
-
})();
|
|
167206
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167207
|
-
exports.loadEnterprisePolicyEngine = loadEnterprisePolicyEngine;
|
|
167208
|
-
exports.loadEnterpriseStoreBackend = loadEnterpriseStoreBackend;
|
|
167209
|
-
const default_engine_1 = __nccwpck_require__(93866);
|
|
167210
|
-
/**
|
|
167211
|
-
* Load the enterprise policy engine if licensed, otherwise return the default no-op engine.
|
|
167212
|
-
*
|
|
167213
|
-
* This is the sole import boundary between OSS and enterprise code. Core code
|
|
167214
|
-
* must only import from this module (via dynamic `await import()`), never from
|
|
167215
|
-
* individual enterprise submodules.
|
|
167216
|
-
*/
|
|
167217
|
-
async function loadEnterprisePolicyEngine(config) {
|
|
167218
|
-
try {
|
|
167219
|
-
const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
|
|
167220
|
-
const validator = new LicenseValidator();
|
|
167221
|
-
const license = await validator.loadAndValidate();
|
|
167222
|
-
if (!license || !validator.hasFeature('policy')) {
|
|
167223
|
-
return new default_engine_1.DefaultPolicyEngine();
|
|
167224
|
-
}
|
|
167225
|
-
if (validator.isInGracePeriod()) {
|
|
167226
|
-
// eslint-disable-next-line no-console
|
|
167227
|
-
console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
|
|
167228
|
-
'Please renew your license.');
|
|
167229
|
-
}
|
|
167230
|
-
const { OpaPolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(39530)));
|
|
167231
|
-
const engine = new OpaPolicyEngine(config);
|
|
167232
|
-
await engine.initialize(config);
|
|
167233
|
-
return engine;
|
|
167234
|
-
}
|
|
167235
|
-
catch (err) {
|
|
167236
|
-
// Enterprise code not available or initialization failed
|
|
167237
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
167238
|
-
try {
|
|
167239
|
-
const { logger } = __nccwpck_require__(86999);
|
|
167240
|
-
logger.warn(`[PolicyEngine] Enterprise policy init failed, falling back to default: ${msg}`);
|
|
167241
|
-
}
|
|
167242
|
-
catch {
|
|
167243
|
-
// silent
|
|
167244
|
-
}
|
|
167245
|
-
return new default_engine_1.DefaultPolicyEngine();
|
|
167246
|
-
}
|
|
167247
|
-
}
|
|
167248
|
-
/**
|
|
167249
|
-
* Load the enterprise schedule store backend if licensed.
|
|
167250
|
-
*
|
|
167251
|
-
* @param driver Database driver ('postgresql', 'mysql', or 'mssql')
|
|
167252
|
-
* @param storageConfig Storage configuration with connection details
|
|
167253
|
-
* @param haConfig Optional HA configuration
|
|
167254
|
-
* @throws Error if enterprise license is not available or missing 'scheduler-sql' feature
|
|
167255
|
-
*/
|
|
167256
|
-
async function loadEnterpriseStoreBackend(driver, storageConfig, haConfig) {
|
|
167257
|
-
const { LicenseValidator } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(50069)));
|
|
167258
|
-
const validator = new LicenseValidator();
|
|
167259
|
-
const license = await validator.loadAndValidate();
|
|
167260
|
-
if (!license || !validator.hasFeature('scheduler-sql')) {
|
|
167261
|
-
throw new Error(`The ${driver} schedule storage driver requires a Visor Enterprise license ` +
|
|
167262
|
-
`with the 'scheduler-sql' feature. Please upgrade or use driver: 'sqlite' (default).`);
|
|
167263
|
-
}
|
|
167264
|
-
if (validator.isInGracePeriod()) {
|
|
167265
|
-
// eslint-disable-next-line no-console
|
|
167266
|
-
console.warn('[visor:enterprise] License has expired but is within the 72-hour grace period. ' +
|
|
167267
|
-
'Please renew your license.');
|
|
167268
|
-
}
|
|
167269
|
-
const { KnexStoreBackend } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(63737)));
|
|
167270
|
-
return new KnexStoreBackend(driver, storageConfig, haConfig);
|
|
167271
|
-
}
|
|
167272
|
-
|
|
167273
|
-
|
|
167274
|
-
/***/ }),
|
|
167275
|
-
|
|
167276
|
-
/***/ 628:
|
|
167277
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
167278
|
-
|
|
167279
|
-
"use strict";
|
|
167280
|
-
|
|
167281
|
-
/**
|
|
167282
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
167283
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
167284
|
-
* in compliance with the Elastic License 2.0.
|
|
167285
|
-
*/
|
|
167286
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
167287
|
-
if (k2 === undefined) k2 = k;
|
|
167288
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
167289
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
167290
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
167291
|
-
}
|
|
167292
|
-
Object.defineProperty(o, k2, desc);
|
|
167293
|
-
}) : (function(o, m, k, k2) {
|
|
167294
|
-
if (k2 === undefined) k2 = k;
|
|
167295
|
-
o[k2] = m[k];
|
|
167296
|
-
}));
|
|
167297
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
167298
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
167299
|
-
}) : function(o, v) {
|
|
167300
|
-
o["default"] = v;
|
|
167301
|
-
});
|
|
167302
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
167303
|
-
var ownKeys = function(o) {
|
|
167304
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
167305
|
-
var ar = [];
|
|
167306
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
167307
|
-
return ar;
|
|
167308
|
-
};
|
|
167309
|
-
return ownKeys(o);
|
|
167310
|
-
};
|
|
167311
|
-
return function (mod) {
|
|
167312
|
-
if (mod && mod.__esModule) return mod;
|
|
167313
|
-
var result = {};
|
|
167314
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
167315
|
-
__setModuleDefault(result, mod);
|
|
167316
|
-
return result;
|
|
167317
|
-
};
|
|
167318
|
-
})();
|
|
167319
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167320
|
-
exports.OpaCompiler = void 0;
|
|
167321
|
-
const fs = __importStar(__nccwpck_require__(79896));
|
|
167322
|
-
const path = __importStar(__nccwpck_require__(16928));
|
|
167323
|
-
const os = __importStar(__nccwpck_require__(70857));
|
|
167324
|
-
const crypto = __importStar(__nccwpck_require__(76982));
|
|
167325
|
-
const child_process_1 = __nccwpck_require__(35317);
|
|
167326
|
-
/**
|
|
167327
|
-
* OPA Rego Compiler - compiles .rego policy files to WASM bundles using the `opa` CLI.
|
|
167328
|
-
*
|
|
167329
|
-
* Handles:
|
|
167330
|
-
* - Resolving input paths to WASM bytes (direct .wasm, directory with policy.wasm, or .rego files)
|
|
167331
|
-
* - Compiling .rego files to WASM via `opa build`
|
|
167332
|
-
* - Caching compiled bundles based on content hashes
|
|
167333
|
-
* - Extracting policy.wasm from OPA tar.gz bundles
|
|
167334
|
-
*
|
|
167335
|
-
* Requires:
|
|
167336
|
-
* - `opa` CLI on PATH (only when auto-compiling .rego files)
|
|
167337
|
-
*/
|
|
167338
|
-
class OpaCompiler {
|
|
167339
|
-
static CACHE_DIR = path.join(os.tmpdir(), 'visor-opa-cache');
|
|
167340
|
-
/**
|
|
167341
|
-
* Resolve the input paths to WASM bytes.
|
|
167342
|
-
*
|
|
167343
|
-
* Strategy:
|
|
167344
|
-
* 1. If any path is a .wasm file, read it directly
|
|
167345
|
-
* 2. If a directory contains policy.wasm, read it
|
|
167346
|
-
* 3. Otherwise, collect all .rego files and auto-compile via `opa build`
|
|
167347
|
-
*/
|
|
167348
|
-
async resolveWasmBytes(paths) {
|
|
167349
|
-
// Collect .rego files and check for existing .wasm
|
|
167350
|
-
const regoFiles = [];
|
|
167351
|
-
for (const p of paths) {
|
|
167352
|
-
const resolved = path.resolve(p);
|
|
167353
|
-
// Reject paths containing '..' after resolution (path traversal)
|
|
167354
|
-
if (path.normalize(resolved).includes('..')) {
|
|
167355
|
-
throw new Error(`Policy path contains traversal sequences: ${p}`);
|
|
167356
|
-
}
|
|
167357
|
-
// Direct .wasm file
|
|
167358
|
-
if (resolved.endsWith('.wasm') && fs.existsSync(resolved)) {
|
|
167359
|
-
return fs.readFileSync(resolved);
|
|
167360
|
-
}
|
|
167361
|
-
if (!fs.existsSync(resolved))
|
|
167362
|
-
continue;
|
|
167363
|
-
const stat = fs.statSync(resolved);
|
|
167364
|
-
if (stat.isDirectory()) {
|
|
167365
|
-
// Check for pre-compiled policy.wasm in directory
|
|
167366
|
-
const wasmCandidate = path.join(resolved, 'policy.wasm');
|
|
167367
|
-
if (fs.existsSync(wasmCandidate)) {
|
|
167368
|
-
return fs.readFileSync(wasmCandidate);
|
|
167369
|
-
}
|
|
167370
|
-
// Collect all .rego files from directory
|
|
167371
|
-
const files = fs.readdirSync(resolved);
|
|
167372
|
-
for (const f of files) {
|
|
167373
|
-
if (f.endsWith('.rego')) {
|
|
167374
|
-
regoFiles.push(path.join(resolved, f));
|
|
167375
|
-
}
|
|
167376
|
-
}
|
|
167377
|
-
}
|
|
167378
|
-
else if (resolved.endsWith('.rego')) {
|
|
167379
|
-
regoFiles.push(resolved);
|
|
167380
|
-
}
|
|
167381
|
-
}
|
|
167382
|
-
if (regoFiles.length === 0) {
|
|
167383
|
-
throw new Error(`OPA WASM evaluator: no .wasm bundle or .rego files found in: ${paths.join(', ')}`);
|
|
167384
|
-
}
|
|
167385
|
-
// Auto-compile .rego -> .wasm
|
|
167386
|
-
return this.compileRego(regoFiles);
|
|
167387
|
-
}
|
|
167388
|
-
/**
|
|
167389
|
-
* Auto-compile .rego files to a WASM bundle using the `opa` CLI.
|
|
167390
|
-
*
|
|
167391
|
-
* Caches the compiled bundle based on a content hash of all input .rego files
|
|
167392
|
-
* so subsequent runs skip compilation if policies haven't changed.
|
|
167393
|
-
*/
|
|
167394
|
-
compileRego(regoFiles) {
|
|
167395
|
-
// Check that `opa` CLI is available
|
|
167396
|
-
try {
|
|
167397
|
-
(0, child_process_1.execFileSync)('opa', ['version'], { stdio: 'pipe' });
|
|
167398
|
-
}
|
|
167399
|
-
catch {
|
|
167400
|
-
throw new Error('OPA CLI (`opa`) not found on PATH. Install it from https://www.openpolicyagent.org/docs/latest/#running-opa\n' +
|
|
167401
|
-
'Or pre-compile your .rego files: opa build -t wasm -e visor -o bundle.tar.gz ' +
|
|
167402
|
-
regoFiles.join(' '));
|
|
167403
|
-
}
|
|
167404
|
-
// Compute content hash for cache key
|
|
167405
|
-
const hash = crypto.createHash('sha256');
|
|
167406
|
-
for (const f of regoFiles.sort()) {
|
|
167407
|
-
hash.update(fs.readFileSync(f));
|
|
167408
|
-
hash.update(f); // include filename for disambiguation
|
|
167409
|
-
}
|
|
167410
|
-
const cacheKey = hash.digest('hex').slice(0, 16);
|
|
167411
|
-
const cacheDir = OpaCompiler.CACHE_DIR;
|
|
167412
|
-
const cachedWasm = path.join(cacheDir, `${cacheKey}.wasm`);
|
|
167413
|
-
// Return cached bundle if still valid
|
|
167414
|
-
if (fs.existsSync(cachedWasm)) {
|
|
167415
|
-
return fs.readFileSync(cachedWasm);
|
|
167416
|
-
}
|
|
167417
|
-
// Compile to WASM via opa build
|
|
167418
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
167419
|
-
const bundleTar = path.join(cacheDir, `${cacheKey}-bundle.tar.gz`);
|
|
167420
|
-
try {
|
|
167421
|
-
const args = [
|
|
167422
|
-
'build',
|
|
167423
|
-
'-t',
|
|
167424
|
-
'wasm',
|
|
167425
|
-
'-e',
|
|
167426
|
-
'visor', // entrypoint: the visor package tree
|
|
167427
|
-
'-o',
|
|
167428
|
-
bundleTar,
|
|
167429
|
-
...regoFiles,
|
|
167430
|
-
];
|
|
167431
|
-
(0, child_process_1.execFileSync)('opa', args, {
|
|
167432
|
-
stdio: 'pipe',
|
|
167433
|
-
timeout: 30000,
|
|
167434
|
-
});
|
|
167435
|
-
}
|
|
167436
|
-
catch (err) {
|
|
167437
|
-
const stderr = err?.stderr?.toString() || '';
|
|
167438
|
-
throw new Error(`Failed to compile .rego files to WASM:\n${stderr}\n` +
|
|
167439
|
-
'Ensure your .rego files are valid and the `opa` CLI is installed.');
|
|
167440
|
-
}
|
|
167441
|
-
// Extract policy.wasm from the tar.gz bundle
|
|
167442
|
-
// OPA bundles are tar.gz with /policy.wasm inside
|
|
167443
|
-
try {
|
|
167444
|
-
(0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, '/policy.wasm'], {
|
|
167445
|
-
stdio: 'pipe',
|
|
167446
|
-
});
|
|
167447
|
-
const extractedWasm = path.join(cacheDir, 'policy.wasm');
|
|
167448
|
-
if (fs.existsSync(extractedWasm)) {
|
|
167449
|
-
// Move to cache-key named file
|
|
167450
|
-
fs.renameSync(extractedWasm, cachedWasm);
|
|
167451
|
-
}
|
|
167452
|
-
}
|
|
167453
|
-
catch {
|
|
167454
|
-
// Some tar implementations don't like leading /
|
|
167455
|
-
try {
|
|
167456
|
-
(0, child_process_1.execFileSync)('tar', ['-xzf', bundleTar, '-C', cacheDir, 'policy.wasm'], {
|
|
167457
|
-
stdio: 'pipe',
|
|
167458
|
-
});
|
|
167459
|
-
const extractedWasm = path.join(cacheDir, 'policy.wasm');
|
|
167460
|
-
if (fs.existsSync(extractedWasm)) {
|
|
167461
|
-
fs.renameSync(extractedWasm, cachedWasm);
|
|
167462
|
-
}
|
|
167463
|
-
}
|
|
167464
|
-
catch (err2) {
|
|
167465
|
-
throw new Error(`Failed to extract policy.wasm from OPA bundle: ${err2?.message || err2}`);
|
|
167466
|
-
}
|
|
167467
|
-
}
|
|
167468
|
-
// Clean up tar
|
|
167469
|
-
try {
|
|
167470
|
-
fs.unlinkSync(bundleTar);
|
|
167471
|
-
}
|
|
167472
|
-
catch { }
|
|
167473
|
-
if (!fs.existsSync(cachedWasm)) {
|
|
167474
|
-
throw new Error('OPA build succeeded but policy.wasm was not found in the bundle');
|
|
167475
|
-
}
|
|
167476
|
-
return fs.readFileSync(cachedWasm);
|
|
167477
|
-
}
|
|
167478
|
-
}
|
|
167479
|
-
exports.OpaCompiler = OpaCompiler;
|
|
167480
|
-
|
|
167481
|
-
|
|
167482
|
-
/***/ }),
|
|
167483
|
-
|
|
167484
|
-
/***/ 44693:
|
|
167485
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
167486
|
-
|
|
167487
|
-
"use strict";
|
|
167488
|
-
|
|
167489
|
-
/**
|
|
167490
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
167491
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
167492
|
-
* in compliance with the Elastic License 2.0.
|
|
167493
|
-
*/
|
|
167494
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167495
|
-
exports.OpaHttpEvaluator = void 0;
|
|
167496
|
-
/**
|
|
167497
|
-
* OPA HTTP Evaluator - evaluates policies via an external OPA server's REST API.
|
|
167498
|
-
*
|
|
167499
|
-
* Uses the built-in `fetch` API (Node 18+), so no extra dependencies are needed.
|
|
167500
|
-
*/
|
|
167501
|
-
class OpaHttpEvaluator {
|
|
167502
|
-
baseUrl;
|
|
167503
|
-
timeout;
|
|
167504
|
-
constructor(baseUrl, timeout = 5000) {
|
|
167505
|
-
// Validate URL format and protocol
|
|
167506
|
-
let parsed;
|
|
167507
|
-
try {
|
|
167508
|
-
parsed = new URL(baseUrl);
|
|
167509
|
-
}
|
|
167510
|
-
catch {
|
|
167511
|
-
throw new Error(`OPA HTTP evaluator: invalid URL: ${baseUrl}`);
|
|
167512
|
-
}
|
|
167513
|
-
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
|
167514
|
-
throw new Error(`OPA HTTP evaluator: url must use http:// or https:// protocol, got: ${baseUrl}`);
|
|
167515
|
-
}
|
|
167516
|
-
// Block cloud metadata, loopback, link-local, and private network addresses
|
|
167517
|
-
const hostname = parsed.hostname;
|
|
167518
|
-
if (this.isBlockedHostname(hostname)) {
|
|
167519
|
-
throw new Error(`OPA HTTP evaluator: url must not point to internal, loopback, or private network addresses`);
|
|
167520
|
-
}
|
|
167521
|
-
// Normalize: strip trailing slash
|
|
167522
|
-
this.baseUrl = baseUrl.replace(/\/+$/, '');
|
|
167523
|
-
this.timeout = timeout;
|
|
167524
|
-
}
|
|
167525
|
-
/**
|
|
167526
|
-
* Check if a hostname is blocked due to SSRF concerns.
|
|
167527
|
-
*
|
|
167528
|
-
* Blocks:
|
|
167529
|
-
* - Loopback addresses (127.x.x.x, localhost, 0.0.0.0, ::1)
|
|
167530
|
-
* - Link-local addresses (169.254.x.x)
|
|
167531
|
-
* - Private networks (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
|
|
167532
|
-
* - IPv6 unique local addresses (fd00::/8)
|
|
167533
|
-
* - Cloud metadata services (*.internal)
|
|
167534
|
-
*/
|
|
167535
|
-
isBlockedHostname(hostname) {
|
|
167536
|
-
if (!hostname)
|
|
167537
|
-
return true; // block empty hostnames
|
|
167538
|
-
// Normalize hostname: lowercase and remove brackets for IPv6
|
|
167539
|
-
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
167540
|
-
// Block .internal domains (cloud metadata services)
|
|
167541
|
-
if (normalized === 'metadata.google.internal' || normalized.endsWith('.internal')) {
|
|
167542
|
-
return true;
|
|
167543
|
-
}
|
|
167544
|
-
// Block localhost variants
|
|
167545
|
-
if (normalized === 'localhost' || normalized === 'localhost.localdomain') {
|
|
167546
|
-
return true;
|
|
167547
|
-
}
|
|
167548
|
-
// Block IPv6 loopback
|
|
167549
|
-
if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
|
|
167550
|
-
return true;
|
|
167551
|
-
}
|
|
167552
|
-
// Check IPv4 patterns
|
|
167553
|
-
const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
167554
|
-
const ipv4Match = normalized.match(ipv4Pattern);
|
|
167555
|
-
if (ipv4Match) {
|
|
167556
|
-
const octets = ipv4Match.slice(1, 5).map(Number);
|
|
167557
|
-
// Validate octets are in range [0, 255]
|
|
167558
|
-
if (octets.some(octet => octet > 255)) {
|
|
167559
|
-
return false;
|
|
167560
|
-
}
|
|
167561
|
-
const [a, b] = octets;
|
|
167562
|
-
// Block loopback: 127.0.0.0/8
|
|
167563
|
-
if (a === 127) {
|
|
167564
|
-
return true;
|
|
167565
|
-
}
|
|
167566
|
-
// Block 0.0.0.0/8 (this host)
|
|
167567
|
-
if (a === 0) {
|
|
167568
|
-
return true;
|
|
167569
|
-
}
|
|
167570
|
-
// Block link-local: 169.254.0.0/16
|
|
167571
|
-
if (a === 169 && b === 254) {
|
|
167572
|
-
return true;
|
|
167573
|
-
}
|
|
167574
|
-
// Block private networks
|
|
167575
|
-
// 10.0.0.0/8
|
|
167576
|
-
if (a === 10) {
|
|
167577
|
-
return true;
|
|
167578
|
-
}
|
|
167579
|
-
// 172.16.0.0/12 (172.16.x.x through 172.31.x.x)
|
|
167580
|
-
if (a === 172 && b >= 16 && b <= 31) {
|
|
167581
|
-
return true;
|
|
167582
|
-
}
|
|
167583
|
-
// 192.168.0.0/16
|
|
167584
|
-
if (a === 192 && b === 168) {
|
|
167585
|
-
return true;
|
|
167586
|
-
}
|
|
167587
|
-
}
|
|
167588
|
-
// Check IPv6 patterns
|
|
167589
|
-
// Block unique local addresses: fd00::/8
|
|
167590
|
-
if (normalized.startsWith('fd') || normalized.startsWith('fc')) {
|
|
167591
|
-
return true;
|
|
167592
|
-
}
|
|
167593
|
-
// Block link-local: fe80::/10
|
|
167594
|
-
if (normalized.startsWith('fe80:')) {
|
|
167595
|
-
return true;
|
|
167596
|
-
}
|
|
167597
|
-
return false;
|
|
167598
|
-
}
|
|
167599
|
-
/**
|
|
167600
|
-
* Evaluate a policy rule against an input document via OPA REST API.
|
|
167601
|
-
*
|
|
167602
|
-
* @param input - The input document to evaluate
|
|
167603
|
-
* @param rulePath - OPA rule path (e.g., 'visor/check/execute')
|
|
167604
|
-
* @returns The result object from OPA, or undefined on error
|
|
167605
|
-
*/
|
|
167606
|
-
async evaluate(input, rulePath) {
|
|
167607
|
-
// OPA Data API: POST /v1/data/<path>
|
|
167608
|
-
const encodedPath = rulePath
|
|
167609
|
-
.split('/')
|
|
167610
|
-
.map(s => encodeURIComponent(s))
|
|
167611
|
-
.join('/');
|
|
167612
|
-
const url = `${this.baseUrl}/v1/data/${encodedPath}`;
|
|
167613
|
-
const controller = new AbortController();
|
|
167614
|
-
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
167615
|
-
try {
|
|
167616
|
-
const response = await fetch(url, {
|
|
167617
|
-
method: 'POST',
|
|
167618
|
-
headers: { 'Content-Type': 'application/json' },
|
|
167619
|
-
body: JSON.stringify({ input }),
|
|
167620
|
-
signal: controller.signal,
|
|
167621
|
-
});
|
|
167622
|
-
if (!response.ok) {
|
|
167623
|
-
throw new Error(`OPA HTTP ${response.status}: ${response.statusText}`);
|
|
167624
|
-
}
|
|
167625
|
-
let body;
|
|
167626
|
-
try {
|
|
167627
|
-
body = await response.json();
|
|
167628
|
-
}
|
|
167629
|
-
catch (jsonErr) {
|
|
167630
|
-
throw new Error(`OPA HTTP evaluator: failed to parse JSON response: ${jsonErr instanceof Error ? jsonErr.message : String(jsonErr)}`);
|
|
167631
|
-
}
|
|
167632
|
-
// OPA returns { result: { ... } }
|
|
167633
|
-
return body?.result;
|
|
167634
|
-
}
|
|
167635
|
-
finally {
|
|
167636
|
-
clearTimeout(timer);
|
|
167637
|
-
}
|
|
167638
|
-
}
|
|
167639
|
-
async shutdown() {
|
|
167640
|
-
// No persistent connections to close
|
|
167641
|
-
}
|
|
167642
|
-
}
|
|
167643
|
-
exports.OpaHttpEvaluator = OpaHttpEvaluator;
|
|
167644
|
-
|
|
167645
|
-
|
|
167646
|
-
/***/ }),
|
|
167647
|
-
|
|
167648
|
-
/***/ 39530:
|
|
167649
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
167650
|
-
|
|
167651
|
-
"use strict";
|
|
167652
|
-
|
|
167653
|
-
/**
|
|
167654
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
167655
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
167656
|
-
* in compliance with the Elastic License 2.0.
|
|
167657
|
-
*/
|
|
167658
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167659
|
-
exports.OpaPolicyEngine = void 0;
|
|
167660
|
-
const opa_wasm_evaluator_1 = __nccwpck_require__(8613);
|
|
167661
|
-
const opa_http_evaluator_1 = __nccwpck_require__(44693);
|
|
167662
|
-
const policy_input_builder_1 = __nccwpck_require__(17117);
|
|
167663
|
-
/**
|
|
167664
|
-
* Enterprise OPA Policy Engine.
|
|
167665
|
-
*
|
|
167666
|
-
* Wraps both WASM (local) and HTTP (remote) OPA evaluators behind the
|
|
167667
|
-
* OSS PolicyEngine interface. All OPA input building and role resolution
|
|
167668
|
-
* is handled internally — the OSS call sites pass only plain types.
|
|
167669
|
-
*/
|
|
167670
|
-
class OpaPolicyEngine {
|
|
167671
|
-
evaluator = null;
|
|
167672
|
-
fallback;
|
|
167673
|
-
timeout;
|
|
167674
|
-
config;
|
|
167675
|
-
inputBuilder = null;
|
|
167676
|
-
logger = null;
|
|
167677
|
-
constructor(config) {
|
|
167678
|
-
this.config = config;
|
|
167679
|
-
this.fallback = config.fallback || 'deny';
|
|
167680
|
-
this.timeout = config.timeout || 5000;
|
|
167681
|
-
}
|
|
167682
|
-
async initialize(config) {
|
|
167683
|
-
// Resolve logger once at initialization
|
|
167684
|
-
try {
|
|
167685
|
-
this.logger = (__nccwpck_require__(86999).logger);
|
|
167686
|
-
}
|
|
167687
|
-
catch {
|
|
167688
|
-
// logger not available in this context
|
|
167689
|
-
}
|
|
167690
|
-
// Build actor/repo context from environment (available at engine init time)
|
|
167691
|
-
const actor = {
|
|
167692
|
-
authorAssociation: process.env.VISOR_AUTHOR_ASSOCIATION,
|
|
167693
|
-
login: process.env.VISOR_AUTHOR_LOGIN || process.env.GITHUB_ACTOR,
|
|
167694
|
-
isLocalMode: !process.env.GITHUB_ACTIONS,
|
|
167695
|
-
};
|
|
167696
|
-
const repo = {
|
|
167697
|
-
owner: process.env.GITHUB_REPOSITORY_OWNER,
|
|
167698
|
-
name: process.env.GITHUB_REPOSITORY?.split('/')[1],
|
|
167699
|
-
branch: process.env.GITHUB_HEAD_REF,
|
|
167700
|
-
baseBranch: process.env.GITHUB_BASE_REF,
|
|
167701
|
-
event: process.env.GITHUB_EVENT_NAME,
|
|
167702
|
-
};
|
|
167703
|
-
const prNum = process.env.GITHUB_PR_NUMBER
|
|
167704
|
-
? parseInt(process.env.GITHUB_PR_NUMBER, 10)
|
|
167705
|
-
: undefined;
|
|
167706
|
-
const pullRequest = {
|
|
167707
|
-
number: prNum !== undefined && Number.isFinite(prNum) ? prNum : undefined,
|
|
167708
|
-
};
|
|
167709
|
-
this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(config, actor, repo, pullRequest);
|
|
167710
|
-
if (config.engine === 'local') {
|
|
167711
|
-
if (!config.rules) {
|
|
167712
|
-
throw new Error('OPA local mode requires `policy.rules` path to .wasm or .rego files');
|
|
167713
|
-
}
|
|
167714
|
-
const wasm = new opa_wasm_evaluator_1.OpaWasmEvaluator();
|
|
167715
|
-
await wasm.initialize(config.rules);
|
|
167716
|
-
if (config.data) {
|
|
167717
|
-
wasm.loadData(config.data);
|
|
167718
|
-
}
|
|
167719
|
-
this.evaluator = wasm;
|
|
167720
|
-
}
|
|
167721
|
-
else if (config.engine === 'remote') {
|
|
167722
|
-
if (!config.url) {
|
|
167723
|
-
throw new Error('OPA remote mode requires `policy.url` pointing to OPA server');
|
|
167724
|
-
}
|
|
167725
|
-
this.evaluator = new opa_http_evaluator_1.OpaHttpEvaluator(config.url, this.timeout);
|
|
167726
|
-
}
|
|
167727
|
-
else {
|
|
167728
|
-
this.evaluator = null;
|
|
167729
|
-
}
|
|
167730
|
-
}
|
|
167731
|
-
/**
|
|
167732
|
-
* Update actor/repo/PR context (e.g., after PR info becomes available).
|
|
167733
|
-
* Called by the enterprise loader when engine context is enriched.
|
|
167734
|
-
*/
|
|
167735
|
-
setActorContext(actor, repo, pullRequest) {
|
|
167736
|
-
this.inputBuilder = new policy_input_builder_1.PolicyInputBuilder(this.config, actor, repo, pullRequest);
|
|
167737
|
-
}
|
|
167738
|
-
async evaluateCheckExecution(checkId, checkConfig) {
|
|
167739
|
-
if (!this.evaluator || !this.inputBuilder)
|
|
167740
|
-
return { allowed: true };
|
|
167741
|
-
const cfg = checkConfig && typeof checkConfig === 'object'
|
|
167742
|
-
? checkConfig
|
|
167743
|
-
: {};
|
|
167744
|
-
const policyOverride = cfg.policy;
|
|
167745
|
-
const input = this.inputBuilder.forCheckExecution({
|
|
167746
|
-
id: checkId,
|
|
167747
|
-
type: cfg.type || 'ai',
|
|
167748
|
-
group: cfg.group,
|
|
167749
|
-
tags: cfg.tags,
|
|
167750
|
-
criticality: cfg.criticality,
|
|
167751
|
-
sandbox: cfg.sandbox,
|
|
167752
|
-
policy: policyOverride,
|
|
167753
|
-
});
|
|
167754
|
-
return this.doEvaluate(input, this.resolveRulePath('check.execute', policyOverride?.rule));
|
|
167755
|
-
}
|
|
167756
|
-
async evaluateToolInvocation(serverName, methodName, transport) {
|
|
167757
|
-
if (!this.evaluator || !this.inputBuilder)
|
|
167758
|
-
return { allowed: true };
|
|
167759
|
-
const input = this.inputBuilder.forToolInvocation(serverName, methodName, transport);
|
|
167760
|
-
return this.doEvaluate(input, 'visor/tool/invoke');
|
|
167761
|
-
}
|
|
167762
|
-
async evaluateCapabilities(checkId, capabilities) {
|
|
167763
|
-
if (!this.evaluator || !this.inputBuilder)
|
|
167764
|
-
return { allowed: true };
|
|
167765
|
-
const input = this.inputBuilder.forCapabilityResolve(checkId, capabilities);
|
|
167766
|
-
return this.doEvaluate(input, 'visor/capability/resolve');
|
|
167767
|
-
}
|
|
167768
|
-
async shutdown() {
|
|
167769
|
-
if (this.evaluator && 'shutdown' in this.evaluator) {
|
|
167770
|
-
await this.evaluator.shutdown();
|
|
167771
|
-
}
|
|
167772
|
-
this.evaluator = null;
|
|
167773
|
-
this.inputBuilder = null;
|
|
167774
|
-
}
|
|
167775
|
-
resolveRulePath(defaultScope, override) {
|
|
167776
|
-
if (override) {
|
|
167777
|
-
return override.startsWith('visor/') ? override : `visor/${override}`;
|
|
167778
|
-
}
|
|
167779
|
-
return `visor/${defaultScope.replace(/\./g, '/')}`;
|
|
167780
|
-
}
|
|
167781
|
-
async doEvaluate(input, rulePath) {
|
|
167782
|
-
try {
|
|
167783
|
-
this.logger?.debug(`[PolicyEngine] Evaluating ${rulePath}`, JSON.stringify(input));
|
|
167784
|
-
let timer;
|
|
167785
|
-
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
167786
|
-
timer = setTimeout(() => reject(new Error('policy evaluation timeout')), this.timeout);
|
|
167787
|
-
});
|
|
167788
|
-
try {
|
|
167789
|
-
const result = await Promise.race([this.rawEvaluate(input, rulePath), timeoutPromise]);
|
|
167790
|
-
const decision = this.parseDecision(result);
|
|
167791
|
-
// In warn mode, override denied decisions to allowed but flag as warn
|
|
167792
|
-
if (!decision.allowed && this.fallback === 'warn') {
|
|
167793
|
-
decision.allowed = true;
|
|
167794
|
-
decision.warn = true;
|
|
167795
|
-
decision.reason = `audit: ${decision.reason || 'policy denied'}`;
|
|
167796
|
-
}
|
|
167797
|
-
this.logger?.debug(`[PolicyEngine] Decision for ${rulePath}: allowed=${decision.allowed}, warn=${decision.warn || false}, reason=${decision.reason || 'none'}`);
|
|
167798
|
-
return decision;
|
|
167799
|
-
}
|
|
167800
|
-
finally {
|
|
167801
|
-
if (timer)
|
|
167802
|
-
clearTimeout(timer);
|
|
167803
|
-
}
|
|
167804
|
-
}
|
|
167805
|
-
catch (err) {
|
|
167806
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
167807
|
-
this.logger?.warn(`[PolicyEngine] Evaluation failed for ${rulePath}: ${msg}`);
|
|
167808
|
-
return {
|
|
167809
|
-
allowed: this.fallback === 'allow' || this.fallback === 'warn',
|
|
167810
|
-
warn: this.fallback === 'warn' ? true : undefined,
|
|
167811
|
-
reason: `policy evaluation failed, fallback=${this.fallback}`,
|
|
167812
|
-
};
|
|
167813
|
-
}
|
|
167814
|
-
}
|
|
167815
|
-
async rawEvaluate(input, rulePath) {
|
|
167816
|
-
if (this.evaluator instanceof opa_wasm_evaluator_1.OpaWasmEvaluator) {
|
|
167817
|
-
const result = await this.evaluator.evaluate(input);
|
|
167818
|
-
// WASM compiled with `-e visor` entrypoint returns the full visor package tree.
|
|
167819
|
-
// Navigate to the specific rule subtree using rulePath segments.
|
|
167820
|
-
// e.g., 'visor/check/execute' → result.check.execute
|
|
167821
|
-
return this.navigateWasmResult(result, rulePath);
|
|
167822
|
-
}
|
|
167823
|
-
return this.evaluator.evaluate(input, rulePath);
|
|
167824
|
-
}
|
|
167825
|
-
/**
|
|
167826
|
-
* Navigate nested OPA WASM result tree to reach the specific rule's output.
|
|
167827
|
-
* The WASM entrypoint `-e visor` means the result root IS the visor package,
|
|
167828
|
-
* so we strip the `visor/` prefix and walk the remaining segments.
|
|
167829
|
-
*/
|
|
167830
|
-
navigateWasmResult(result, rulePath) {
|
|
167831
|
-
if (!result || typeof result !== 'object')
|
|
167832
|
-
return result;
|
|
167833
|
-
// Strip the 'visor/' prefix (matches our compilation entrypoint)
|
|
167834
|
-
const segments = rulePath.replace(/^visor\//, '').split('/');
|
|
167835
|
-
let current = result;
|
|
167836
|
-
for (const seg of segments) {
|
|
167837
|
-
if (current && typeof current === 'object' && seg in current) {
|
|
167838
|
-
current = current[seg];
|
|
167839
|
-
}
|
|
167840
|
-
else {
|
|
167841
|
-
return undefined; // path not found in result tree
|
|
167842
|
-
}
|
|
167843
|
-
}
|
|
167844
|
-
return current;
|
|
167845
|
-
}
|
|
167846
|
-
parseDecision(result) {
|
|
167847
|
-
if (result === undefined || result === null) {
|
|
167848
|
-
return {
|
|
167849
|
-
allowed: this.fallback === 'allow' || this.fallback === 'warn',
|
|
167850
|
-
warn: this.fallback === 'warn' ? true : undefined,
|
|
167851
|
-
reason: this.fallback === 'warn' ? 'audit: no policy result' : 'no policy result',
|
|
167852
|
-
};
|
|
167853
|
-
}
|
|
167854
|
-
const allowed = result.allowed !== false;
|
|
167855
|
-
const decision = {
|
|
167856
|
-
allowed,
|
|
167857
|
-
reason: result.reason,
|
|
167858
|
-
};
|
|
167859
|
-
if (result.capabilities) {
|
|
167860
|
-
decision.capabilities = result.capabilities;
|
|
167861
|
-
}
|
|
167862
|
-
return decision;
|
|
167863
|
-
}
|
|
167864
|
-
}
|
|
167865
|
-
exports.OpaPolicyEngine = OpaPolicyEngine;
|
|
167866
|
-
|
|
167867
|
-
|
|
167868
|
-
/***/ }),
|
|
167869
|
-
|
|
167870
|
-
/***/ 8613:
|
|
167871
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
167872
|
-
|
|
167873
|
-
"use strict";
|
|
167874
|
-
|
|
167875
|
-
/**
|
|
167876
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
167877
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
167878
|
-
* in compliance with the Elastic License 2.0.
|
|
167879
|
-
*/
|
|
167880
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
167881
|
-
if (k2 === undefined) k2 = k;
|
|
167882
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
167883
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
167884
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
167885
|
-
}
|
|
167886
|
-
Object.defineProperty(o, k2, desc);
|
|
167887
|
-
}) : (function(o, m, k, k2) {
|
|
167888
|
-
if (k2 === undefined) k2 = k;
|
|
167889
|
-
o[k2] = m[k];
|
|
167890
|
-
}));
|
|
167891
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
167892
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
167893
|
-
}) : function(o, v) {
|
|
167894
|
-
o["default"] = v;
|
|
167895
|
-
});
|
|
167896
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
167897
|
-
var ownKeys = function(o) {
|
|
167898
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
167899
|
-
var ar = [];
|
|
167900
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
167901
|
-
return ar;
|
|
167902
|
-
};
|
|
167903
|
-
return ownKeys(o);
|
|
167904
|
-
};
|
|
167905
|
-
return function (mod) {
|
|
167906
|
-
if (mod && mod.__esModule) return mod;
|
|
167907
|
-
var result = {};
|
|
167908
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
167909
|
-
__setModuleDefault(result, mod);
|
|
167910
|
-
return result;
|
|
167911
|
-
};
|
|
167912
|
-
})();
|
|
167913
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
167914
|
-
exports.OpaWasmEvaluator = void 0;
|
|
167915
|
-
const fs = __importStar(__nccwpck_require__(79896));
|
|
167916
|
-
const path = __importStar(__nccwpck_require__(16928));
|
|
167917
|
-
const opa_compiler_1 = __nccwpck_require__(628);
|
|
167918
|
-
/**
|
|
167919
|
-
* OPA WASM Evaluator - loads and evaluates OPA policies locally.
|
|
167920
|
-
*
|
|
167921
|
-
* Supports three input formats:
|
|
167922
|
-
* 1. Pre-compiled `.wasm` bundle — loaded directly (fastest startup)
|
|
167923
|
-
* 2. `.rego` files or directory — auto-compiled to WASM via `opa build` CLI
|
|
167924
|
-
* 3. Directory with `policy.wasm` inside — loaded directly
|
|
167925
|
-
*
|
|
167926
|
-
* Compilation and caching of .rego files is delegated to {@link OpaCompiler}.
|
|
167927
|
-
*
|
|
167928
|
-
* Requires:
|
|
167929
|
-
* - `@open-policy-agent/opa-wasm` npm package (optional dep)
|
|
167930
|
-
* - `opa` CLI on PATH (only when auto-compiling .rego files)
|
|
167931
|
-
*/
|
|
167932
|
-
class OpaWasmEvaluator {
|
|
167933
|
-
policy = null;
|
|
167934
|
-
dataDocument = {};
|
|
167935
|
-
compiler = new opa_compiler_1.OpaCompiler();
|
|
167936
|
-
async initialize(rulesPath) {
|
|
167937
|
-
const paths = Array.isArray(rulesPath) ? rulesPath : [rulesPath];
|
|
167938
|
-
const wasmBytes = await this.compiler.resolveWasmBytes(paths);
|
|
167939
|
-
try {
|
|
167940
|
-
// Use createRequire to load the optional dep at runtime without ncc bundling it.
|
|
167941
|
-
// `new Function('id', 'return require(id)')` fails in ncc bundles because
|
|
167942
|
-
// `require` is not in the `new Function` scope. `createRequire` works correctly
|
|
167943
|
-
// because it creates a real Node.js require rooted at the given path.
|
|
167944
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
167945
|
-
const { createRequire } = __nccwpck_require__(73339);
|
|
167946
|
-
const runtimeRequire = createRequire(__filename);
|
|
167947
|
-
const opaWasm = runtimeRequire('@open-policy-agent/opa-wasm');
|
|
167948
|
-
const loadPolicy = opaWasm.loadPolicy || opaWasm.default?.loadPolicy;
|
|
167949
|
-
if (!loadPolicy) {
|
|
167950
|
-
throw new Error('loadPolicy not found in @open-policy-agent/opa-wasm');
|
|
167951
|
-
}
|
|
167952
|
-
this.policy = await loadPolicy(wasmBytes);
|
|
167953
|
-
}
|
|
167954
|
-
catch (err) {
|
|
167955
|
-
if (err?.code === 'MODULE_NOT_FOUND' || err?.code === 'ERR_MODULE_NOT_FOUND') {
|
|
167956
|
-
throw new Error('OPA WASM evaluator requires @open-policy-agent/opa-wasm. ' +
|
|
167957
|
-
'Install it with: npm install @open-policy-agent/opa-wasm');
|
|
167958
|
-
}
|
|
167959
|
-
throw err;
|
|
167960
|
-
}
|
|
167961
|
-
}
|
|
167962
|
-
/**
|
|
167963
|
-
* Load external data from a JSON file to use as the OPA data document.
|
|
167964
|
-
* The loaded data will be passed to `policy.setData()` during evaluation,
|
|
167965
|
-
* making it available in Rego via `data.<key>`.
|
|
167966
|
-
*/
|
|
167967
|
-
loadData(dataPath) {
|
|
167968
|
-
const resolved = path.resolve(dataPath);
|
|
167969
|
-
if (path.normalize(resolved).includes('..')) {
|
|
167970
|
-
throw new Error(`Data path contains traversal sequences: ${dataPath}`);
|
|
167971
|
-
}
|
|
167972
|
-
if (!fs.existsSync(resolved)) {
|
|
167973
|
-
throw new Error(`OPA data file not found: ${resolved}`);
|
|
167974
|
-
}
|
|
167975
|
-
const stat = fs.statSync(resolved);
|
|
167976
|
-
if (stat.size > 10 * 1024 * 1024) {
|
|
167977
|
-
throw new Error(`OPA data file exceeds 10MB limit: ${resolved} (${stat.size} bytes)`);
|
|
167978
|
-
}
|
|
167979
|
-
const raw = fs.readFileSync(resolved, 'utf-8');
|
|
167980
|
-
try {
|
|
167981
|
-
const parsed = JSON.parse(raw);
|
|
167982
|
-
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
167983
|
-
throw new Error('OPA data file must contain a JSON object (not an array or primitive)');
|
|
167984
|
-
}
|
|
167985
|
-
this.dataDocument = parsed;
|
|
167986
|
-
}
|
|
167987
|
-
catch (err) {
|
|
167988
|
-
if (err.message.startsWith('OPA data file must')) {
|
|
167989
|
-
throw err;
|
|
167990
|
-
}
|
|
167991
|
-
throw new Error(`Failed to parse OPA data file ${resolved}: ${err.message}`);
|
|
167992
|
-
}
|
|
167993
|
-
}
|
|
167994
|
-
async evaluate(input) {
|
|
167995
|
-
if (!this.policy) {
|
|
167996
|
-
throw new Error('OPA WASM evaluator not initialized');
|
|
167997
|
-
}
|
|
167998
|
-
this.policy.setData(this.dataDocument);
|
|
167999
|
-
const resultSet = this.policy.evaluate(input);
|
|
168000
|
-
if (Array.isArray(resultSet) && resultSet.length > 0) {
|
|
168001
|
-
return resultSet[0].result;
|
|
168002
|
-
}
|
|
168003
|
-
return undefined;
|
|
168004
|
-
}
|
|
168005
|
-
async shutdown() {
|
|
168006
|
-
if (this.policy) {
|
|
168007
|
-
// opa-wasm policy objects may have a close/free method for WASM cleanup
|
|
168008
|
-
if (typeof this.policy.close === 'function') {
|
|
168009
|
-
try {
|
|
168010
|
-
this.policy.close();
|
|
168011
|
-
}
|
|
168012
|
-
catch { }
|
|
168013
|
-
}
|
|
168014
|
-
else if (typeof this.policy.free === 'function') {
|
|
168015
|
-
try {
|
|
168016
|
-
this.policy.free();
|
|
168017
|
-
}
|
|
168018
|
-
catch { }
|
|
168019
|
-
}
|
|
168020
|
-
}
|
|
168021
|
-
this.policy = null;
|
|
168022
|
-
}
|
|
168023
|
-
}
|
|
168024
|
-
exports.OpaWasmEvaluator = OpaWasmEvaluator;
|
|
168025
|
-
|
|
168026
|
-
|
|
168027
|
-
/***/ }),
|
|
168028
|
-
|
|
168029
|
-
/***/ 17117:
|
|
168030
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
168031
|
-
|
|
168032
|
-
"use strict";
|
|
168033
|
-
|
|
168034
|
-
/**
|
|
168035
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
168036
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
168037
|
-
* in compliance with the Elastic License 2.0.
|
|
168038
|
-
*/
|
|
168039
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168040
|
-
exports.PolicyInputBuilder = void 0;
|
|
168041
|
-
/**
|
|
168042
|
-
* Builds OPA-compatible input documents from engine context.
|
|
168043
|
-
*
|
|
168044
|
-
* Resolves actor roles from the `policy.roles` config section by matching
|
|
168045
|
-
* the actor's authorAssociation and login against role definitions.
|
|
168046
|
-
*/
|
|
168047
|
-
class PolicyInputBuilder {
|
|
168048
|
-
roles;
|
|
168049
|
-
actor;
|
|
168050
|
-
repository;
|
|
168051
|
-
pullRequest;
|
|
168052
|
-
constructor(policyConfig, actor, repository, pullRequest) {
|
|
168053
|
-
this.roles = policyConfig.roles || {};
|
|
168054
|
-
this.actor = actor;
|
|
168055
|
-
this.repository = repository;
|
|
168056
|
-
this.pullRequest = pullRequest;
|
|
168057
|
-
}
|
|
168058
|
-
/** Resolve which roles apply to the current actor. */
|
|
168059
|
-
resolveRoles() {
|
|
168060
|
-
const matched = [];
|
|
168061
|
-
for (const [roleName, roleConfig] of Object.entries(this.roles)) {
|
|
168062
|
-
let identityMatch = false;
|
|
168063
|
-
if (roleConfig.author_association &&
|
|
168064
|
-
this.actor.authorAssociation &&
|
|
168065
|
-
roleConfig.author_association.includes(this.actor.authorAssociation)) {
|
|
168066
|
-
identityMatch = true;
|
|
168067
|
-
}
|
|
168068
|
-
if (!identityMatch &&
|
|
168069
|
-
roleConfig.users &&
|
|
168070
|
-
this.actor.login &&
|
|
168071
|
-
roleConfig.users.includes(this.actor.login)) {
|
|
168072
|
-
identityMatch = true;
|
|
168073
|
-
}
|
|
168074
|
-
// Slack user ID match
|
|
168075
|
-
if (!identityMatch &&
|
|
168076
|
-
roleConfig.slack_users &&
|
|
168077
|
-
this.actor.slack?.userId &&
|
|
168078
|
-
roleConfig.slack_users.includes(this.actor.slack.userId)) {
|
|
168079
|
-
identityMatch = true;
|
|
168080
|
-
}
|
|
168081
|
-
// Email match (case-insensitive)
|
|
168082
|
-
if (!identityMatch && roleConfig.emails && this.actor.slack?.email) {
|
|
168083
|
-
const actorEmail = this.actor.slack.email.toLowerCase();
|
|
168084
|
-
if (roleConfig.emails.some(e => e.toLowerCase() === actorEmail)) {
|
|
168085
|
-
identityMatch = true;
|
|
168086
|
-
}
|
|
168087
|
-
}
|
|
168088
|
-
// Note: teams-based role resolution requires GitHub API access (read:org scope)
|
|
168089
|
-
// and is not yet implemented. If configured, the role will not match via teams.
|
|
168090
|
-
if (!identityMatch)
|
|
168091
|
-
continue;
|
|
168092
|
-
// slack_channels gate: if set, the role only applies when triggered from one of these channels
|
|
168093
|
-
if (roleConfig.slack_channels && roleConfig.slack_channels.length > 0) {
|
|
168094
|
-
if (!this.actor.slack?.channelId ||
|
|
168095
|
-
!roleConfig.slack_channels.includes(this.actor.slack.channelId)) {
|
|
168096
|
-
continue;
|
|
168097
|
-
}
|
|
168098
|
-
}
|
|
168099
|
-
matched.push(roleName);
|
|
168100
|
-
}
|
|
168101
|
-
return matched;
|
|
168102
|
-
}
|
|
168103
|
-
buildActor() {
|
|
168104
|
-
return {
|
|
168105
|
-
authorAssociation: this.actor.authorAssociation,
|
|
168106
|
-
login: this.actor.login,
|
|
168107
|
-
roles: this.resolveRoles(),
|
|
168108
|
-
isLocalMode: this.actor.isLocalMode,
|
|
168109
|
-
...(this.actor.slack && { slack: this.actor.slack }),
|
|
168110
|
-
};
|
|
168111
|
-
}
|
|
168112
|
-
forCheckExecution(check) {
|
|
168113
|
-
return {
|
|
168114
|
-
scope: 'check.execute',
|
|
168115
|
-
check: {
|
|
168116
|
-
id: check.id,
|
|
168117
|
-
type: check.type,
|
|
168118
|
-
group: check.group,
|
|
168119
|
-
tags: check.tags,
|
|
168120
|
-
criticality: check.criticality,
|
|
168121
|
-
sandbox: check.sandbox,
|
|
168122
|
-
policy: check.policy,
|
|
168123
|
-
},
|
|
168124
|
-
actor: this.buildActor(),
|
|
168125
|
-
repository: this.repository,
|
|
168126
|
-
pullRequest: this.pullRequest,
|
|
168127
|
-
};
|
|
168128
|
-
}
|
|
168129
|
-
forToolInvocation(serverName, methodName, transport) {
|
|
168130
|
-
return {
|
|
168131
|
-
scope: 'tool.invoke',
|
|
168132
|
-
tool: { serverName, methodName, transport },
|
|
168133
|
-
actor: this.buildActor(),
|
|
168134
|
-
repository: this.repository,
|
|
168135
|
-
pullRequest: this.pullRequest,
|
|
168136
|
-
};
|
|
168137
|
-
}
|
|
168138
|
-
forCapabilityResolve(checkId, capabilities) {
|
|
168139
|
-
return {
|
|
168140
|
-
scope: 'capability.resolve',
|
|
168141
|
-
check: { id: checkId, type: 'ai' },
|
|
168142
|
-
capability: capabilities,
|
|
168143
|
-
actor: this.buildActor(),
|
|
168144
|
-
repository: this.repository,
|
|
168145
|
-
pullRequest: this.pullRequest,
|
|
168146
|
-
};
|
|
168147
|
-
}
|
|
168148
|
-
}
|
|
168149
|
-
exports.PolicyInputBuilder = PolicyInputBuilder;
|
|
168150
|
-
|
|
168151
|
-
|
|
168152
|
-
/***/ }),
|
|
168153
|
-
|
|
168154
|
-
/***/ 63737:
|
|
168155
|
-
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
168156
|
-
|
|
168157
|
-
"use strict";
|
|
168158
|
-
|
|
168159
|
-
/**
|
|
168160
|
-
* Copyright (c) ProbeLabs. All rights reserved.
|
|
168161
|
-
* Licensed under the Elastic License 2.0; you may not use this file except
|
|
168162
|
-
* in compliance with the Elastic License 2.0.
|
|
168163
|
-
*/
|
|
168164
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
168165
|
-
if (k2 === undefined) k2 = k;
|
|
168166
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
168167
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
168168
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
168169
|
-
}
|
|
168170
|
-
Object.defineProperty(o, k2, desc);
|
|
168171
|
-
}) : (function(o, m, k, k2) {
|
|
168172
|
-
if (k2 === undefined) k2 = k;
|
|
168173
|
-
o[k2] = m[k];
|
|
168174
|
-
}));
|
|
168175
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
168176
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
168177
|
-
}) : function(o, v) {
|
|
168178
|
-
o["default"] = v;
|
|
168179
|
-
});
|
|
168180
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
168181
|
-
var ownKeys = function(o) {
|
|
168182
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
168183
|
-
var ar = [];
|
|
168184
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
168185
|
-
return ar;
|
|
168186
|
-
};
|
|
168187
|
-
return ownKeys(o);
|
|
168188
|
-
};
|
|
168189
|
-
return function (mod) {
|
|
168190
|
-
if (mod && mod.__esModule) return mod;
|
|
168191
|
-
var result = {};
|
|
168192
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
168193
|
-
__setModuleDefault(result, mod);
|
|
168194
|
-
return result;
|
|
168195
|
-
};
|
|
168196
|
-
})();
|
|
168197
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
168198
|
-
exports.KnexStoreBackend = void 0;
|
|
168199
|
-
/**
|
|
168200
|
-
* Knex-backed schedule store for PostgreSQL, MySQL, and MSSQL (Enterprise)
|
|
168201
|
-
*
|
|
168202
|
-
* Uses Knex query builder for database-agnostic SQL. Same schema as SQLite backend
|
|
168203
|
-
* but with real distributed locking via row-level claims (claimed_by/claimed_at/lock_token).
|
|
168204
|
-
*/
|
|
168205
|
-
const fs = __importStar(__nccwpck_require__(79896));
|
|
168206
|
-
const path = __importStar(__nccwpck_require__(16928));
|
|
168207
|
-
const uuid_1 = __nccwpck_require__(31914);
|
|
168208
|
-
const logger_1 = __nccwpck_require__(86999);
|
|
168209
|
-
function toNum(val) {
|
|
168210
|
-
if (val === null || val === undefined)
|
|
168211
|
-
return undefined;
|
|
168212
|
-
return typeof val === 'string' ? parseInt(val, 10) : val;
|
|
168213
|
-
}
|
|
168214
|
-
function safeJsonParse(value) {
|
|
168215
|
-
if (!value)
|
|
168216
|
-
return undefined;
|
|
168217
|
-
try {
|
|
168218
|
-
return JSON.parse(value);
|
|
168219
|
-
}
|
|
168220
|
-
catch {
|
|
168221
|
-
return undefined;
|
|
168222
|
-
}
|
|
168223
|
-
}
|
|
168224
|
-
function fromDbRow(row) {
|
|
168225
|
-
return {
|
|
168226
|
-
id: row.id,
|
|
168227
|
-
creatorId: row.creator_id,
|
|
168228
|
-
creatorContext: row.creator_context ?? undefined,
|
|
168229
|
-
creatorName: row.creator_name ?? undefined,
|
|
168230
|
-
timezone: row.timezone,
|
|
168231
|
-
schedule: row.schedule_expr,
|
|
168232
|
-
runAt: toNum(row.run_at),
|
|
168233
|
-
isRecurring: row.is_recurring === true || row.is_recurring === 1,
|
|
168234
|
-
originalExpression: row.original_expression,
|
|
168235
|
-
workflow: row.workflow ?? undefined,
|
|
168236
|
-
workflowInputs: safeJsonParse(row.workflow_inputs),
|
|
168237
|
-
outputContext: safeJsonParse(row.output_context),
|
|
168238
|
-
status: row.status,
|
|
168239
|
-
createdAt: toNum(row.created_at),
|
|
168240
|
-
lastRunAt: toNum(row.last_run_at),
|
|
168241
|
-
nextRunAt: toNum(row.next_run_at),
|
|
168242
|
-
runCount: row.run_count,
|
|
168243
|
-
failureCount: row.failure_count,
|
|
168244
|
-
lastError: row.last_error ?? undefined,
|
|
168245
|
-
previousResponse: row.previous_response ?? undefined,
|
|
168246
|
-
};
|
|
168247
|
-
}
|
|
168248
|
-
function toInsertRow(schedule) {
|
|
168249
|
-
return {
|
|
168250
|
-
id: schedule.id,
|
|
168251
|
-
creator_id: schedule.creatorId,
|
|
168252
|
-
creator_context: schedule.creatorContext ?? null,
|
|
168253
|
-
creator_name: schedule.creatorName ?? null,
|
|
168254
|
-
timezone: schedule.timezone,
|
|
168255
|
-
schedule_expr: schedule.schedule,
|
|
168256
|
-
run_at: schedule.runAt ?? null,
|
|
168257
|
-
is_recurring: schedule.isRecurring,
|
|
168258
|
-
original_expression: schedule.originalExpression,
|
|
168259
|
-
workflow: schedule.workflow ?? null,
|
|
168260
|
-
workflow_inputs: schedule.workflowInputs ? JSON.stringify(schedule.workflowInputs) : null,
|
|
168261
|
-
output_context: schedule.outputContext ? JSON.stringify(schedule.outputContext) : null,
|
|
168262
|
-
status: schedule.status,
|
|
168263
|
-
created_at: schedule.createdAt,
|
|
168264
|
-
last_run_at: schedule.lastRunAt ?? null,
|
|
168265
|
-
next_run_at: schedule.nextRunAt ?? null,
|
|
168266
|
-
run_count: schedule.runCount,
|
|
168267
|
-
failure_count: schedule.failureCount,
|
|
168268
|
-
last_error: schedule.lastError ?? null,
|
|
168269
|
-
previous_response: schedule.previousResponse ?? null,
|
|
168270
|
-
};
|
|
168271
|
-
}
|
|
168272
|
-
/**
|
|
168273
|
-
* Enterprise Knex-backed store for PostgreSQL, MySQL, and MSSQL
|
|
168274
|
-
*/
|
|
168275
|
-
class KnexStoreBackend {
|
|
168276
|
-
knex = null;
|
|
168277
|
-
driver;
|
|
168278
|
-
connection;
|
|
168279
|
-
constructor(driver, storageConfig, _haConfig) {
|
|
168280
|
-
this.driver = driver;
|
|
168281
|
-
this.connection = (storageConfig.connection || {});
|
|
168282
|
-
}
|
|
168283
|
-
async initialize() {
|
|
168284
|
-
// Load knex dynamically
|
|
168285
|
-
const { createRequire } = __nccwpck_require__(73339);
|
|
168286
|
-
const runtimeRequire = createRequire(__filename);
|
|
168287
|
-
let knexFactory;
|
|
168288
|
-
try {
|
|
168289
|
-
knexFactory = runtimeRequire('knex');
|
|
168290
|
-
}
|
|
168291
|
-
catch (err) {
|
|
168292
|
-
const code = err?.code;
|
|
168293
|
-
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND') {
|
|
168294
|
-
throw new Error('knex is required for PostgreSQL/MySQL/MSSQL schedule storage. ' +
|
|
168295
|
-
'Install it with: npm install knex');
|
|
168296
|
-
}
|
|
168297
|
-
throw err;
|
|
168298
|
-
}
|
|
168299
|
-
const clientMap = {
|
|
168300
|
-
postgresql: 'pg',
|
|
168301
|
-
mysql: 'mysql2',
|
|
168302
|
-
mssql: 'tedious',
|
|
168303
|
-
};
|
|
168304
|
-
const client = clientMap[this.driver];
|
|
168305
|
-
// Build connection config
|
|
168306
|
-
let connection;
|
|
168307
|
-
if (this.connection.connection_string) {
|
|
168308
|
-
connection = this.connection.connection_string;
|
|
168309
|
-
}
|
|
168310
|
-
else if (this.driver === 'mssql') {
|
|
168311
|
-
connection = this.buildMssqlConnection();
|
|
168312
|
-
}
|
|
168313
|
-
else {
|
|
168314
|
-
connection = this.buildStandardConnection();
|
|
168315
|
-
}
|
|
168316
|
-
this.knex = knexFactory({
|
|
168317
|
-
client,
|
|
168318
|
-
connection,
|
|
168319
|
-
pool: {
|
|
168320
|
-
min: this.connection.pool?.min ?? 0,
|
|
168321
|
-
max: this.connection.pool?.max ?? 10,
|
|
168322
|
-
},
|
|
168323
|
-
});
|
|
168324
|
-
// Run schema migration
|
|
168325
|
-
await this.migrateSchema();
|
|
168326
|
-
logger_1.logger.info(`[KnexStore] Initialized (${this.driver})`);
|
|
168327
|
-
}
|
|
168328
|
-
buildStandardConnection() {
|
|
168329
|
-
return {
|
|
168330
|
-
host: this.connection.host || 'localhost',
|
|
168331
|
-
port: this.connection.port,
|
|
168332
|
-
database: this.connection.database || 'visor',
|
|
168333
|
-
user: this.connection.user,
|
|
168334
|
-
password: this.connection.password,
|
|
168335
|
-
ssl: this.resolveSslConfig(),
|
|
168336
|
-
};
|
|
168337
|
-
}
|
|
168338
|
-
buildMssqlConnection() {
|
|
168339
|
-
const ssl = this.connection.ssl;
|
|
168340
|
-
const sslEnabled = ssl === true || (typeof ssl === 'object' && ssl.enabled !== false);
|
|
168341
|
-
return {
|
|
168342
|
-
server: this.connection.host || 'localhost',
|
|
168343
|
-
port: this.connection.port,
|
|
168344
|
-
database: this.connection.database || 'visor',
|
|
168345
|
-
user: this.connection.user,
|
|
168346
|
-
password: this.connection.password,
|
|
168347
|
-
options: {
|
|
168348
|
-
encrypt: sslEnabled,
|
|
168349
|
-
trustServerCertificate: typeof ssl === 'object' ? ssl.reject_unauthorized === false : !sslEnabled,
|
|
168350
|
-
},
|
|
168351
|
-
};
|
|
168352
|
-
}
|
|
168353
|
-
resolveSslConfig() {
|
|
168354
|
-
const ssl = this.connection.ssl;
|
|
168355
|
-
if (ssl === false || ssl === undefined)
|
|
168356
|
-
return false;
|
|
168357
|
-
if (ssl === true)
|
|
168358
|
-
return { rejectUnauthorized: true };
|
|
168359
|
-
// Object config
|
|
168360
|
-
if (ssl.enabled === false)
|
|
168361
|
-
return false;
|
|
168362
|
-
const result = {
|
|
168363
|
-
rejectUnauthorized: ssl.reject_unauthorized !== false,
|
|
168364
|
-
};
|
|
168365
|
-
if (ssl.ca) {
|
|
168366
|
-
const caPath = this.validateSslPath(ssl.ca, 'CA certificate');
|
|
168367
|
-
result.ca = fs.readFileSync(caPath, 'utf8');
|
|
168368
|
-
}
|
|
168369
|
-
if (ssl.cert) {
|
|
168370
|
-
const certPath = this.validateSslPath(ssl.cert, 'client certificate');
|
|
168371
|
-
result.cert = fs.readFileSync(certPath, 'utf8');
|
|
168372
|
-
}
|
|
168373
|
-
if (ssl.key) {
|
|
168374
|
-
const keyPath = this.validateSslPath(ssl.key, 'client key');
|
|
168375
|
-
result.key = fs.readFileSync(keyPath, 'utf8');
|
|
168376
|
-
}
|
|
168377
|
-
return result;
|
|
168378
|
-
}
|
|
168379
|
-
validateSslPath(filePath, label) {
|
|
168380
|
-
const resolved = path.resolve(filePath);
|
|
168381
|
-
if (resolved !== path.normalize(resolved)) {
|
|
168382
|
-
throw new Error(`SSL ${label} path contains invalid sequences: ${filePath}`);
|
|
168383
|
-
}
|
|
168384
|
-
if (!fs.existsSync(resolved)) {
|
|
168385
|
-
throw new Error(`SSL ${label} not found: ${filePath}`);
|
|
168386
|
-
}
|
|
168387
|
-
return resolved;
|
|
168388
|
-
}
|
|
168389
|
-
async shutdown() {
|
|
168390
|
-
if (this.knex) {
|
|
168391
|
-
await this.knex.destroy();
|
|
168392
|
-
this.knex = null;
|
|
168393
|
-
}
|
|
168394
|
-
}
|
|
168395
|
-
async migrateSchema() {
|
|
168396
|
-
const knex = this.getKnex();
|
|
168397
|
-
const exists = await knex.schema.hasTable('schedules');
|
|
168398
|
-
if (!exists) {
|
|
168399
|
-
await knex.schema.createTable('schedules', table => {
|
|
168400
|
-
table.string('id', 36).primary();
|
|
168401
|
-
table.string('creator_id', 255).notNullable().index();
|
|
168402
|
-
table.string('creator_context', 255);
|
|
168403
|
-
table.string('creator_name', 255);
|
|
168404
|
-
table.string('timezone', 64).notNullable().defaultTo('UTC');
|
|
168405
|
-
table.string('schedule_expr', 255);
|
|
168406
|
-
table.bigInteger('run_at');
|
|
168407
|
-
table.boolean('is_recurring').notNullable();
|
|
168408
|
-
table.text('original_expression');
|
|
168409
|
-
table.string('workflow', 255);
|
|
168410
|
-
table.text('workflow_inputs');
|
|
168411
|
-
table.text('output_context');
|
|
168412
|
-
table.string('status', 20).notNullable().index();
|
|
168413
|
-
table.bigInteger('created_at').notNullable();
|
|
168414
|
-
table.bigInteger('last_run_at');
|
|
168415
|
-
table.bigInteger('next_run_at');
|
|
168416
|
-
table.integer('run_count').notNullable().defaultTo(0);
|
|
168417
|
-
table.integer('failure_count').notNullable().defaultTo(0);
|
|
168418
|
-
table.text('last_error');
|
|
168419
|
-
table.text('previous_response');
|
|
168420
|
-
table.index(['status', 'next_run_at']);
|
|
168421
|
-
});
|
|
168422
|
-
}
|
|
168423
|
-
// Create scheduler_locks table for distributed locking
|
|
168424
|
-
const locksExist = await knex.schema.hasTable('scheduler_locks');
|
|
168425
|
-
if (!locksExist) {
|
|
168426
|
-
await knex.schema.createTable('scheduler_locks', table => {
|
|
168427
|
-
table.string('lock_id', 255).primary();
|
|
168428
|
-
table.string('node_id', 255).notNullable();
|
|
168429
|
-
table.string('lock_token', 36).notNullable();
|
|
168430
|
-
table.bigInteger('acquired_at').notNullable();
|
|
168431
|
-
table.bigInteger('expires_at').notNullable();
|
|
168432
|
-
});
|
|
168433
|
-
}
|
|
168434
|
-
}
|
|
168435
|
-
getKnex() {
|
|
168436
|
-
if (!this.knex) {
|
|
168437
|
-
throw new Error('[KnexStore] Not initialized. Call initialize() first.');
|
|
168438
|
-
}
|
|
168439
|
-
return this.knex;
|
|
168440
|
-
}
|
|
168441
|
-
// --- CRUD ---
|
|
168442
|
-
async create(schedule) {
|
|
168443
|
-
const knex = this.getKnex();
|
|
168444
|
-
const newSchedule = {
|
|
168445
|
-
...schedule,
|
|
168446
|
-
id: (0, uuid_1.v4)(),
|
|
168447
|
-
createdAt: Date.now(),
|
|
168448
|
-
runCount: 0,
|
|
168449
|
-
failureCount: 0,
|
|
168450
|
-
status: 'active',
|
|
168451
|
-
};
|
|
168452
|
-
await knex('schedules').insert(toInsertRow(newSchedule));
|
|
168453
|
-
logger_1.logger.info(`[KnexStore] Created schedule ${newSchedule.id} for user ${newSchedule.creatorId}`);
|
|
168454
|
-
return newSchedule;
|
|
168455
|
-
}
|
|
168456
|
-
async importSchedule(schedule) {
|
|
168457
|
-
const knex = this.getKnex();
|
|
168458
|
-
const existing = await knex('schedules').where('id', schedule.id).first();
|
|
168459
|
-
if (existing)
|
|
168460
|
-
return; // Already imported (idempotent)
|
|
168461
|
-
await knex('schedules').insert(toInsertRow(schedule));
|
|
168462
|
-
}
|
|
168463
|
-
async get(id) {
|
|
168464
|
-
const knex = this.getKnex();
|
|
168465
|
-
const row = await knex('schedules').where('id', id).first();
|
|
168466
|
-
return row ? fromDbRow(row) : undefined;
|
|
168467
|
-
}
|
|
168468
|
-
async update(id, patch) {
|
|
168469
|
-
const knex = this.getKnex();
|
|
168470
|
-
const existing = await knex('schedules').where('id', id).first();
|
|
168471
|
-
if (!existing)
|
|
168472
|
-
return undefined;
|
|
168473
|
-
const current = fromDbRow(existing);
|
|
168474
|
-
const updated = { ...current, ...patch, id: current.id };
|
|
168475
|
-
const row = toInsertRow(updated);
|
|
168476
|
-
// Remove id from update (PK cannot change)
|
|
168477
|
-
delete row.id;
|
|
168478
|
-
await knex('schedules').where('id', id).update(row);
|
|
168479
|
-
return updated;
|
|
168480
|
-
}
|
|
168481
|
-
async delete(id) {
|
|
168482
|
-
const knex = this.getKnex();
|
|
168483
|
-
const deleted = await knex('schedules').where('id', id).del();
|
|
168484
|
-
if (deleted > 0) {
|
|
168485
|
-
logger_1.logger.info(`[KnexStore] Deleted schedule ${id}`);
|
|
168486
|
-
return true;
|
|
168487
|
-
}
|
|
168488
|
-
return false;
|
|
168489
|
-
}
|
|
168490
|
-
// --- Queries ---
|
|
168491
|
-
async getByCreator(creatorId) {
|
|
168492
|
-
const knex = this.getKnex();
|
|
168493
|
-
const rows = await knex('schedules').where('creator_id', creatorId);
|
|
168494
|
-
return rows.map((r) => fromDbRow(r));
|
|
168495
|
-
}
|
|
168496
|
-
async getActiveSchedules() {
|
|
168497
|
-
const knex = this.getKnex();
|
|
168498
|
-
const rows = await knex('schedules').where('status', 'active');
|
|
168499
|
-
return rows.map((r) => fromDbRow(r));
|
|
168500
|
-
}
|
|
168501
|
-
async getDueSchedules(now) {
|
|
168502
|
-
const ts = now ?? Date.now();
|
|
168503
|
-
const knex = this.getKnex();
|
|
168504
|
-
// MSSQL uses 1/0 for booleans
|
|
168505
|
-
const bFalse = this.driver === 'mssql' ? 0 : false;
|
|
168506
|
-
const bTrue = this.driver === 'mssql' ? 1 : true;
|
|
168507
|
-
const rows = await knex('schedules')
|
|
168508
|
-
.where('status', 'active')
|
|
168509
|
-
.andWhere(function () {
|
|
168510
|
-
this.where(function () {
|
|
168511
|
-
this.where('is_recurring', bFalse)
|
|
168512
|
-
.whereNotNull('run_at')
|
|
168513
|
-
.where('run_at', '<=', ts);
|
|
168514
|
-
}).orWhere(function () {
|
|
168515
|
-
this.where('is_recurring', bTrue)
|
|
168516
|
-
.whereNotNull('next_run_at')
|
|
168517
|
-
.where('next_run_at', '<=', ts);
|
|
168518
|
-
});
|
|
168519
|
-
});
|
|
168520
|
-
return rows.map((r) => fromDbRow(r));
|
|
168521
|
-
}
|
|
168522
|
-
async findByWorkflow(creatorId, workflowName) {
|
|
168523
|
-
const knex = this.getKnex();
|
|
168524
|
-
const escaped = workflowName.toLowerCase().replace(/[%_\\]/g, '\\$&');
|
|
168525
|
-
const pattern = `%${escaped}%`;
|
|
168526
|
-
const rows = await knex('schedules')
|
|
168527
|
-
.where('creator_id', creatorId)
|
|
168528
|
-
.where('status', 'active')
|
|
168529
|
-
.whereRaw("LOWER(workflow) LIKE ? ESCAPE '\\'", [pattern]);
|
|
168530
|
-
return rows.map((r) => fromDbRow(r));
|
|
168531
|
-
}
|
|
168532
|
-
async getAll() {
|
|
168533
|
-
const knex = this.getKnex();
|
|
168534
|
-
const rows = await knex('schedules');
|
|
168535
|
-
return rows.map((r) => fromDbRow(r));
|
|
168536
|
-
}
|
|
168537
|
-
async getStats() {
|
|
168538
|
-
const knex = this.getKnex();
|
|
168539
|
-
// MSSQL uses 1/0 for booleans; PostgreSQL/MySQL accept both true/1
|
|
168540
|
-
const boolTrue = this.driver === 'mssql' ? '1' : 'true';
|
|
168541
|
-
const boolFalse = this.driver === 'mssql' ? '0' : 'false';
|
|
168542
|
-
const result = await knex('schedules')
|
|
168543
|
-
.select(knex.raw('COUNT(*) as total'), knex.raw("SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active"), knex.raw("SUM(CASE WHEN status = 'paused' THEN 1 ELSE 0 END) as paused"), knex.raw("SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed"), knex.raw("SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed"), knex.raw(`SUM(CASE WHEN is_recurring = ${boolTrue} THEN 1 ELSE 0 END) as recurring`), knex.raw(`SUM(CASE WHEN is_recurring = ${boolFalse} THEN 1 ELSE 0 END) as one_time`))
|
|
168544
|
-
.first();
|
|
168545
|
-
return {
|
|
168546
|
-
total: Number(result.total) || 0,
|
|
168547
|
-
active: Number(result.active) || 0,
|
|
168548
|
-
paused: Number(result.paused) || 0,
|
|
168549
|
-
completed: Number(result.completed) || 0,
|
|
168550
|
-
failed: Number(result.failed) || 0,
|
|
168551
|
-
recurring: Number(result.recurring) || 0,
|
|
168552
|
-
oneTime: Number(result.one_time) || 0,
|
|
168553
|
-
};
|
|
168554
|
-
}
|
|
168555
|
-
async validateLimits(creatorId, isRecurring, limits) {
|
|
168556
|
-
const knex = this.getKnex();
|
|
168557
|
-
if (limits.maxGlobal) {
|
|
168558
|
-
const result = await knex('schedules').count('* as cnt').first();
|
|
168559
|
-
if (Number(result?.cnt) >= limits.maxGlobal) {
|
|
168560
|
-
throw new Error(`Global schedule limit reached (${limits.maxGlobal})`);
|
|
168561
|
-
}
|
|
168562
|
-
}
|
|
168563
|
-
if (limits.maxPerUser) {
|
|
168564
|
-
const result = await knex('schedules')
|
|
168565
|
-
.where('creator_id', creatorId)
|
|
168566
|
-
.count('* as cnt')
|
|
168567
|
-
.first();
|
|
168568
|
-
if (Number(result?.cnt) >= limits.maxPerUser) {
|
|
168569
|
-
throw new Error(`You have reached the maximum number of schedules (${limits.maxPerUser})`);
|
|
168570
|
-
}
|
|
168571
|
-
}
|
|
168572
|
-
if (isRecurring && limits.maxRecurringPerUser) {
|
|
168573
|
-
const bTrue = this.driver === 'mssql' ? 1 : true;
|
|
168574
|
-
const result = await knex('schedules')
|
|
168575
|
-
.where('creator_id', creatorId)
|
|
168576
|
-
.where('is_recurring', bTrue)
|
|
168577
|
-
.count('* as cnt')
|
|
168578
|
-
.first();
|
|
168579
|
-
if (Number(result?.cnt) >= limits.maxRecurringPerUser) {
|
|
168580
|
-
throw new Error(`You have reached the maximum number of recurring schedules (${limits.maxRecurringPerUser})`);
|
|
168581
|
-
}
|
|
168582
|
-
}
|
|
168583
|
-
}
|
|
168584
|
-
// --- HA Distributed Locking (via scheduler_locks table) ---
|
|
168585
|
-
async tryAcquireLock(lockId, nodeId, ttlSeconds) {
|
|
168586
|
-
const knex = this.getKnex();
|
|
168587
|
-
const now = Date.now();
|
|
168588
|
-
const expiresAt = now + ttlSeconds * 1000;
|
|
168589
|
-
const token = (0, uuid_1.v4)();
|
|
168590
|
-
// Step 1: Try to claim an existing expired lock
|
|
168591
|
-
const updated = await knex('scheduler_locks')
|
|
168592
|
-
.where('lock_id', lockId)
|
|
168593
|
-
.where('expires_at', '<', now)
|
|
168594
|
-
.update({
|
|
168595
|
-
node_id: nodeId,
|
|
168596
|
-
lock_token: token,
|
|
168597
|
-
acquired_at: now,
|
|
168598
|
-
expires_at: expiresAt,
|
|
168599
|
-
});
|
|
168600
|
-
if (updated > 0)
|
|
168601
|
-
return token;
|
|
168602
|
-
// Step 2: Try to INSERT a new lock row
|
|
168603
|
-
try {
|
|
168604
|
-
await knex('scheduler_locks').insert({
|
|
168605
|
-
lock_id: lockId,
|
|
168606
|
-
node_id: nodeId,
|
|
168607
|
-
lock_token: token,
|
|
168608
|
-
acquired_at: now,
|
|
168609
|
-
expires_at: expiresAt,
|
|
168610
|
-
});
|
|
168611
|
-
return token;
|
|
168612
|
-
}
|
|
168613
|
-
catch {
|
|
168614
|
-
// Unique constraint violation — another node holds the lock
|
|
168615
|
-
return null;
|
|
168616
|
-
}
|
|
168617
|
-
}
|
|
168618
|
-
async releaseLock(lockId, lockToken) {
|
|
168619
|
-
const knex = this.getKnex();
|
|
168620
|
-
await knex('scheduler_locks').where('lock_id', lockId).where('lock_token', lockToken).del();
|
|
168621
|
-
}
|
|
168622
|
-
async renewLock(lockId, lockToken, ttlSeconds) {
|
|
168623
|
-
const knex = this.getKnex();
|
|
168624
|
-
const now = Date.now();
|
|
168625
|
-
const expiresAt = now + ttlSeconds * 1000;
|
|
168626
|
-
const updated = await knex('scheduler_locks')
|
|
168627
|
-
.where('lock_id', lockId)
|
|
168628
|
-
.where('lock_token', lockToken)
|
|
168629
|
-
.update({ acquired_at: now, expires_at: expiresAt });
|
|
168630
|
-
return updated > 0;
|
|
168631
|
-
}
|
|
168632
|
-
async flush() {
|
|
168633
|
-
// No-op for server-based backends
|
|
168634
|
-
}
|
|
168635
|
-
}
|
|
168636
|
-
exports.KnexStoreBackend = KnexStoreBackend;
|
|
168637
|
-
|
|
168638
|
-
|
|
168639
166955
|
/***/ }),
|
|
168640
166956
|
|
|
168641
166957
|
/***/ 83864:
|
|
@@ -179312,35 +177628,6 @@ class OutputFormatters {
|
|
|
179312
177628
|
exports.OutputFormatters = OutputFormatters;
|
|
179313
177629
|
|
|
179314
177630
|
|
|
179315
|
-
/***/ }),
|
|
179316
|
-
|
|
179317
|
-
/***/ 93866:
|
|
179318
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
179319
|
-
|
|
179320
|
-
"use strict";
|
|
179321
|
-
|
|
179322
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
179323
|
-
exports.DefaultPolicyEngine = void 0;
|
|
179324
|
-
/**
|
|
179325
|
-
* Default (no-op) policy engine — always allows everything.
|
|
179326
|
-
* Used when no enterprise license is present or policy is disabled.
|
|
179327
|
-
*/
|
|
179328
|
-
class DefaultPolicyEngine {
|
|
179329
|
-
async initialize(_config) { }
|
|
179330
|
-
async evaluateCheckExecution(_checkId, _checkConfig) {
|
|
179331
|
-
return { allowed: true };
|
|
179332
|
-
}
|
|
179333
|
-
async evaluateToolInvocation(_serverName, _methodName, _transport) {
|
|
179334
|
-
return { allowed: true };
|
|
179335
|
-
}
|
|
179336
|
-
async evaluateCapabilities(_checkId, _capabilities) {
|
|
179337
|
-
return { allowed: true };
|
|
179338
|
-
}
|
|
179339
|
-
async shutdown() { }
|
|
179340
|
-
}
|
|
179341
|
-
exports.DefaultPolicyEngine = DefaultPolicyEngine;
|
|
179342
|
-
|
|
179343
|
-
|
|
179344
177631
|
/***/ }),
|
|
179345
177632
|
|
|
179346
177633
|
/***/ 96611:
|
|
@@ -188294,7 +186581,7 @@ class McpCheckProvider extends check_provider_interface_1.CheckProvider {
|
|
|
188294
186581
|
}
|
|
188295
186582
|
}
|
|
188296
186583
|
// Create MCP client and execute method
|
|
188297
|
-
const result = await this.executeMcpMethod(cfg, methodArgs, prInfo, dependencyResults);
|
|
186584
|
+
const result = await this.executeMcpMethod(cfg, methodArgs, prInfo, dependencyResults, sessionInfo);
|
|
188298
186585
|
// Apply transforms if specified
|
|
188299
186586
|
let finalOutput = result;
|
|
188300
186587
|
// Apply Liquid transform
|
|
@@ -188404,19 +186691,29 @@ class McpCheckProvider extends check_provider_interface_1.CheckProvider {
|
|
|
188404
186691
|
/**
|
|
188405
186692
|
* Execute an MCP method using the configured transport
|
|
188406
186693
|
*/
|
|
188407
|
-
async executeMcpMethod(config, methodArgs, prInfo, dependencyResults) {
|
|
186694
|
+
async executeMcpMethod(config, methodArgs, prInfo, dependencyResults, sessionInfo) {
|
|
188408
186695
|
const transport = config.transport || 'stdio';
|
|
188409
186696
|
const timeout = (config.timeout || 60) * 1000; // Convert to milliseconds
|
|
188410
186697
|
if (transport === 'custom') {
|
|
188411
|
-
//
|
|
188412
|
-
|
|
188413
|
-
|
|
188414
|
-
|
|
188415
|
-
|
|
188416
|
-
|
|
188417
|
-
|
|
186698
|
+
// Check both local execution context and global registry for tools
|
|
186699
|
+
const localTools = sessionInfo?._parentContext?.config?.tools || sessionInfo?.config?.tools || {};
|
|
186700
|
+
let localExecutor;
|
|
186701
|
+
if (Object.keys(localTools).length > 0) {
|
|
186702
|
+
localExecutor = new custom_tool_executor_1.CustomToolExecutor(localTools);
|
|
186703
|
+
}
|
|
186704
|
+
const hasLocalTool = localExecutor ? await localExecutor.hasTool(config.method) : false;
|
|
186705
|
+
const hasGlobalTool = this.customToolExecutor
|
|
186706
|
+
? await this.customToolExecutor.hasTool(config.method)
|
|
186707
|
+
: false;
|
|
186708
|
+
if (!hasLocalTool && !hasGlobalTool) {
|
|
186709
|
+
const localNames = localExecutor ? await localExecutor.getToolNames() : [];
|
|
186710
|
+
const globalNames = this.customToolExecutor
|
|
186711
|
+
? await this.customToolExecutor.getToolNames()
|
|
186712
|
+
: [];
|
|
186713
|
+
const availableToolNames = [...new Set([...localNames, ...globalNames])];
|
|
188418
186714
|
throw new Error(`Custom tool not found: ${config.method}. Available tools: ${availableToolNames.join(', ')}`);
|
|
188419
186715
|
}
|
|
186716
|
+
const activeExecutor = hasLocalTool ? localExecutor : this.customToolExecutor;
|
|
188420
186717
|
// Build context for custom tool execution
|
|
188421
186718
|
const context = {
|
|
188422
186719
|
pr: prInfo
|
|
@@ -188432,7 +186729,7 @@ class McpCheckProvider extends check_provider_interface_1.CheckProvider {
|
|
|
188432
186729
|
outputs: this.buildOutputContext(dependencyResults),
|
|
188433
186730
|
env: this.getSafeEnvironmentVariables(),
|
|
188434
186731
|
};
|
|
188435
|
-
return await
|
|
186732
|
+
return await activeExecutor.execute(config.method, methodArgs, context);
|
|
188436
186733
|
}
|
|
188437
186734
|
else if (transport === 'stdio') {
|
|
188438
186735
|
return await this.executeStdioMethod(config, methodArgs, timeout);
|
|
@@ -191126,6 +189423,7 @@ class WorkflowCheckProvider extends check_provider_interface_1.CheckProvider {
|
|
|
191126
189423
|
// Carry over optional inputs/outputs if present so callers can consume them
|
|
191127
189424
|
inputs: loaded.inputs,
|
|
191128
189425
|
outputs: loaded.outputs,
|
|
189426
|
+
tools: loaded.tools,
|
|
191129
189427
|
};
|
|
191130
189428
|
return workflowDef;
|
|
191131
189429
|
}
|
|
@@ -199564,7 +197862,7 @@ class StateMachineExecutionEngine {
|
|
|
199564
197862
|
try {
|
|
199565
197863
|
logger_1.logger.debug(`[PolicyEngine] Loading enterprise policy engine (engine=${configWithTagFilter.policy.engine})`);
|
|
199566
197864
|
// @ts-ignore — enterprise/ may not exist in OSS builds (caught at runtime)
|
|
199567
|
-
const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(
|
|
197865
|
+
const { loadEnterprisePolicyEngine } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(7065)));
|
|
199568
197866
|
context.policyEngine = await loadEnterprisePolicyEngine(configWithTagFilter.policy);
|
|
199569
197867
|
logger_1.logger.debug(`[PolicyEngine] Initialized: ${context.policyEngine?.constructor?.name || 'unknown'}`);
|
|
199570
197868
|
}
|
|
@@ -209074,6 +207372,7 @@ function projectWorkflowToGraph(workflow, workflowInputs, _parentCheckId) {
|
|
|
209074
207372
|
// Create a synthetic config for this workflow
|
|
209075
207373
|
const config = {
|
|
209076
207374
|
checks,
|
|
207375
|
+
tools: workflow.tools,
|
|
209077
207376
|
version: '1.0',
|
|
209078
207377
|
output: {
|
|
209079
207378
|
pr_comment: {
|
|
@@ -209822,7 +208121,7 @@ async function initTelemetry(opts = {}) {
|
|
|
209822
208121
|
const path = __nccwpck_require__(16928);
|
|
209823
208122
|
const outDir = opts.file?.dir ||
|
|
209824
208123
|
process.env.VISOR_TRACE_DIR ||
|
|
209825
|
-
|
|
208124
|
+
__nccwpck_require__.ab + "traces";
|
|
209826
208125
|
fs.mkdirSync(outDir, { recursive: true });
|
|
209827
208126
|
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
209828
208127
|
process.env.VISOR_FALLBACK_TRACE_FILE = path.join(outDir, `run-${ts}.ndjson`);
|
|
@@ -210025,7 +208324,7 @@ async function shutdownTelemetry() {
|
|
|
210025
208324
|
if (process.env.VISOR_TRACE_REPORT === 'true') {
|
|
210026
208325
|
const fs = __nccwpck_require__(79896);
|
|
210027
208326
|
const path = __nccwpck_require__(16928);
|
|
210028
|
-
const outDir = process.env.VISOR_TRACE_DIR ||
|
|
208327
|
+
const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
|
|
210029
208328
|
if (!fs.existsSync(outDir))
|
|
210030
208329
|
fs.mkdirSync(outDir, { recursive: true });
|
|
210031
208330
|
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
@@ -210524,7 +208823,7 @@ function __getOrCreateNdjsonPath() {
|
|
|
210524
208823
|
fs.mkdirSync(dir, { recursive: true });
|
|
210525
208824
|
return __ndjsonPath;
|
|
210526
208825
|
}
|
|
210527
|
-
const outDir = process.env.VISOR_TRACE_DIR ||
|
|
208826
|
+
const outDir = process.env.VISOR_TRACE_DIR || __nccwpck_require__.ab + "traces";
|
|
210528
208827
|
if (!fs.existsSync(outDir))
|
|
210529
208828
|
fs.mkdirSync(outDir, { recursive: true });
|
|
210530
208829
|
if (!__ndjsonPath) {
|
|
@@ -223851,6 +222150,22 @@ class WorkflowRegistry {
|
|
|
223851
222150
|
exports.WorkflowRegistry = WorkflowRegistry;
|
|
223852
222151
|
|
|
223853
222152
|
|
|
222153
|
+
/***/ }),
|
|
222154
|
+
|
|
222155
|
+
/***/ 7065:
|
|
222156
|
+
/***/ ((module) => {
|
|
222157
|
+
|
|
222158
|
+
module.exports = eval("require")("./enterprise/loader");
|
|
222159
|
+
|
|
222160
|
+
|
|
222161
|
+
/***/ }),
|
|
222162
|
+
|
|
222163
|
+
/***/ 71370:
|
|
222164
|
+
/***/ ((module) => {
|
|
222165
|
+
|
|
222166
|
+
module.exports = eval("require")("./enterprise/policy/policy-input-builder");
|
|
222167
|
+
|
|
222168
|
+
|
|
223854
222169
|
/***/ }),
|
|
223855
222170
|
|
|
223856
222171
|
/***/ 18327:
|
|
@@ -397804,7 +396119,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"100":"Continue","101":"Switching Pro
|
|
|
397804
396119
|
/***/ ((module) => {
|
|
397805
396120
|
|
|
397806
396121
|
"use strict";
|
|
397807
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.
|
|
396122
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.139","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#f1c13b8eee98734a8ea024061eada4aa9a9ff2e9","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@probelabs/probe":"^0.6.0-rc257","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","ignore":"^7.0.5","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","minimatch":"^10.2.2","node-cron":"^3.0.3","open":"^9.1.0","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","@opentelemetry/api":"^1.9.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
|
|
397808
396123
|
|
|
397809
396124
|
/***/ })
|
|
397810
396125
|
|