saktum 0.1.4 → 0.2.0
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/README.md +20 -3
- package/package.json +1 -1
- package/saktum.mjs +1244 -583
package/saktum.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Saktum Check 0.
|
|
2
|
+
// Saktum Check 0.2.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
|
|
3
3
|
import { createRequire as __saktumCreateRequire } from "node:module";
|
|
4
4
|
const require = __saktumCreateRequire(import.meta.url);
|
|
5
5
|
var __create = Object.create;
|
|
@@ -14,6 +14,14 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
14
14
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
15
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
16
|
});
|
|
17
|
+
var __esm = (fn, res, err) => function __init() {
|
|
18
|
+
if (err) throw err[0];
|
|
19
|
+
try {
|
|
20
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw err = [e], e;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
17
25
|
var __commonJS = (cb, mod) => function __require2() {
|
|
18
26
|
try {
|
|
19
27
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -3495,7 +3503,7 @@ var require_anchors = __commonJS({
|
|
|
3495
3503
|
var require_applyReviver = __commonJS({
|
|
3496
3504
|
"node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/applyReviver.js"(exports) {
|
|
3497
3505
|
"use strict";
|
|
3498
|
-
function applyReviver(reviver,
|
|
3506
|
+
function applyReviver(reviver, obj2, key, val) {
|
|
3499
3507
|
if (val && typeof val === "object") {
|
|
3500
3508
|
if (Array.isArray(val)) {
|
|
3501
3509
|
for (let i = 0, len = val.length; i < len; ++i) {
|
|
@@ -3535,7 +3543,7 @@ var require_applyReviver = __commonJS({
|
|
|
3535
3543
|
}
|
|
3536
3544
|
}
|
|
3537
3545
|
}
|
|
3538
|
-
return reviver.call(
|
|
3546
|
+
return reviver.call(obj2, key, val);
|
|
3539
3547
|
}
|
|
3540
3548
|
exports.applyReviver = applyReviver;
|
|
3541
3549
|
}
|
|
@@ -4471,10 +4479,10 @@ var require_stringify = __commonJS({
|
|
|
4471
4479
|
return match.find((t) => t.format === item.format) ?? match[0];
|
|
4472
4480
|
}
|
|
4473
4481
|
let tagObj = void 0;
|
|
4474
|
-
let
|
|
4482
|
+
let obj2;
|
|
4475
4483
|
if (identity.isScalar(item)) {
|
|
4476
|
-
|
|
4477
|
-
let match = tags.filter((t) => t.identify?.(
|
|
4484
|
+
obj2 = item.value;
|
|
4485
|
+
let match = tags.filter((t) => t.identify?.(obj2));
|
|
4478
4486
|
if (match.length > 1) {
|
|
4479
4487
|
const testMatch = match.filter((t) => t.test);
|
|
4480
4488
|
if (testMatch.length > 0)
|
|
@@ -4482,11 +4490,11 @@ var require_stringify = __commonJS({
|
|
|
4482
4490
|
}
|
|
4483
4491
|
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
4484
4492
|
} else {
|
|
4485
|
-
|
|
4486
|
-
tagObj = tags.find((t) => t.nodeClass &&
|
|
4493
|
+
obj2 = item;
|
|
4494
|
+
tagObj = tags.find((t) => t.nodeClass && obj2 instanceof t.nodeClass);
|
|
4487
4495
|
}
|
|
4488
4496
|
if (!tagObj) {
|
|
4489
|
-
const name =
|
|
4497
|
+
const name = obj2?.constructor?.name ?? (obj2 === null ? "null" : typeof obj2);
|
|
4490
4498
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
4491
4499
|
}
|
|
4492
4500
|
return tagObj;
|
|
@@ -5042,23 +5050,23 @@ var require_YAMLMap = __commonJS({
|
|
|
5042
5050
|
* A generic collection parsing method that can be extended
|
|
5043
5051
|
* to other node classes that inherit from YAMLMap
|
|
5044
5052
|
*/
|
|
5045
|
-
static from(schema,
|
|
5053
|
+
static from(schema, obj2, ctx) {
|
|
5046
5054
|
const { keepUndefined, replacer } = ctx;
|
|
5047
5055
|
const map = new this(schema);
|
|
5048
5056
|
const add = (key, value) => {
|
|
5049
5057
|
if (typeof replacer === "function")
|
|
5050
|
-
value = replacer.call(
|
|
5058
|
+
value = replacer.call(obj2, key, value);
|
|
5051
5059
|
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
5052
5060
|
return;
|
|
5053
5061
|
if (value !== void 0 || keepUndefined)
|
|
5054
5062
|
map.items.push(Pair.createPair(key, value, ctx));
|
|
5055
5063
|
};
|
|
5056
|
-
if (
|
|
5057
|
-
for (const [key, value] of
|
|
5064
|
+
if (obj2 instanceof Map) {
|
|
5065
|
+
for (const [key, value] of obj2)
|
|
5058
5066
|
add(key, value);
|
|
5059
|
-
} else if (
|
|
5060
|
-
for (const key of Object.keys(
|
|
5061
|
-
add(key,
|
|
5067
|
+
} else if (obj2 && typeof obj2 === "object") {
|
|
5068
|
+
for (const key of Object.keys(obj2))
|
|
5069
|
+
add(key, obj2[key]);
|
|
5062
5070
|
}
|
|
5063
5071
|
if (typeof schema.sortMapEntries === "function") {
|
|
5064
5072
|
map.items.sort(schema.sortMapEntries);
|
|
@@ -5168,7 +5176,7 @@ var require_map = __commonJS({
|
|
|
5168
5176
|
onError("Expected a mapping for this tag");
|
|
5169
5177
|
return map2;
|
|
5170
5178
|
},
|
|
5171
|
-
createNode: (schema,
|
|
5179
|
+
createNode: (schema, obj2, ctx) => YAMLMap.YAMLMap.from(schema, obj2, ctx)
|
|
5172
5180
|
};
|
|
5173
5181
|
exports.map = map;
|
|
5174
5182
|
}
|
|
@@ -5264,15 +5272,15 @@ var require_YAMLSeq = __commonJS({
|
|
|
5264
5272
|
onComment
|
|
5265
5273
|
});
|
|
5266
5274
|
}
|
|
5267
|
-
static from(schema,
|
|
5275
|
+
static from(schema, obj2, ctx) {
|
|
5268
5276
|
const { replacer } = ctx;
|
|
5269
5277
|
const seq = new this(schema);
|
|
5270
|
-
if (
|
|
5278
|
+
if (obj2 && Symbol.iterator in Object(obj2)) {
|
|
5271
5279
|
let i = 0;
|
|
5272
|
-
for (let it of
|
|
5280
|
+
for (let it of obj2) {
|
|
5273
5281
|
if (typeof replacer === "function") {
|
|
5274
|
-
const key =
|
|
5275
|
-
it = replacer.call(
|
|
5282
|
+
const key = obj2 instanceof Set ? it : String(i++);
|
|
5283
|
+
it = replacer.call(obj2, key, it);
|
|
5276
5284
|
}
|
|
5277
5285
|
seq.items.push(createNode.createNode(it, void 0, ctx));
|
|
5278
5286
|
}
|
|
@@ -5306,7 +5314,7 @@ var require_seq = __commonJS({
|
|
|
5306
5314
|
onError("Expected a sequence for this tag");
|
|
5307
5315
|
return seq2;
|
|
5308
5316
|
},
|
|
5309
|
-
createNode: (schema,
|
|
5317
|
+
createNode: (schema, obj2, ctx) => YAMLSeq.YAMLSeq.from(schema, obj2, ctx)
|
|
5310
5318
|
};
|
|
5311
5319
|
exports.seq = seq;
|
|
5312
5320
|
}
|
|
@@ -11201,12 +11209,12 @@ var require_codegen = __commonJS({
|
|
|
11201
11209
|
}
|
|
11202
11210
|
// `for-in` statement.
|
|
11203
11211
|
// With option `ownProperties` replaced with a `for-of` loop for object keys
|
|
11204
|
-
forIn(nameOrPrefix,
|
|
11212
|
+
forIn(nameOrPrefix, obj2, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
|
11205
11213
|
if (this.opts.ownProperties) {
|
|
11206
|
-
return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${
|
|
11214
|
+
return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj2})`, forBody);
|
|
11207
11215
|
}
|
|
11208
11216
|
const name = this._scope.toName(nameOrPrefix);
|
|
11209
|
-
return this._for(new ForIter("in", varKind, name,
|
|
11217
|
+
return this._for(new ForIter("in", varKind, name, obj2), () => forBody(name));
|
|
11210
11218
|
}
|
|
11211
11219
|
// end `for` loop
|
|
11212
11220
|
endFor() {
|
|
@@ -11430,11 +11438,11 @@ var require_util = __commonJS({
|
|
|
11430
11438
|
return false;
|
|
11431
11439
|
}
|
|
11432
11440
|
exports.schemaHasRules = schemaHasRules;
|
|
11433
|
-
function schemaHasRulesButRef(schema,
|
|
11441
|
+
function schemaHasRulesButRef(schema, RULES2) {
|
|
11434
11442
|
if (typeof schema == "boolean")
|
|
11435
11443
|
return !schema;
|
|
11436
11444
|
for (const key in schema)
|
|
11437
|
-
if (key !== "$ref" &&
|
|
11445
|
+
if (key !== "$ref" && RULES2.all[key])
|
|
11438
11446
|
return true;
|
|
11439
11447
|
return false;
|
|
11440
11448
|
}
|
|
@@ -12828,17 +12836,17 @@ var require_validate = __commonJS({
|
|
|
12828
12836
|
}
|
|
12829
12837
|
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
12830
12838
|
const { gen, schema, data, allErrors, opts, self } = it;
|
|
12831
|
-
const { RULES } = self;
|
|
12832
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema,
|
|
12833
|
-
gen.block(() => keywordCode(it, "$ref",
|
|
12839
|
+
const { RULES: RULES2 } = self;
|
|
12840
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES2))) {
|
|
12841
|
+
gen.block(() => keywordCode(it, "$ref", RULES2.all.$ref.definition));
|
|
12834
12842
|
return;
|
|
12835
12843
|
}
|
|
12836
12844
|
if (!opts.jtd)
|
|
12837
12845
|
checkStrictTypes(it, types);
|
|
12838
12846
|
gen.block(() => {
|
|
12839
|
-
for (const group of
|
|
12847
|
+
for (const group of RULES2.rules)
|
|
12840
12848
|
groupKeywords(group);
|
|
12841
|
-
groupKeywords(
|
|
12849
|
+
groupKeywords(RULES2.post);
|
|
12842
12850
|
});
|
|
12843
12851
|
function groupKeywords(group) {
|
|
12844
12852
|
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
@@ -13026,11 +13034,11 @@ var require_validate = __commonJS({
|
|
|
13026
13034
|
if (!this.allErrors)
|
|
13027
13035
|
this.gen.if(cond);
|
|
13028
13036
|
}
|
|
13029
|
-
setParams(
|
|
13037
|
+
setParams(obj2, assign) {
|
|
13030
13038
|
if (assign)
|
|
13031
|
-
Object.assign(this.params,
|
|
13039
|
+
Object.assign(this.params, obj2);
|
|
13032
13040
|
else
|
|
13033
|
-
this.params =
|
|
13041
|
+
this.params = obj2;
|
|
13034
13042
|
}
|
|
13035
13043
|
block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
|
|
13036
13044
|
this.gen.block(() => {
|
|
@@ -14993,10 +15001,10 @@ var require_core = __commonJS({
|
|
|
14993
15001
|
}
|
|
14994
15002
|
// Remove keyword
|
|
14995
15003
|
removeKeyword(keyword) {
|
|
14996
|
-
const { RULES } = this;
|
|
14997
|
-
delete
|
|
14998
|
-
delete
|
|
14999
|
-
for (const group of
|
|
15004
|
+
const { RULES: RULES2 } = this;
|
|
15005
|
+
delete RULES2.keywords[keyword];
|
|
15006
|
+
delete RULES2.all[keyword];
|
|
15007
|
+
for (const group of RULES2.rules) {
|
|
15000
15008
|
const i = group.rules.findIndex((rule) => rule.keyword === keyword);
|
|
15001
15009
|
if (i >= 0)
|
|
15002
15010
|
group.rules.splice(i, 1);
|
|
@@ -15164,9 +15172,9 @@ var require_core = __commonJS({
|
|
|
15164
15172
|
}
|
|
15165
15173
|
var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
15166
15174
|
function checkKeyword(keyword, def) {
|
|
15167
|
-
const { RULES } = this;
|
|
15175
|
+
const { RULES: RULES2 } = this;
|
|
15168
15176
|
(0, util_1.eachItem)(keyword, (kwd) => {
|
|
15169
|
-
if (
|
|
15177
|
+
if (RULES2.keywords[kwd])
|
|
15170
15178
|
throw new Error(`Keyword ${kwd} is already defined`);
|
|
15171
15179
|
if (!KEYWORD_NAME.test(kwd))
|
|
15172
15180
|
throw new Error(`Keyword ${kwd} has invalid name`);
|
|
@@ -15182,13 +15190,13 @@ var require_core = __commonJS({
|
|
|
15182
15190
|
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
15183
15191
|
if (dataType && post)
|
|
15184
15192
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
15185
|
-
const { RULES } = this;
|
|
15186
|
-
let ruleGroup = post ?
|
|
15193
|
+
const { RULES: RULES2 } = this;
|
|
15194
|
+
let ruleGroup = post ? RULES2.post : RULES2.rules.find(({ type: t }) => t === dataType);
|
|
15187
15195
|
if (!ruleGroup) {
|
|
15188
15196
|
ruleGroup = { type: dataType, rules: [] };
|
|
15189
|
-
|
|
15197
|
+
RULES2.rules.push(ruleGroup);
|
|
15190
15198
|
}
|
|
15191
|
-
|
|
15199
|
+
RULES2.keywords[keyword] = true;
|
|
15192
15200
|
if (!definition)
|
|
15193
15201
|
return;
|
|
15194
15202
|
const rule = {
|
|
@@ -15203,7 +15211,7 @@ var require_core = __commonJS({
|
|
|
15203
15211
|
addBeforeRule.call(this, ruleGroup, rule, definition.before);
|
|
15204
15212
|
else
|
|
15205
15213
|
ruleGroup.rules.push(rule);
|
|
15206
|
-
|
|
15214
|
+
RULES2.all[keyword] = rule;
|
|
15207
15215
|
(_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
|
|
15208
15216
|
}
|
|
15209
15217
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
@@ -18867,6 +18875,517 @@ var require_dist2 = __commonJS({
|
|
|
18867
18875
|
}
|
|
18868
18876
|
});
|
|
18869
18877
|
|
|
18878
|
+
// packages/testkit-core/dist/embedded.js
|
|
18879
|
+
var EMBEDDED_CONTRACTS, EMBEDDED_PACKS;
|
|
18880
|
+
var init_embedded = __esm({
|
|
18881
|
+
"packages/testkit-core/dist/embedded.js"() {
|
|
18882
|
+
"use strict";
|
|
18883
|
+
EMBEDDED_CONTRACTS = { "envelope.schema.json": `{
|
|
18884
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
18885
|
+
"$id": "https://saktum.dev/schemas/envelope/0.1.json",
|
|
18886
|
+
"title": "Saktum canonical call envelope",
|
|
18887
|
+
"description": "Protocol-neutral description of one call between an agent and a service. Trust Check records calls in this shape; the gateway (2027) uses the same contract.",
|
|
18888
|
+
"type": "object",
|
|
18889
|
+
"required": [
|
|
18890
|
+
"envelopeFormat",
|
|
18891
|
+
"id",
|
|
18892
|
+
"protocol",
|
|
18893
|
+
"operation",
|
|
18894
|
+
"target",
|
|
18895
|
+
"timestamp"
|
|
18896
|
+
],
|
|
18897
|
+
"additionalProperties": false,
|
|
18898
|
+
"properties": {
|
|
18899
|
+
"envelopeFormat": {
|
|
18900
|
+
"const": "0.1"
|
|
18901
|
+
},
|
|
18902
|
+
"id": {
|
|
18903
|
+
"type": "string"
|
|
18904
|
+
},
|
|
18905
|
+
"protocol": {
|
|
18906
|
+
"enum": [
|
|
18907
|
+
"mcp",
|
|
18908
|
+
"a2a",
|
|
18909
|
+
"http"
|
|
18910
|
+
]
|
|
18911
|
+
},
|
|
18912
|
+
"operation": {
|
|
18913
|
+
"type": "string",
|
|
18914
|
+
"description": "e.g. tools/call"
|
|
18915
|
+
},
|
|
18916
|
+
"tool": {
|
|
18917
|
+
"type": "string"
|
|
18918
|
+
},
|
|
18919
|
+
"caller": {
|
|
18920
|
+
"type": "object",
|
|
18921
|
+
"properties": {
|
|
18922
|
+
"agent": {
|
|
18923
|
+
"type": "string"
|
|
18924
|
+
},
|
|
18925
|
+
"onBehalfOf": {
|
|
18926
|
+
"type": "string"
|
|
18927
|
+
}
|
|
18928
|
+
}
|
|
18929
|
+
},
|
|
18930
|
+
"target": {
|
|
18931
|
+
"type": "object",
|
|
18932
|
+
"required": [
|
|
18933
|
+
"service"
|
|
18934
|
+
],
|
|
18935
|
+
"properties": {
|
|
18936
|
+
"service": {
|
|
18937
|
+
"type": "string"
|
|
18938
|
+
},
|
|
18939
|
+
"version": {
|
|
18940
|
+
"type": "string"
|
|
18941
|
+
}
|
|
18942
|
+
}
|
|
18943
|
+
},
|
|
18944
|
+
"argumentsHash": {
|
|
18945
|
+
"type": "string",
|
|
18946
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
18947
|
+
},
|
|
18948
|
+
"timestamp": {
|
|
18949
|
+
"type": "string",
|
|
18950
|
+
"format": "date-time"
|
|
18951
|
+
},
|
|
18952
|
+
"context": {
|
|
18953
|
+
"type": "object",
|
|
18954
|
+
"additionalProperties": false,
|
|
18955
|
+
"description": "Optional governance context (Baseline 7.0): which task and business-process step this call belongs to. Policies may reference it; receipts echo it.",
|
|
18956
|
+
"properties": {
|
|
18957
|
+
"task": {
|
|
18958
|
+
"type": "object",
|
|
18959
|
+
"additionalProperties": false,
|
|
18960
|
+
"properties": {
|
|
18961
|
+
"id": {
|
|
18962
|
+
"type": "string"
|
|
18963
|
+
},
|
|
18964
|
+
"purpose": {
|
|
18965
|
+
"type": "string"
|
|
18966
|
+
},
|
|
18967
|
+
"permissions": {
|
|
18968
|
+
"type": "array",
|
|
18969
|
+
"items": {
|
|
18970
|
+
"type": "string"
|
|
18971
|
+
}
|
|
18972
|
+
}
|
|
18973
|
+
}
|
|
18974
|
+
},
|
|
18975
|
+
"process": {
|
|
18976
|
+
"type": "object",
|
|
18977
|
+
"additionalProperties": false,
|
|
18978
|
+
"properties": {
|
|
18979
|
+
"id": {
|
|
18980
|
+
"type": "string"
|
|
18981
|
+
},
|
|
18982
|
+
"name": {
|
|
18983
|
+
"type": "string"
|
|
18984
|
+
},
|
|
18985
|
+
"step": {
|
|
18986
|
+
"type": "string"
|
|
18987
|
+
}
|
|
18988
|
+
}
|
|
18989
|
+
},
|
|
18990
|
+
"orchestrator": {
|
|
18991
|
+
"type": "string",
|
|
18992
|
+
"description": "e.g. camunda, temporal, n8n"
|
|
18993
|
+
},
|
|
18994
|
+
"rationale": {
|
|
18995
|
+
"type": "string",
|
|
18996
|
+
"maxLength": 280,
|
|
18997
|
+
"description": "Optional short reason the agent states for this call (Baseline 7.9); recorded on the receipt so reasoning is auditable without storing conversations."
|
|
18998
|
+
},
|
|
18999
|
+
"executor": {
|
|
19000
|
+
"type": "object",
|
|
19001
|
+
"additionalProperties": false,
|
|
19002
|
+
"description": "Optional (Baseline 8.4): the orchestrator that carried out the action on the agent's behalf, so receipts distinguish who decided, who executed and who authorised.",
|
|
19003
|
+
"properties": {
|
|
19004
|
+
"type": {
|
|
19005
|
+
"type": "string",
|
|
19006
|
+
"description": "e.g. orchestrator, rpa, gateway"
|
|
19007
|
+
},
|
|
19008
|
+
"id": {
|
|
19009
|
+
"type": "string"
|
|
19010
|
+
},
|
|
19011
|
+
"name": {
|
|
19012
|
+
"type": "string"
|
|
19013
|
+
},
|
|
19014
|
+
"instance": {
|
|
19015
|
+
"type": "string"
|
|
19016
|
+
}
|
|
19017
|
+
}
|
|
19018
|
+
}
|
|
19019
|
+
}
|
|
19020
|
+
}
|
|
19021
|
+
}
|
|
19022
|
+
}
|
|
19023
|
+
`, "pack.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/pack/0.1.json",\n "title": "Saktum Trust Check test pack",\n "description": "A versioned set of checks. Packs are data, never code: steps use a closed set of actions, and any logic lives in named, engine-versioned analysers.",\n "type": "object",\n "required": [\n "packFormat",\n "id",\n "version",\n "category",\n "checks"\n ],\n "additionalProperties": false,\n "properties": {\n "packFormat": {\n "const": "0.1"\n },\n "id": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"\n },\n "version": {\n "type": "string",\n "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$"\n },\n "category": {\n "enum": [\n "conformance",\n "auth",\n "security",\n "agent-experience",\n "performance",\n "functional"\n ]\n },\n "description": {\n "type": "string"\n },\n "checks": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/check"\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n },\n "description": "Detached JWS over the canonical pack without this member. Required for packs from the feed (v0.2)."\n }\n },\n "$defs": {\n "check": {\n "type": "object",\n "required": [\n "id",\n "title",\n "severity",\n "safety",\n "steps",\n "fix"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string",\n "pattern": "^[a-z]+(\\\\.[a-z0-9-]+)+$"\n },\n "title": {\n "type": "string"\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "safety": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "scored": {\n "type": "boolean",\n "default": true\n },\n "appliesTo": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "transports": {\n "type": "array",\n "items": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n }\n },\n "protocol": {\n "type": "string",\n "description": "Minimum protocol revision, e.g. >=2025-03-26"\n }\n }\n },\n "steps": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/step"\n }\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "normative": {\n "type": "array",\n "description": "Baseline 4.1: the normative statements this check verifies, for the public traceability matrix.",\n "items": {\n "type": "object",\n "required": [\n "source",\n "level"\n ],\n "additionalProperties": false,\n "properties": {\n "source": {\n "type": "string",\n "description": "e.g. MCP specification, RFC 9728, OWASP MCP Top 10"\n },\n "version": {\n "type": "string",\n "description": "specification revision or date"\n },\n "clause": {\n "type": "string",\n "description": "section or requirement identifier"\n },\n "level": {\n "enum": [\n "MUST",\n "SHOULD",\n "MAY",\n "best-practice"\n ]\n }\n }\n }\n }\n }\n },\n "step": {\n "type": "object",\n "required": [\n "action"\n ],\n "additionalProperties": false,\n "properties": {\n "action": {\n "enum": [\n "mcp.initialize",\n "mcp.listTools",\n "mcp.callTool",\n "analyse"\n ]\n },\n "tool": {\n "type": "string"\n },\n "arguments": {\n "type": "object"\n },\n "analyser": {\n "type": "string"\n },\n "expect": {\n "$ref": "#/$defs/expectation"\n }\n }\n },\n "expectation": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "exists": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "isError": {\n "type": "boolean"\n },\n "errorCodeIn": {\n "type": "array",\n "items": {\n "type": "integer"\n }\n },\n "failed": {\n "type": "boolean",\n "description": "The call must not succeed: either a protocol error or a tool result flagged as an error."\n },\n "anyOf": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/expectation"\n }\n }\n }\n }\n }\n}\n', "receipt.schema.json": `{
|
|
19024
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
19025
|
+
"$id": "https://saktum.dev/schemas/receipt/0.1.json",
|
|
19026
|
+
"title": "Saktum receipt",
|
|
19027
|
+
"description": "A signed record of one call's outcome. Signatures use public-key cryptography so any third party can verify them without a shared secret.",
|
|
19028
|
+
"type": "object",
|
|
19029
|
+
"required": [
|
|
19030
|
+
"receiptFormat",
|
|
19031
|
+
"envelope",
|
|
19032
|
+
"outcome",
|
|
19033
|
+
"issuedAt",
|
|
19034
|
+
"signatures"
|
|
19035
|
+
],
|
|
19036
|
+
"additionalProperties": false,
|
|
19037
|
+
"properties": {
|
|
19038
|
+
"receiptFormat": {
|
|
19039
|
+
"const": "0.1"
|
|
19040
|
+
},
|
|
19041
|
+
"envelope": {
|
|
19042
|
+
"$ref": "https://saktum.dev/schemas/envelope/0.1.json"
|
|
19043
|
+
},
|
|
19044
|
+
"outcome": {
|
|
19045
|
+
"enum": [
|
|
19046
|
+
"allow",
|
|
19047
|
+
"deny",
|
|
19048
|
+
"error"
|
|
19049
|
+
]
|
|
19050
|
+
},
|
|
19051
|
+
"reason": {
|
|
19052
|
+
"type": "string"
|
|
19053
|
+
},
|
|
19054
|
+
"issuedAt": {
|
|
19055
|
+
"type": "string",
|
|
19056
|
+
"format": "date-time"
|
|
19057
|
+
},
|
|
19058
|
+
"signatures": {
|
|
19059
|
+
"type": "array",
|
|
19060
|
+
"minItems": 1,
|
|
19061
|
+
"items": {
|
|
19062
|
+
"type": "object",
|
|
19063
|
+
"required": [
|
|
19064
|
+
"alg",
|
|
19065
|
+
"kid",
|
|
19066
|
+
"jws"
|
|
19067
|
+
],
|
|
19068
|
+
"properties": {
|
|
19069
|
+
"alg": {
|
|
19070
|
+
"const": "EdDSA"
|
|
19071
|
+
},
|
|
19072
|
+
"kid": {
|
|
19073
|
+
"type": "string"
|
|
19074
|
+
},
|
|
19075
|
+
"jws": {
|
|
19076
|
+
"type": "string"
|
|
19077
|
+
}
|
|
19078
|
+
}
|
|
19079
|
+
}
|
|
19080
|
+
},
|
|
19081
|
+
"explanation": {
|
|
19082
|
+
"type": "string",
|
|
19083
|
+
"maxLength": 500,
|
|
19084
|
+
"description": "One plain-language sentence: what happened, which rule applied, who could have stopped it."
|
|
19085
|
+
},
|
|
19086
|
+
"context": {
|
|
19087
|
+
"$ref": "https://saktum.dev/schemas/envelope/0.1.json#/properties/context"
|
|
19088
|
+
},
|
|
19089
|
+
"compensates": {
|
|
19090
|
+
"type": "string",
|
|
19091
|
+
"description": "Optional (Baseline 8.4): id of the original envelope or receipt that this call reverses (compensation transaction)."
|
|
19092
|
+
}
|
|
19093
|
+
}
|
|
19094
|
+
}
|
|
19095
|
+
`, "result.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/result/0.1.json",\n "title": "Saktum Trust Check result",\n "description": "The canonical result of one run. Every report format is rendered from this model. Evidence is a hash plus a short, sanitised excerpt; raw payloads never appear.",\n "type": "object",\n "required": [\n "resultFormat",\n "tool",\n "target",\n "packs",\n "findings",\n "scores",\n "metrics",\n "run"\n ],\n "additionalProperties": false,\n "properties": {\n "resultFormat": {\n "const": "0.1"\n },\n "tool": {\n "type": "object",\n "required": [\n "name",\n "version"\n ],\n "additionalProperties": false,\n "properties": {\n "name": {\n "const": "saktum-trust-check"\n },\n "version": {\n "type": "string"\n }\n }\n },\n "target": {\n "type": "object",\n "required": [\n "transport",\n "description"\n ],\n "additionalProperties": false,\n "properties": {\n "transport": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n },\n "description": {\n "type": "string"\n },\n "protocolVersion": {\n "type": "string"\n },\n "serverInfo": {\n "type": "object"\n },\n "toolsFingerprint": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "packs": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "id",\n "version",\n "hash"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string"\n },\n "version": {\n "type": "string"\n },\n "hash": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n }\n }\n }\n },\n "findings": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/finding"\n }\n },\n "scores": {\n "type": "object",\n "required": [\n "overall",\n "capped",\n "categories"\n ],\n "additionalProperties": false,\n "properties": {\n "overall": {\n "type": [\n "integer",\n "null"\n ],\n "minimum": 0,\n "maximum": 100\n },\n "capped": {\n "type": "boolean"\n },\n "categories": {\n "type": "object",\n "additionalProperties": {\n "type": [\n "integer",\n "null"\n ]\n }\n }\n }\n },\n "metrics": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "contextCostTokens": {\n "type": "integer",\n "minimum": 0\n },\n "largestTools": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "tool",\n "tokens"\n ],\n "properties": {\n "tool": {\n "type": "string"\n },\n "tokens": {\n "type": "integer"\n }\n }\n }\n },\n "contextCostPer1kTurnsUsd": {\n "type": "number",\n "minimum": 0,\n "description": "Estimated cost of loading the tool definitions on 1,000 agent turns at pricePerMTokUsd. Reported only."\n },\n "pricePerMTokUsd": {\n "type": "number",\n "minimum": 0\n },\n "performance": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "initMs": {\n "type": "integer",\n "minimum": 0\n },\n "listMs": {\n "type": "integer",\n "minimum": 0\n },\n "listBytes": {\n "type": "integer",\n "minimum": 0\n },\n "rssMb": {\n "type": "number",\n "minimum": 0\n },\n "cpuPct": {\n "type": "number",\n "minimum": 0\n },\n "burst": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "requests": {\n "type": "integer"\n },\n "ok": {\n "type": "integer"\n },\n "rateLimited": {\n "type": "integer"\n },\n "errors": {\n "type": "integer"\n },\n "p95Ms": {\n "type": "integer"\n }\n }\n }\n }\n }\n }\n },\n "run": {\n "type": "object",\n "required": [\n "startedAt",\n "durationMs",\n "mode",\n "runner",\n "sandbox"\n ],\n "additionalProperties": false,\n "properties": {\n "startedAt": {\n "type": "string",\n "format": "date-time"\n },\n "durationMs": {\n "type": "integer",\n "minimum": 0\n },\n "mode": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "runner": {\n "enum": [\n "self",\n "hosted"\n ],\n "description": "self: run and signed by the user, proves integrity not independence. hosted: run and signed by Saktum (later)."\n },\n "sandbox": {\n "enum": [\n "none",\n "docker"\n ],\n "description": "Whether local servers ran inside a container sandbox."\n }\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n }\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ],\n "description": "Letter grade from the trust score: A 90-100, B 80-89, C 70-79, D 50-69, F below 50 or any failed critical check."\n },\n "summary": {\n "type": "array",\n "maxItems": 5,\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "description": "Plain-language summary sentences shown first in every report."\n },\n "assuranceLevel": {\n "enum": [\n "L1",\n "L2",\n "L3",\n "L4"\n ],\n "description": "L1 self-tested (Saktum Check); L2 independently tested; L3 certified; L4 continuously certified."\n },\n "readiness": {\n "description": "Agent readiness: a second grade beside trust (annotations, descriptions, context cost), never mixed into the trust score.",\n "oneOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "score",\n "grade",\n "toolsAnnotated",\n "toolsDescribed",\n "toolCount",\n "contextTokens"\n ],\n "properties": {\n "score": {\n "type": "integer",\n "minimum": 0,\n "maximum": 100\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ]\n },\n "toolsAnnotated": {\n "type": "integer",\n "minimum": 0\n },\n "toolsDescribed": {\n "type": "integer",\n "minimum": 0\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n },\n "contextTokens": {\n "type": "integer",\n "minimum": 0\n },\n "topImprovement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n ]\n },\n "coverage": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "trustChecksRun": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "capabilities": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capabilities",\n "lethalTrifecta",\n "note"\n ],\n "properties": {\n "capabilities": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capability",\n "label",\n "tools",\n "basis"\n ],\n "properties": {\n "capability": {\n "type": "string"\n },\n "label": {\n "type": "string",\n "maxLength": 400\n },\n "tools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "maxItems": 20\n },\n "basis": {\n "enum": [\n "declared",\n "inferred"\n ]\n }\n }\n }\n },\n "lethalTrifecta": {\n "type": "boolean"\n },\n "note": {\n "type": "string",\n "maxLength": 400\n }\n }\n },\n "functional": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "ran",\n "calledTools",\n "notCalled",\n "calls"\n ],\n "properties": {\n "ran": {\n "type": "boolean"\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n },\n "calledTools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "survived": {\n "type": "boolean"\n },\n "notCalled": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "why"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "why": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "calls": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "purpose",\n "outcome",\n "latencyMs",\n "problems"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "purpose": {\n "type": "string",\n "maxLength": 400\n },\n "outcome": {\n "type": "string",\n "maxLength": 400\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n },\n "load": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "operation",\n "latency",\n "levels",\n "verdicts"\n ],\n "properties": {\n "operation": {\n "type": "string",\n "maxLength": 400\n },\n "latency": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "p50": {\n "type": "number"\n },\n "p95": {\n "type": "number"\n },\n "samples": {\n "type": "integer"\n }\n }\n },\n "levels": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "concurrency",\n "requests",\n "ok",\n "rateLimited",\n "errors",\n "p95",\n "throughput"\n ],\n "properties": {\n "concurrency": {\n "type": "number",\n "minimum": 0\n },\n "requests": {\n "type": "number",\n "minimum": 0\n },\n "ok": {\n "type": "number",\n "minimum": 0\n },\n "rateLimited": {\n "type": "number",\n "minimum": 0\n },\n "errors": {\n "type": "number",\n "minimum": 0\n },\n "p95": {\n "type": "number",\n "minimum": 0\n },\n "throughput": {\n "type": "number",\n "minimum": 0\n }\n }\n }\n },\n "memoryGrowthMb": {\n "type": "number"\n },\n "verdicts": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "id",\n "tool",\n "status",\n "problems"\n ],\n "properties": {\n "id": {\n "type": "string",\n "maxLength": 400\n },\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped"\n ]\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n }\n }\n }\n },\n "suppressions": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "check",\n "reason"\n ],\n "properties": {\n "check": {\n "type": "string",\n "maxLength": 400\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n },\n "$defs": {\n "finding": {\n "type": "object",\n "required": [\n "check",\n "pack",\n "status",\n "severity",\n "title"\n ],\n "additionalProperties": false,\n "properties": {\n "check": {\n "type": "string"\n },\n "pack": {\n "type": "string"\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped",\n "inconclusive",\n "info"\n ]\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "scored": {\n "type": "boolean"\n },\n "title": {\n "type": "string"\n },\n "subject": {\n "type": "string"\n },\n "message": {\n "type": "string"\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "evidence": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "hash": {\n "type": "string"\n },\n "excerpt": {\n "type": "string",\n "maxLength": 240\n }\n }\n },\n "suppressed": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "reason"\n ],\n "properties": {\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n}\n', "test-cases.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/test-cases/0.1.json",\n "title": "Saktum Trust Check functional test cases (saktum.tests.yaml)",\n "type": "object",\n "required": ["testsFormat", "tests"],\n "additionalProperties": false,\n "properties": {\n "testsFormat": { "const": "0.1" },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "required": ["id", "tool", "input", "expect"],\n "additionalProperties": false,\n "properties": {\n "id": { "type": "string" },\n "tool": { "type": "string" },\n "input": { "type": "object" },\n "sideEffects": { "type": "boolean", "default": false, "description": "Tests with side effects run only against owned targets." },\n "expect": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "isError": { "type": "boolean" },\n "textContains": { "type": "string" },\n "structured": { "type": "object" },\n "outputSchema": { "type": "boolean" },\n "latencyMs": { "type": "object", "properties": { "lt": { "type": "integer" } }, "additionalProperties": false }\n }\n }\n }\n }\n }\n }\n}\n' };
|
|
19096
|
+
EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n', "auth.yaml": `packFormat: "0.1"
|
|
19097
|
+
id: auth
|
|
19098
|
+
version: 0.1.0
|
|
19099
|
+
category: auth
|
|
19100
|
+
description: Sign-in for remote servers, checked from the outside without credentials. Follows the MCP authorization specification and the OAuth RFCs it builds on.
|
|
19101
|
+
checks:
|
|
19102
|
+
- id: auth.https
|
|
19103
|
+
title: Served over HTTPS
|
|
19104
|
+
severity: critical
|
|
19105
|
+
safety: passive
|
|
19106
|
+
appliesTo: { transports: [streamable-http] }
|
|
19107
|
+
steps: [{ action: analyse, analyser: auth-https }]
|
|
19108
|
+
fix: Serve the MCP endpoint over HTTPS (plain HTTP only on localhost during development).
|
|
19109
|
+
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization", "CWE-319"]
|
|
19110
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Authorization: communication security", level: MUST }, { source: "RFC 9700", clause: "OAuth security best current practice: TLS", level: MUST }]
|
|
19111
|
+
- id: auth.unauthenticated
|
|
19112
|
+
title: Whether sign-in is required
|
|
19113
|
+
severity: info
|
|
19114
|
+
safety: passive
|
|
19115
|
+
scored: false
|
|
19116
|
+
appliesTo: { transports: [streamable-http] }
|
|
19117
|
+
steps: [{ action: analyse, analyser: auth-unauthenticated }]
|
|
19118
|
+
fix: Require OAuth sign-in for any server that exposes user data or actions.
|
|
19119
|
+
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19120
|
+
- id: auth.www-authenticate
|
|
19121
|
+
title: Refusals point clients to the resource metadata
|
|
19122
|
+
severity: high
|
|
19123
|
+
safety: passive
|
|
19124
|
+
appliesTo: { transports: [streamable-http] }
|
|
19125
|
+
steps: [{ action: analyse, analyser: auth-www-authenticate }]
|
|
19126
|
+
fix: Answer unauthenticated requests with 401 and a header such as WWW-Authenticate Bearer resource_metadata="https://your-server/.well-known/oauth-protected-resource".
|
|
19127
|
+
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19128
|
+
normative: [{ source: "RFC 9728", clause: "Section 5.1, WWW-Authenticate response", level: MUST }, { source: "MCP specification", version: "verify-latest", clause: "Authorization: authorization server discovery", level: MUST }]
|
|
19129
|
+
- id: auth.resource-metadata
|
|
19130
|
+
title: Protected resource metadata is published and correct
|
|
19131
|
+
severity: high
|
|
19132
|
+
safety: passive
|
|
19133
|
+
appliesTo: { transports: [streamable-http] }
|
|
19134
|
+
steps: [{ action: analyse, analyser: auth-resource-metadata }]
|
|
19135
|
+
fix: Publish /.well-known/oauth-protected-resource with "resource" set to this server's URL and "authorization_servers" listing your HTTPS authorization server.
|
|
19136
|
+
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19137
|
+
normative: [{ source: "RFC 9728", clause: "Sections 2 and 3, metadata and well-known URI", level: MUST }]
|
|
19138
|
+
- id: auth.server-metadata
|
|
19139
|
+
title: Authorization server metadata is complete, with PKCE
|
|
19140
|
+
severity: high
|
|
19141
|
+
safety: passive
|
|
19142
|
+
appliesTo: { transports: [streamable-http] }
|
|
19143
|
+
steps: [{ action: analyse, analyser: auth-server-metadata }]
|
|
19144
|
+
fix: Publish RFC 8414 metadata with issuer, HTTPS authorization and token endpoints, the code response type, and code_challenge_methods_supported including S256.
|
|
19145
|
+
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19146
|
+
normative: [{ source: "RFC 8414", clause: "Sections 2 and 3", level: MUST }, { source: "RFC 7636", clause: "PKCE with S256", level: MUST }, { source: "MCP specification", version: "verify-latest", clause: "Authorization: PKCE required", level: MUST }]
|
|
19147
|
+
- id: auth.invalid-token
|
|
19148
|
+
title: Invalid tokens are rejected
|
|
19149
|
+
severity: critical
|
|
19150
|
+
safety: passive
|
|
19151
|
+
appliesTo: { transports: [streamable-http] }
|
|
19152
|
+
steps: [{ action: analyse, analyser: auth-invalid-token }]
|
|
19153
|
+
fix: Validate every bearer token (signature or introspection, expiry, audience) and answer invalid ones with 401 and error="invalid_token".
|
|
19154
|
+
references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization", "CWE-287"]
|
|
19155
|
+
normative: [{ source: "RFC 6750", clause: "Section 3.1, invalid_token", level: MUST }]
|
|
19156
|
+
`, "conformance.yaml": `packFormat: "0.1"
|
|
19157
|
+
id: conformance
|
|
19158
|
+
version: 0.1.0
|
|
19159
|
+
category: conformance
|
|
19160
|
+
description: Does the server speak MCP correctly? Basis for every other check.
|
|
19161
|
+
checks:
|
|
19162
|
+
- id: conf.init.handshake
|
|
19163
|
+
title: Initialize returns server info and capabilities
|
|
19164
|
+
severity: high
|
|
19165
|
+
safety: passive
|
|
19166
|
+
steps: [{ action: analyse, analyser: handshake }]
|
|
19167
|
+
fix: Return serverInfo (name, version) and a capabilities object from initialize.
|
|
19168
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Lifecycle: initialization (server returns capabilities and serverInfo)", level: MUST }]
|
|
19169
|
+
references: ["MCP specification: lifecycle"]
|
|
19170
|
+
- id: conf.tools.list
|
|
19171
|
+
title: Tool list is returned
|
|
19172
|
+
severity: high
|
|
19173
|
+
safety: passive
|
|
19174
|
+
steps: [{ action: mcp.listTools, expect: { exists: [tools] } }]
|
|
19175
|
+
fix: Implement tools/list and return a tools array (empty if you have none).
|
|
19176
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Server features: tools, listing tools", level: MUST }]
|
|
19177
|
+
references: ["MCP specification: tools"]
|
|
19178
|
+
- id: conf.tools.schema-valid
|
|
19179
|
+
title: Every input schema is a valid JSON Schema object
|
|
19180
|
+
severity: high
|
|
19181
|
+
safety: passive
|
|
19182
|
+
steps: [{ action: analyse, analyser: tool-input-schemas }]
|
|
19183
|
+
fix: Give every tool an inputSchema of type "object" that compiles as JSON Schema.
|
|
19184
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Tools: inputSchema is a JSON Schema object", level: MUST }]
|
|
19185
|
+
references: ["MCP specification: tools", "JSON Schema 2020-12", "OWASP MCP Top 10: MCP05 Command Injection and Execution (input validation)"]
|
|
19186
|
+
- id: conf.tools.names
|
|
19187
|
+
title: Tool names are unique and use allowed characters
|
|
19188
|
+
severity: medium
|
|
19189
|
+
safety: passive
|
|
19190
|
+
steps: [{ action: analyse, analyser: tool-names }]
|
|
19191
|
+
fix: Use unique names of 1 to 128 characters from A-Z, a-z, 0-9, underscore, dot and hyphen.
|
|
19192
|
+
references: ["MCP specification: tools"]
|
|
19193
|
+
- id: conf.tools.unknown-not-success
|
|
19194
|
+
title: Calling an unknown tool does not succeed
|
|
19195
|
+
severity: high
|
|
19196
|
+
safety: passive
|
|
19197
|
+
steps:
|
|
19198
|
+
- action: mcp.callTool
|
|
19199
|
+
tool: saktum_trust_check_no_such_tool
|
|
19200
|
+
arguments: {}
|
|
19201
|
+
expect: { failed: true }
|
|
19202
|
+
fix: Return an error for unknown tool names; never a successful result.
|
|
19203
|
+
references: ["MCP specification: tools, error handling", "OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (false success hides actions)"]
|
|
19204
|
+
- id: conf.tools.unknown-error-code
|
|
19205
|
+
title: Error code for unknown tools
|
|
19206
|
+
severity: info
|
|
19207
|
+
safety: passive
|
|
19208
|
+
scored: false
|
|
19209
|
+
steps: [{ action: analyse, analyser: unknown-tool-code }]
|
|
19210
|
+
fix: Answer an unknown tool name with a JSON-RPC error; the specification's example uses -32602 (invalid params).
|
|
19211
|
+
references: ["MCP specification: tools, error handling", "JSON-RPC 2.0"]
|
|
19212
|
+
`, "functional.yaml": `packFormat: "0.1"
|
|
19213
|
+
id: functional
|
|
19214
|
+
version: 0.1.0
|
|
19215
|
+
category: functional
|
|
19216
|
+
description: Do the tools actually work? Smoke calls with arguments generated from each tool's schema, output validation and robustness. Runs only with --active, and only on tools annotated read-only unless named with --call.
|
|
19217
|
+
checks:
|
|
19218
|
+
- id: func.tools.respond
|
|
19219
|
+
title: Tools respond to valid arguments
|
|
19220
|
+
severity: high
|
|
19221
|
+
safety: active
|
|
19222
|
+
steps: [{ action: analyse, analyser: func-respond }]
|
|
19223
|
+
fix: Accept every argument set that satisfies the tool's own input schema, and answer within the client's timeout.
|
|
19224
|
+
references: ["MCP specification: tools, calling tools"]
|
|
19225
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Tools: calling tools", level: MUST }]
|
|
19226
|
+
- id: func.output.valid
|
|
19227
|
+
title: Results are well-formed and match the declared output schema
|
|
19228
|
+
severity: high
|
|
19229
|
+
safety: active
|
|
19230
|
+
steps: [{ action: analyse, analyser: func-output }]
|
|
19231
|
+
fix: Return content as an array of typed items, and when a tool declares an outputSchema, return structuredContent that conforms to it.
|
|
19232
|
+
references: ["MCP specification: tools, structured content and output schema"]
|
|
19233
|
+
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Tools: output schema (servers MUST provide structured results that conform)", level: MUST }]
|
|
19234
|
+
- id: func.errors.graceful
|
|
19235
|
+
title: Invalid arguments are rejected gracefully
|
|
19236
|
+
severity: medium
|
|
19237
|
+
safety: active
|
|
19238
|
+
steps: [{ action: analyse, analyser: func-invalid }]
|
|
19239
|
+
fix: Validate arguments against the input schema and return an error result or JSON-RPC -32602 with a short, helpful message; never crash, hang or expose internals.
|
|
19240
|
+
references: ["MCP specification: tools, error handling", "CWE-20", "CWE-209", "OWASP MCP Top 10: MCP05 Command Injection and Execution (input validation)"]
|
|
19241
|
+
- id: func.server.survives
|
|
19242
|
+
title: The server keeps working after the functional calls
|
|
19243
|
+
severity: high
|
|
19244
|
+
safety: active
|
|
19245
|
+
steps: [{ action: analyse, analyser: func-survives }]
|
|
19246
|
+
fix: Catch errors per request so one bad call cannot stop the server.
|
|
19247
|
+
`, "performance.yaml": `packFormat: "0.1"
|
|
19248
|
+
id: performance
|
|
19249
|
+
version: 0.1.0
|
|
19250
|
+
category: performance
|
|
19251
|
+
description: Speed and resource use, reported as information and never part of the trust score. The burst test runs only with --active.
|
|
19252
|
+
checks:
|
|
19253
|
+
- id: perf.startup
|
|
19254
|
+
title: Start-up and handshake time
|
|
19255
|
+
severity: info
|
|
19256
|
+
safety: passive
|
|
19257
|
+
scored: false
|
|
19258
|
+
steps: [{ action: analyse, analyser: perf-startup }]
|
|
19259
|
+
fix: Defer heavy initialisation until the first call that needs it; agents and clients time out on slow starts.
|
|
19260
|
+
- id: perf.latency
|
|
19261
|
+
title: Tool-list latency and size
|
|
19262
|
+
severity: info
|
|
19263
|
+
safety: passive
|
|
19264
|
+
scored: false
|
|
19265
|
+
steps: [{ action: analyse, analyser: perf-latency }]
|
|
19266
|
+
fix: Keep tools/list fast and small; cache it and trim long descriptions.
|
|
19267
|
+
- id: perf.memory
|
|
19268
|
+
title: Memory and CPU of a local server
|
|
19269
|
+
severity: info
|
|
19270
|
+
safety: passive
|
|
19271
|
+
scored: false
|
|
19272
|
+
appliesTo: { transports: [stdio] }
|
|
19273
|
+
steps: [{ action: analyse, analyser: perf-memory }]
|
|
19274
|
+
fix: Reduce idle memory and CPU; local servers run beside the user's other tools.
|
|
19275
|
+
- id: perf.concurrency
|
|
19276
|
+
title: Latency percentiles and behaviour at 1, 5 and 20 concurrent callers
|
|
19277
|
+
severity: info
|
|
19278
|
+
safety: active
|
|
19279
|
+
scored: false
|
|
19280
|
+
steps: [{ action: analyse, analyser: perf-concurrency }]
|
|
19281
|
+
fix: Keep p95 latency low, answer overload with HTTP 429 and Retry-After instead of errors, and set limits per client.
|
|
19282
|
+
references: ["OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (resource abuse)", "CWE-770"]
|
|
19283
|
+
`, "security.yaml": 'packFormat: "0.1"\nid: security\nversion: 0.1.0\ncategory: security\ndescription: Passive security checks on what the server tells agents and users.\nchecks:\n - id: sec.description.hidden-instructions\n title: No instructions to the agent in tool descriptions or schemas\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: hidden-instructions }]\n fix: Describe what each tool does; never instruct the agent (for example to read other data, send data elsewhere or hide actions from the user).\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP03 Tool Poisoning", level: best-practice }]\n references: ["MCP security best practices", "CWE-1427", "OWASP MCP Top 10: MCP03 Tool Poisoning", "OWASP MCP Top 10: MCP06 Intent Flow Subversion"]\n - id: sec.description.invisible-text\n title: No invisible or bidirectional control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: invisible-text }]\n fix: Remove zero-width and bidirectional control characters from names, descriptions and schemas.\n references: ["CWE-1007", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.description.control-characters\n title: No escape sequences or control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: control-characters }]\n fix: Remove terminal escape sequences and control characters; clients may print tool text to a terminal.\n references: ["CWE-150", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.secrets.exposed\n title: No secrets in tool definitions or responses\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: secrets }]\n fix: Remove keys, tokens and passwords from descriptions, schemas, defaults, examples and error messages; load them from a secret store at runtime.\n references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "CWE-798", "CWE-200"]\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP01 Token Mismanagement and Secret Exposure", level: best-practice }]\n - id: sec.errors.leakage\n title: Errors do not expose internals\n severity: medium\n safety: passive\n steps: [{ action: analyse, analyser: error-leakage }]\n fix: Return short, actionable error messages; log stack traces, file paths and database errors on the server only.\n references: ["OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (errors leak internals)", "CWE-209"]\n normative: [{ source: "OWASP MCP Top 10", clause: "Information exposure through errors", level: best-practice }]\n\n' };
|
|
19284
|
+
}
|
|
19285
|
+
});
|
|
19286
|
+
|
|
19287
|
+
// packages/testkit-core/dist/contracts.js
|
|
19288
|
+
var contracts_exports = {};
|
|
19289
|
+
__export(contracts_exports, {
|
|
19290
|
+
compileContract: () => compileContract,
|
|
19291
|
+
compileUntrustedSchema: () => compileUntrustedSchema,
|
|
19292
|
+
compileUntrustedSchemaValidator: () => compileUntrustedSchemaValidator,
|
|
19293
|
+
contractText: () => contractText,
|
|
19294
|
+
contractsDir: () => contractsDir,
|
|
19295
|
+
schemaDialect: () => schemaDialect
|
|
19296
|
+
});
|
|
19297
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
19298
|
+
import { fileURLToPath } from "node:url";
|
|
19299
|
+
function contractText(f) {
|
|
19300
|
+
if (existsSync2(contractsDir + f))
|
|
19301
|
+
return readFileSync2(contractsDir + f, "utf8");
|
|
19302
|
+
const t = EMBEDDED_CONTRACTS[f];
|
|
19303
|
+
if (!t)
|
|
19304
|
+
throw new Error(`contract ${f} not found`);
|
|
19305
|
+
return t;
|
|
19306
|
+
}
|
|
19307
|
+
function compileContract(file) {
|
|
19308
|
+
const v = ajv.getSchema(file);
|
|
19309
|
+
if (!v)
|
|
19310
|
+
throw new Error(`unknown contract ${file}`);
|
|
19311
|
+
return v;
|
|
19312
|
+
}
|
|
19313
|
+
function schemaDialect(schema) {
|
|
19314
|
+
const id = schema && typeof schema === "object" ? schema.$schema : void 0;
|
|
19315
|
+
if (id === void 0)
|
|
19316
|
+
return "2020-12";
|
|
19317
|
+
const s = String(id);
|
|
19318
|
+
if (/draft-04/.test(s))
|
|
19319
|
+
return "draft-04";
|
|
19320
|
+
if (/draft-06/.test(s))
|
|
19321
|
+
return "draft-06";
|
|
19322
|
+
if (/draft-07/.test(s))
|
|
19323
|
+
return "draft-07";
|
|
19324
|
+
if (/2019-09/.test(s))
|
|
19325
|
+
return "2019-09";
|
|
19326
|
+
if (/2020-12/.test(s))
|
|
19327
|
+
return "2020-12";
|
|
19328
|
+
return "unknown";
|
|
19329
|
+
}
|
|
19330
|
+
function compileUntrustedSchema(schema) {
|
|
19331
|
+
try {
|
|
19332
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
19333
|
+
return { ok: false, error: "the schema is not a JSON object" };
|
|
19334
|
+
const dialect = schemaDialect(schema);
|
|
19335
|
+
if (dialect === "unknown")
|
|
19336
|
+
return { ok: false, error: `unrecognised $schema dialect ${JSON.stringify(schema.$schema).slice(0, 80)}` };
|
|
19337
|
+
const { $schema: _ignored, ...body } = schema;
|
|
19338
|
+
const Ctor = dialect === "2020-12" ? Ajv2020 : dialect === "2019-09" ? Ajv2019 : AjvDraft7;
|
|
19339
|
+
new Ctor({ strict: false, allErrors: false, validateSchema: true, logger: false }).compile(body);
|
|
19340
|
+
return { ok: true };
|
|
19341
|
+
} catch (e) {
|
|
19342
|
+
return { ok: false, error: e.message };
|
|
19343
|
+
}
|
|
19344
|
+
}
|
|
19345
|
+
function compileUntrustedSchemaValidator(schema) {
|
|
19346
|
+
try {
|
|
19347
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
19348
|
+
return { ok: false, error: "the schema is not a JSON object" };
|
|
19349
|
+
const dialect = schemaDialect(schema);
|
|
19350
|
+
if (dialect === "unknown")
|
|
19351
|
+
return { ok: false, error: "unrecognised $schema dialect" };
|
|
19352
|
+
const { $schema: _ignored, ...body } = schema;
|
|
19353
|
+
const Ctor = dialect === "2020-12" ? Ajv2020 : dialect === "2019-09" ? Ajv2019 : AjvDraft7;
|
|
19354
|
+
const ajv2 = new Ctor({ strict: false, allErrors: false, validateSchema: true, logger: false });
|
|
19355
|
+
const fn = ajv2.compile(body);
|
|
19356
|
+
return { ok: true, validate: (d) => Boolean(fn(d)), errors: () => (fn.errors ?? []).map((e) => `${e.instancePath || "/"} ${e.message ?? ""}`).join("; ") };
|
|
19357
|
+
} catch (e) {
|
|
19358
|
+
return { ok: false, error: e.message };
|
|
19359
|
+
}
|
|
19360
|
+
}
|
|
19361
|
+
var Ajv2020Module, Ajv2019Module, AjvDraft7Module, addFormatsModule, pick, Ajv2020, Ajv2019, AjvDraft7, addFormats, contractsDir, ajv;
|
|
19362
|
+
var init_contracts = __esm({
|
|
19363
|
+
"packages/testkit-core/dist/contracts.js"() {
|
|
19364
|
+
"use strict";
|
|
19365
|
+
Ajv2020Module = __toESM(require__(), 1);
|
|
19366
|
+
Ajv2019Module = __toESM(require__2(), 1);
|
|
19367
|
+
AjvDraft7Module = __toESM(require_ajv(), 1);
|
|
19368
|
+
addFormatsModule = __toESM(require_dist2(), 1);
|
|
19369
|
+
init_embedded();
|
|
19370
|
+
pick = (m) => {
|
|
19371
|
+
let x = m;
|
|
19372
|
+
while (x && typeof x !== "function" && x.default)
|
|
19373
|
+
x = x.default;
|
|
19374
|
+
return x;
|
|
19375
|
+
};
|
|
19376
|
+
Ajv2020 = pick(Ajv2020Module);
|
|
19377
|
+
Ajv2019 = pick(Ajv2019Module);
|
|
19378
|
+
AjvDraft7 = pick(AjvDraft7Module);
|
|
19379
|
+
addFormats = pick(addFormatsModule);
|
|
19380
|
+
contractsDir = fileURLToPath(new URL("../../../contracts/", import.meta.url));
|
|
19381
|
+
ajv = new Ajv2020({ allErrors: true, strict: false });
|
|
19382
|
+
addFormats(ajv);
|
|
19383
|
+
for (const f of ["envelope.schema.json", "receipt.schema.json", "pack.schema.json", "result.schema.json", "test-cases.schema.json"]) {
|
|
19384
|
+
ajv.addSchema(JSON.parse(contractText(f)), f);
|
|
19385
|
+
}
|
|
19386
|
+
}
|
|
19387
|
+
});
|
|
19388
|
+
|
|
18870
19389
|
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
18871
19390
|
var require_windows = __commonJS({
|
|
18872
19391
|
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
@@ -19381,12 +19900,12 @@ var require_content_type = __commonJS({
|
|
|
19381
19900
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
19382
19901
|
exports.format = format;
|
|
19383
19902
|
exports.parse = parse3;
|
|
19384
|
-
function format(
|
|
19385
|
-
if (!
|
|
19903
|
+
function format(obj2) {
|
|
19904
|
+
if (!obj2 || typeof obj2 !== "object") {
|
|
19386
19905
|
throw new TypeError("argument obj is required");
|
|
19387
19906
|
}
|
|
19388
|
-
var parameters =
|
|
19389
|
-
var type =
|
|
19907
|
+
var parameters = obj2.parameters;
|
|
19908
|
+
var type = obj2.type;
|
|
19390
19909
|
if (!type || !TYPE_REGEXP.test(type)) {
|
|
19391
19910
|
throw new TypeError("invalid type");
|
|
19392
19911
|
}
|
|
@@ -19417,7 +19936,7 @@ var require_content_type = __commonJS({
|
|
|
19417
19936
|
if (!TYPE_REGEXP.test(type)) {
|
|
19418
19937
|
throw new TypeError("invalid media type");
|
|
19419
19938
|
}
|
|
19420
|
-
var
|
|
19939
|
+
var obj2 = new ContentType(type.toLowerCase());
|
|
19421
19940
|
if (index !== -1) {
|
|
19422
19941
|
var key;
|
|
19423
19942
|
var match;
|
|
@@ -19436,20 +19955,20 @@ var require_content_type = __commonJS({
|
|
|
19436
19955
|
value = value.replace(QESC_REGEXP, "$1");
|
|
19437
19956
|
}
|
|
19438
19957
|
}
|
|
19439
|
-
|
|
19958
|
+
obj2.parameters[key] = value;
|
|
19440
19959
|
}
|
|
19441
19960
|
if (index !== header.length) {
|
|
19442
19961
|
throw new TypeError("invalid parameter format");
|
|
19443
19962
|
}
|
|
19444
19963
|
}
|
|
19445
|
-
return
|
|
19964
|
+
return obj2;
|
|
19446
19965
|
}
|
|
19447
|
-
function getcontenttype(
|
|
19966
|
+
function getcontenttype(obj2) {
|
|
19448
19967
|
var header;
|
|
19449
|
-
if (typeof
|
|
19450
|
-
header =
|
|
19451
|
-
} else if (typeof
|
|
19452
|
-
header =
|
|
19968
|
+
if (typeof obj2.getHeader === "function") {
|
|
19969
|
+
header = obj2.getHeader("content-type");
|
|
19970
|
+
} else if (typeof obj2.headers === "object") {
|
|
19971
|
+
header = obj2.headers && obj2.headers["content-type"];
|
|
19453
19972
|
}
|
|
19454
19973
|
if (typeof header !== "string") {
|
|
19455
19974
|
throw new TypeError("content-type header is missing from object");
|
|
@@ -19532,9 +20051,9 @@ function canonicalize(value) {
|
|
|
19532
20051
|
if (Array.isArray(value))
|
|
19533
20052
|
return "[" + value.map((v) => v === void 0 ? "null" : canonicalize(v)).join(",") + "]";
|
|
19534
20053
|
if (typeof value === "object") {
|
|
19535
|
-
const
|
|
19536
|
-
const keys = Object.keys(
|
|
19537
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalize(
|
|
20054
|
+
const obj2 = value;
|
|
20055
|
+
const keys = Object.keys(obj2).filter((k) => obj2[k] !== void 0).sort();
|
|
20056
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalize(obj2[k])).join(",") + "}";
|
|
19538
20057
|
}
|
|
19539
20058
|
throw new Error(`canonicalize: unsupported type ${typeof value}`);
|
|
19540
20059
|
}
|
|
@@ -19639,450 +20158,9 @@ function verifyDocument(doc) {
|
|
|
19639
20158
|
return ok ? { valid: true, kid: s.kid } : { valid: false, kid: s.kid, reason: "signature does not match content" };
|
|
19640
20159
|
}
|
|
19641
20160
|
|
|
19642
|
-
// packages/testkit-core/dist/contracts.js
|
|
19643
|
-
var Ajv2020Module = __toESM(require__(), 1);
|
|
19644
|
-
var Ajv2019Module = __toESM(require__2(), 1);
|
|
19645
|
-
var AjvDraft7Module = __toESM(require_ajv(), 1);
|
|
19646
|
-
var addFormatsModule = __toESM(require_dist2(), 1);
|
|
19647
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
19648
|
-
import { fileURLToPath } from "node:url";
|
|
19649
|
-
|
|
19650
|
-
// packages/testkit-core/dist/embedded.js
|
|
19651
|
-
var EMBEDDED_CONTRACTS = { "envelope.schema.json": `{
|
|
19652
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
19653
|
-
"$id": "https://saktum.dev/schemas/envelope/0.1.json",
|
|
19654
|
-
"title": "Saktum canonical call envelope",
|
|
19655
|
-
"description": "Protocol-neutral description of one call between an agent and a service. Trust Check records calls in this shape; the gateway (2027) uses the same contract.",
|
|
19656
|
-
"type": "object",
|
|
19657
|
-
"required": [
|
|
19658
|
-
"envelopeFormat",
|
|
19659
|
-
"id",
|
|
19660
|
-
"protocol",
|
|
19661
|
-
"operation",
|
|
19662
|
-
"target",
|
|
19663
|
-
"timestamp"
|
|
19664
|
-
],
|
|
19665
|
-
"additionalProperties": false,
|
|
19666
|
-
"properties": {
|
|
19667
|
-
"envelopeFormat": {
|
|
19668
|
-
"const": "0.1"
|
|
19669
|
-
},
|
|
19670
|
-
"id": {
|
|
19671
|
-
"type": "string"
|
|
19672
|
-
},
|
|
19673
|
-
"protocol": {
|
|
19674
|
-
"enum": [
|
|
19675
|
-
"mcp",
|
|
19676
|
-
"a2a",
|
|
19677
|
-
"http"
|
|
19678
|
-
]
|
|
19679
|
-
},
|
|
19680
|
-
"operation": {
|
|
19681
|
-
"type": "string",
|
|
19682
|
-
"description": "e.g. tools/call"
|
|
19683
|
-
},
|
|
19684
|
-
"tool": {
|
|
19685
|
-
"type": "string"
|
|
19686
|
-
},
|
|
19687
|
-
"caller": {
|
|
19688
|
-
"type": "object",
|
|
19689
|
-
"properties": {
|
|
19690
|
-
"agent": {
|
|
19691
|
-
"type": "string"
|
|
19692
|
-
},
|
|
19693
|
-
"onBehalfOf": {
|
|
19694
|
-
"type": "string"
|
|
19695
|
-
}
|
|
19696
|
-
}
|
|
19697
|
-
},
|
|
19698
|
-
"target": {
|
|
19699
|
-
"type": "object",
|
|
19700
|
-
"required": [
|
|
19701
|
-
"service"
|
|
19702
|
-
],
|
|
19703
|
-
"properties": {
|
|
19704
|
-
"service": {
|
|
19705
|
-
"type": "string"
|
|
19706
|
-
},
|
|
19707
|
-
"version": {
|
|
19708
|
-
"type": "string"
|
|
19709
|
-
}
|
|
19710
|
-
}
|
|
19711
|
-
},
|
|
19712
|
-
"argumentsHash": {
|
|
19713
|
-
"type": "string",
|
|
19714
|
-
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
19715
|
-
},
|
|
19716
|
-
"timestamp": {
|
|
19717
|
-
"type": "string",
|
|
19718
|
-
"format": "date-time"
|
|
19719
|
-
},
|
|
19720
|
-
"context": {
|
|
19721
|
-
"type": "object",
|
|
19722
|
-
"additionalProperties": false,
|
|
19723
|
-
"description": "Optional governance context (Baseline 7.0): which task and business-process step this call belongs to. Policies may reference it; receipts echo it.",
|
|
19724
|
-
"properties": {
|
|
19725
|
-
"task": {
|
|
19726
|
-
"type": "object",
|
|
19727
|
-
"additionalProperties": false,
|
|
19728
|
-
"properties": {
|
|
19729
|
-
"id": {
|
|
19730
|
-
"type": "string"
|
|
19731
|
-
},
|
|
19732
|
-
"purpose": {
|
|
19733
|
-
"type": "string"
|
|
19734
|
-
},
|
|
19735
|
-
"permissions": {
|
|
19736
|
-
"type": "array",
|
|
19737
|
-
"items": {
|
|
19738
|
-
"type": "string"
|
|
19739
|
-
}
|
|
19740
|
-
}
|
|
19741
|
-
}
|
|
19742
|
-
},
|
|
19743
|
-
"process": {
|
|
19744
|
-
"type": "object",
|
|
19745
|
-
"additionalProperties": false,
|
|
19746
|
-
"properties": {
|
|
19747
|
-
"id": {
|
|
19748
|
-
"type": "string"
|
|
19749
|
-
},
|
|
19750
|
-
"name": {
|
|
19751
|
-
"type": "string"
|
|
19752
|
-
},
|
|
19753
|
-
"step": {
|
|
19754
|
-
"type": "string"
|
|
19755
|
-
}
|
|
19756
|
-
}
|
|
19757
|
-
},
|
|
19758
|
-
"orchestrator": {
|
|
19759
|
-
"type": "string",
|
|
19760
|
-
"description": "e.g. camunda, temporal, n8n"
|
|
19761
|
-
},
|
|
19762
|
-
"rationale": {
|
|
19763
|
-
"type": "string",
|
|
19764
|
-
"maxLength": 280,
|
|
19765
|
-
"description": "Optional short reason the agent states for this call (Baseline 7.9); recorded on the receipt so reasoning is auditable without storing conversations."
|
|
19766
|
-
},
|
|
19767
|
-
"executor": {
|
|
19768
|
-
"type": "object",
|
|
19769
|
-
"additionalProperties": false,
|
|
19770
|
-
"description": "Optional (Baseline 8.4): the orchestrator that carried out the action on the agent's behalf, so receipts distinguish who decided, who executed and who authorised.",
|
|
19771
|
-
"properties": {
|
|
19772
|
-
"type": {
|
|
19773
|
-
"type": "string",
|
|
19774
|
-
"description": "e.g. orchestrator, rpa, gateway"
|
|
19775
|
-
},
|
|
19776
|
-
"id": {
|
|
19777
|
-
"type": "string"
|
|
19778
|
-
},
|
|
19779
|
-
"name": {
|
|
19780
|
-
"type": "string"
|
|
19781
|
-
},
|
|
19782
|
-
"instance": {
|
|
19783
|
-
"type": "string"
|
|
19784
|
-
}
|
|
19785
|
-
}
|
|
19786
|
-
}
|
|
19787
|
-
}
|
|
19788
|
-
}
|
|
19789
|
-
}
|
|
19790
|
-
}
|
|
19791
|
-
`, "pack.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/pack/0.1.json",\n "title": "Saktum Trust Check test pack",\n "description": "A versioned set of checks. Packs are data, never code: steps use a closed set of actions, and any logic lives in named, engine-versioned analysers.",\n "type": "object",\n "required": [\n "packFormat",\n "id",\n "version",\n "category",\n "checks"\n ],\n "additionalProperties": false,\n "properties": {\n "packFormat": {\n "const": "0.1"\n },\n "id": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"\n },\n "version": {\n "type": "string",\n "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$"\n },\n "category": {\n "enum": [\n "conformance",\n "auth",\n "security",\n "agent-experience",\n "performance",\n "functional"\n ]\n },\n "description": {\n "type": "string"\n },\n "checks": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/check"\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n },\n "description": "Detached JWS over the canonical pack without this member. Required for packs from the feed (v0.2)."\n }\n },\n "$defs": {\n "check": {\n "type": "object",\n "required": [\n "id",\n "title",\n "severity",\n "safety",\n "steps",\n "fix"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string",\n "pattern": "^[a-z]+(\\\\.[a-z0-9-]+)+$"\n },\n "title": {\n "type": "string"\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "safety": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "scored": {\n "type": "boolean",\n "default": true\n },\n "appliesTo": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "transports": {\n "type": "array",\n "items": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n }\n },\n "protocol": {\n "type": "string",\n "description": "Minimum protocol revision, e.g. >=2025-03-26"\n }\n }\n },\n "steps": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/step"\n }\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "normative": {\n "type": "array",\n "description": "Baseline 4.1: the normative statements this check verifies, for the public traceability matrix.",\n "items": {\n "type": "object",\n "required": [\n "source",\n "level"\n ],\n "additionalProperties": false,\n "properties": {\n "source": {\n "type": "string",\n "description": "e.g. MCP specification, RFC 9728, OWASP MCP Top 10"\n },\n "version": {\n "type": "string",\n "description": "specification revision or date"\n },\n "clause": {\n "type": "string",\n "description": "section or requirement identifier"\n },\n "level": {\n "enum": [\n "MUST",\n "SHOULD",\n "MAY",\n "best-practice"\n ]\n }\n }\n }\n }\n }\n },\n "step": {\n "type": "object",\n "required": [\n "action"\n ],\n "additionalProperties": false,\n "properties": {\n "action": {\n "enum": [\n "mcp.initialize",\n "mcp.listTools",\n "mcp.callTool",\n "analyse"\n ]\n },\n "tool": {\n "type": "string"\n },\n "arguments": {\n "type": "object"\n },\n "analyser": {\n "type": "string"\n },\n "expect": {\n "$ref": "#/$defs/expectation"\n }\n }\n },\n "expectation": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "exists": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "isError": {\n "type": "boolean"\n },\n "errorCodeIn": {\n "type": "array",\n "items": {\n "type": "integer"\n }\n },\n "failed": {\n "type": "boolean",\n "description": "The call must not succeed: either a protocol error or a tool result flagged as an error."\n },\n "anyOf": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/expectation"\n }\n }\n }\n }\n }\n}\n', "receipt.schema.json": `{
|
|
19792
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
19793
|
-
"$id": "https://saktum.dev/schemas/receipt/0.1.json",
|
|
19794
|
-
"title": "Saktum receipt",
|
|
19795
|
-
"description": "A signed record of one call's outcome. Signatures use public-key cryptography so any third party can verify them without a shared secret.",
|
|
19796
|
-
"type": "object",
|
|
19797
|
-
"required": [
|
|
19798
|
-
"receiptFormat",
|
|
19799
|
-
"envelope",
|
|
19800
|
-
"outcome",
|
|
19801
|
-
"issuedAt",
|
|
19802
|
-
"signatures"
|
|
19803
|
-
],
|
|
19804
|
-
"additionalProperties": false,
|
|
19805
|
-
"properties": {
|
|
19806
|
-
"receiptFormat": {
|
|
19807
|
-
"const": "0.1"
|
|
19808
|
-
},
|
|
19809
|
-
"envelope": {
|
|
19810
|
-
"$ref": "https://saktum.dev/schemas/envelope/0.1.json"
|
|
19811
|
-
},
|
|
19812
|
-
"outcome": {
|
|
19813
|
-
"enum": [
|
|
19814
|
-
"allow",
|
|
19815
|
-
"deny",
|
|
19816
|
-
"error"
|
|
19817
|
-
]
|
|
19818
|
-
},
|
|
19819
|
-
"reason": {
|
|
19820
|
-
"type": "string"
|
|
19821
|
-
},
|
|
19822
|
-
"issuedAt": {
|
|
19823
|
-
"type": "string",
|
|
19824
|
-
"format": "date-time"
|
|
19825
|
-
},
|
|
19826
|
-
"signatures": {
|
|
19827
|
-
"type": "array",
|
|
19828
|
-
"minItems": 1,
|
|
19829
|
-
"items": {
|
|
19830
|
-
"type": "object",
|
|
19831
|
-
"required": [
|
|
19832
|
-
"alg",
|
|
19833
|
-
"kid",
|
|
19834
|
-
"jws"
|
|
19835
|
-
],
|
|
19836
|
-
"properties": {
|
|
19837
|
-
"alg": {
|
|
19838
|
-
"const": "EdDSA"
|
|
19839
|
-
},
|
|
19840
|
-
"kid": {
|
|
19841
|
-
"type": "string"
|
|
19842
|
-
},
|
|
19843
|
-
"jws": {
|
|
19844
|
-
"type": "string"
|
|
19845
|
-
}
|
|
19846
|
-
}
|
|
19847
|
-
}
|
|
19848
|
-
},
|
|
19849
|
-
"explanation": {
|
|
19850
|
-
"type": "string",
|
|
19851
|
-
"maxLength": 500,
|
|
19852
|
-
"description": "One plain-language sentence: what happened, which rule applied, who could have stopped it."
|
|
19853
|
-
},
|
|
19854
|
-
"context": {
|
|
19855
|
-
"$ref": "https://saktum.dev/schemas/envelope/0.1.json#/properties/context"
|
|
19856
|
-
},
|
|
19857
|
-
"compensates": {
|
|
19858
|
-
"type": "string",
|
|
19859
|
-
"description": "Optional (Baseline 8.4): id of the original envelope or receipt that this call reverses (compensation transaction)."
|
|
19860
|
-
}
|
|
19861
|
-
}
|
|
19862
|
-
}
|
|
19863
|
-
`, "result.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/result/0.1.json",\n "title": "Saktum Trust Check result",\n "description": "The canonical result of one run. Every report format is rendered from this model. Evidence is a hash plus a short, sanitised excerpt; raw payloads never appear.",\n "type": "object",\n "required": [\n "resultFormat",\n "tool",\n "target",\n "packs",\n "findings",\n "scores",\n "metrics",\n "run"\n ],\n "additionalProperties": false,\n "properties": {\n "resultFormat": {\n "const": "0.1"\n },\n "tool": {\n "type": "object",\n "required": [\n "name",\n "version"\n ],\n "additionalProperties": false,\n "properties": {\n "name": {\n "const": "saktum-trust-check"\n },\n "version": {\n "type": "string"\n }\n }\n },\n "target": {\n "type": "object",\n "required": [\n "transport",\n "description"\n ],\n "additionalProperties": false,\n "properties": {\n "transport": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n },\n "description": {\n "type": "string"\n },\n "protocolVersion": {\n "type": "string"\n },\n "serverInfo": {\n "type": "object"\n },\n "toolsFingerprint": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "packs": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "id",\n "version",\n "hash"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string"\n },\n "version": {\n "type": "string"\n },\n "hash": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n }\n }\n }\n },\n "findings": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/finding"\n }\n },\n "scores": {\n "type": "object",\n "required": [\n "overall",\n "capped",\n "categories"\n ],\n "additionalProperties": false,\n "properties": {\n "overall": {\n "type": [\n "integer",\n "null"\n ],\n "minimum": 0,\n "maximum": 100\n },\n "capped": {\n "type": "boolean"\n },\n "categories": {\n "type": "object",\n "additionalProperties": {\n "type": [\n "integer",\n "null"\n ]\n }\n }\n }\n },\n "metrics": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "contextCostTokens": {\n "type": "integer",\n "minimum": 0\n },\n "largestTools": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "tool",\n "tokens"\n ],\n "properties": {\n "tool": {\n "type": "string"\n },\n "tokens": {\n "type": "integer"\n }\n }\n }\n },\n "contextCostPer1kTurnsUsd": {\n "type": "number",\n "minimum": 0,\n "description": "Estimated cost of loading the tool definitions on 1,000 agent turns at pricePerMTokUsd. Reported only."\n },\n "pricePerMTokUsd": {\n "type": "number",\n "minimum": 0\n },\n "performance": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "initMs": {\n "type": "integer",\n "minimum": 0\n },\n "listMs": {\n "type": "integer",\n "minimum": 0\n },\n "listBytes": {\n "type": "integer",\n "minimum": 0\n },\n "rssMb": {\n "type": "number",\n "minimum": 0\n },\n "cpuPct": {\n "type": "number",\n "minimum": 0\n },\n "burst": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "requests": {\n "type": "integer"\n },\n "ok": {\n "type": "integer"\n },\n "rateLimited": {\n "type": "integer"\n },\n "errors": {\n "type": "integer"\n },\n "p95Ms": {\n "type": "integer"\n }\n }\n }\n }\n }\n }\n },\n "run": {\n "type": "object",\n "required": [\n "startedAt",\n "durationMs",\n "mode",\n "runner",\n "sandbox"\n ],\n "additionalProperties": false,\n "properties": {\n "startedAt": {\n "type": "string",\n "format": "date-time"\n },\n "durationMs": {\n "type": "integer",\n "minimum": 0\n },\n "mode": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "runner": {\n "enum": [\n "self",\n "hosted"\n ],\n "description": "self: run and signed by the user, proves integrity not independence. hosted: run and signed by Saktum (later)."\n },\n "sandbox": {\n "enum": [\n "none",\n "docker"\n ],\n "description": "Whether local servers ran inside a container sandbox."\n }\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n }\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ],\n "description": "Letter grade from the trust score: A 90-100, B 80-89, C 70-79, D 50-69, F below 50 or any failed critical check."\n },\n "summary": {\n "type": "array",\n "maxItems": 5,\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "description": "Plain-language summary sentences shown first in every report."\n },\n "assuranceLevel": {\n "enum": [\n "L1",\n "L2",\n "L3",\n "L4"\n ],\n "description": "L1 self-tested (Saktum Check); L2 independently tested; L3 certified; L4 continuously certified."\n },\n "readiness": {\n "description": "Agent readiness: a second grade beside trust (annotations, descriptions, context cost), never mixed into the trust score.",\n "oneOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "score",\n "grade",\n "toolsAnnotated",\n "toolsDescribed",\n "toolCount",\n "contextTokens"\n ],\n "properties": {\n "score": {\n "type": "integer",\n "minimum": 0,\n "maximum": 100\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ]\n },\n "toolsAnnotated": {\n "type": "integer",\n "minimum": 0\n },\n "toolsDescribed": {\n "type": "integer",\n "minimum": 0\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n },\n "contextTokens": {\n "type": "integer",\n "minimum": 0\n },\n "topImprovement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n ]\n },\n "coverage": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "trustChecksRun": {\n "type": "integer",\n "minimum": 0\n }\n }\n }\n },\n "$defs": {\n "finding": {\n "type": "object",\n "required": [\n "check",\n "pack",\n "status",\n "severity",\n "title"\n ],\n "additionalProperties": false,\n "properties": {\n "check": {\n "type": "string"\n },\n "pack": {\n "type": "string"\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped",\n "inconclusive",\n "info"\n ]\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "scored": {\n "type": "boolean"\n },\n "title": {\n "type": "string"\n },\n "subject": {\n "type": "string"\n },\n "message": {\n "type": "string"\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "evidence": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "hash": {\n "type": "string"\n },\n "excerpt": {\n "type": "string",\n "maxLength": 240\n }\n }\n }\n }\n }\n }\n}\n', "test-cases.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/test-cases/0.1.json",\n "title": "Saktum Trust Check functional test cases (saktum.tests.yaml)",\n "type": "object",\n "required": ["testsFormat", "tests"],\n "additionalProperties": false,\n "properties": {\n "testsFormat": { "const": "0.1" },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "required": ["id", "tool", "input", "expect"],\n "additionalProperties": false,\n "properties": {\n "id": { "type": "string" },\n "tool": { "type": "string" },\n "input": { "type": "object" },\n "sideEffects": { "type": "boolean", "default": false, "description": "Tests with side effects run only against owned targets." },\n "expect": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "isError": { "type": "boolean" },\n "textContains": { "type": "string" },\n "structured": { "type": "object" },\n "outputSchema": { "type": "boolean" },\n "latencyMs": { "type": "object", "properties": { "lt": { "type": "integer" } }, "additionalProperties": false }\n }\n }\n }\n }\n }\n }\n}\n' };
|
|
19864
|
-
var EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n', "auth.yaml": `packFormat: "0.1"
|
|
19865
|
-
id: auth
|
|
19866
|
-
version: 0.1.0
|
|
19867
|
-
category: auth
|
|
19868
|
-
description: Sign-in for remote servers, checked from the outside without credentials. Follows the MCP authorization specification and the OAuth RFCs it builds on.
|
|
19869
|
-
checks:
|
|
19870
|
-
- id: auth.https
|
|
19871
|
-
title: Served over HTTPS
|
|
19872
|
-
severity: critical
|
|
19873
|
-
safety: passive
|
|
19874
|
-
appliesTo: { transports: [streamable-http] }
|
|
19875
|
-
steps: [{ action: analyse, analyser: auth-https }]
|
|
19876
|
-
fix: Serve the MCP endpoint over HTTPS (plain HTTP only on localhost during development).
|
|
19877
|
-
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization", "CWE-319"]
|
|
19878
|
-
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Authorization: communication security", level: MUST }, { source: "RFC 9700", clause: "OAuth security best current practice: TLS", level: MUST }]
|
|
19879
|
-
- id: auth.unauthenticated
|
|
19880
|
-
title: Whether sign-in is required
|
|
19881
|
-
severity: info
|
|
19882
|
-
safety: passive
|
|
19883
|
-
scored: false
|
|
19884
|
-
appliesTo: { transports: [streamable-http] }
|
|
19885
|
-
steps: [{ action: analyse, analyser: auth-unauthenticated }]
|
|
19886
|
-
fix: Require OAuth sign-in for any server that exposes user data or actions.
|
|
19887
|
-
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19888
|
-
- id: auth.www-authenticate
|
|
19889
|
-
title: Refusals point clients to the resource metadata
|
|
19890
|
-
severity: high
|
|
19891
|
-
safety: passive
|
|
19892
|
-
appliesTo: { transports: [streamable-http] }
|
|
19893
|
-
steps: [{ action: analyse, analyser: auth-www-authenticate }]
|
|
19894
|
-
fix: Answer unauthenticated requests with 401 and a header such as WWW-Authenticate Bearer resource_metadata="https://your-server/.well-known/oauth-protected-resource".
|
|
19895
|
-
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19896
|
-
normative: [{ source: "RFC 9728", clause: "Section 5.1, WWW-Authenticate response", level: MUST }, { source: "MCP specification", version: "verify-latest", clause: "Authorization: authorization server discovery", level: MUST }]
|
|
19897
|
-
- id: auth.resource-metadata
|
|
19898
|
-
title: Protected resource metadata is published and correct
|
|
19899
|
-
severity: high
|
|
19900
|
-
safety: passive
|
|
19901
|
-
appliesTo: { transports: [streamable-http] }
|
|
19902
|
-
steps: [{ action: analyse, analyser: auth-resource-metadata }]
|
|
19903
|
-
fix: Publish /.well-known/oauth-protected-resource with "resource" set to this server's URL and "authorization_servers" listing your HTTPS authorization server.
|
|
19904
|
-
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19905
|
-
normative: [{ source: "RFC 9728", clause: "Sections 2 and 3, metadata and well-known URI", level: MUST }]
|
|
19906
|
-
- id: auth.server-metadata
|
|
19907
|
-
title: Authorization server metadata is complete, with PKCE
|
|
19908
|
-
severity: high
|
|
19909
|
-
safety: passive
|
|
19910
|
-
appliesTo: { transports: [streamable-http] }
|
|
19911
|
-
steps: [{ action: analyse, analyser: auth-server-metadata }]
|
|
19912
|
-
fix: Publish RFC 8414 metadata with issuer, HTTPS authorization and token endpoints, the code response type, and code_challenge_methods_supported including S256.
|
|
19913
|
-
references: ["OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]
|
|
19914
|
-
normative: [{ source: "RFC 8414", clause: "Sections 2 and 3", level: MUST }, { source: "RFC 7636", clause: "PKCE with S256", level: MUST }, { source: "MCP specification", version: "verify-latest", clause: "Authorization: PKCE required", level: MUST }]
|
|
19915
|
-
- id: auth.invalid-token
|
|
19916
|
-
title: Invalid tokens are rejected
|
|
19917
|
-
severity: critical
|
|
19918
|
-
safety: passive
|
|
19919
|
-
appliesTo: { transports: [streamable-http] }
|
|
19920
|
-
steps: [{ action: analyse, analyser: auth-invalid-token }]
|
|
19921
|
-
fix: Validate every bearer token (signature or introspection, expiry, audience) and answer invalid ones with 401 and error="invalid_token".
|
|
19922
|
-
references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization", "CWE-287"]
|
|
19923
|
-
normative: [{ source: "RFC 6750", clause: "Section 3.1, invalid_token", level: MUST }]
|
|
19924
|
-
`, "conformance.yaml": `packFormat: "0.1"
|
|
19925
|
-
id: conformance
|
|
19926
|
-
version: 0.1.0
|
|
19927
|
-
category: conformance
|
|
19928
|
-
description: Does the server speak MCP correctly? Basis for every other check.
|
|
19929
|
-
checks:
|
|
19930
|
-
- id: conf.init.handshake
|
|
19931
|
-
title: Initialize returns server info and capabilities
|
|
19932
|
-
severity: high
|
|
19933
|
-
safety: passive
|
|
19934
|
-
steps: [{ action: analyse, analyser: handshake }]
|
|
19935
|
-
fix: Return serverInfo (name, version) and a capabilities object from initialize.
|
|
19936
|
-
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Lifecycle: initialization (server returns capabilities and serverInfo)", level: MUST }]
|
|
19937
|
-
references: ["MCP specification: lifecycle"]
|
|
19938
|
-
- id: conf.tools.list
|
|
19939
|
-
title: Tool list is returned
|
|
19940
|
-
severity: high
|
|
19941
|
-
safety: passive
|
|
19942
|
-
steps: [{ action: mcp.listTools, expect: { exists: [tools] } }]
|
|
19943
|
-
fix: Implement tools/list and return a tools array (empty if you have none).
|
|
19944
|
-
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Server features: tools, listing tools", level: MUST }]
|
|
19945
|
-
references: ["MCP specification: tools"]
|
|
19946
|
-
- id: conf.tools.schema-valid
|
|
19947
|
-
title: Every input schema is a valid JSON Schema object
|
|
19948
|
-
severity: high
|
|
19949
|
-
safety: passive
|
|
19950
|
-
steps: [{ action: analyse, analyser: tool-input-schemas }]
|
|
19951
|
-
fix: Give every tool an inputSchema of type "object" that compiles as JSON Schema.
|
|
19952
|
-
normative: [{ source: "MCP specification", version: "verify-latest", clause: "Tools: inputSchema is a JSON Schema object", level: MUST }]
|
|
19953
|
-
references: ["MCP specification: tools", "JSON Schema 2020-12", "OWASP MCP Top 10: MCP05 Command Injection and Execution (input validation)"]
|
|
19954
|
-
- id: conf.tools.names
|
|
19955
|
-
title: Tool names are unique and use allowed characters
|
|
19956
|
-
severity: medium
|
|
19957
|
-
safety: passive
|
|
19958
|
-
steps: [{ action: analyse, analyser: tool-names }]
|
|
19959
|
-
fix: Use unique names of 1 to 128 characters from A-Z, a-z, 0-9, underscore, dot and hyphen.
|
|
19960
|
-
references: ["MCP specification: tools"]
|
|
19961
|
-
- id: conf.tools.unknown-not-success
|
|
19962
|
-
title: Calling an unknown tool does not succeed
|
|
19963
|
-
severity: high
|
|
19964
|
-
safety: passive
|
|
19965
|
-
steps:
|
|
19966
|
-
- action: mcp.callTool
|
|
19967
|
-
tool: saktum_trust_check_no_such_tool
|
|
19968
|
-
arguments: {}
|
|
19969
|
-
expect: { failed: true }
|
|
19970
|
-
fix: Return an error for unknown tool names; never a successful result.
|
|
19971
|
-
references: ["MCP specification: tools, error handling", "OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (false success hides actions)"]
|
|
19972
|
-
- id: conf.tools.unknown-error-code
|
|
19973
|
-
title: Unknown tools get the expected error
|
|
19974
|
-
severity: low
|
|
19975
|
-
safety: passive
|
|
19976
|
-
steps:
|
|
19977
|
-
- action: mcp.callTool
|
|
19978
|
-
tool: saktum_trust_check_no_such_tool
|
|
19979
|
-
arguments: {}
|
|
19980
|
-
expect: { anyOf: [{ errorCodeIn: [-32602] }, { isError: true }] }
|
|
19981
|
-
fix: Respond to an unknown tool name with JSON-RPC error -32602 (invalid params), as in the specification's example.
|
|
19982
|
-
references: ["MCP specification: tools, error handling", "JSON-RPC 2.0"]
|
|
19983
|
-
`, "performance.yaml": `packFormat: "0.1"
|
|
19984
|
-
id: performance
|
|
19985
|
-
version: 0.1.0
|
|
19986
|
-
category: performance
|
|
19987
|
-
description: Speed and resource use, reported as information and never part of the trust score. The burst test runs only with --active.
|
|
19988
|
-
checks:
|
|
19989
|
-
- id: perf.startup
|
|
19990
|
-
title: Start-up and handshake time
|
|
19991
|
-
severity: info
|
|
19992
|
-
safety: passive
|
|
19993
|
-
scored: false
|
|
19994
|
-
steps: [{ action: analyse, analyser: perf-startup }]
|
|
19995
|
-
fix: Defer heavy initialisation until the first call that needs it; agents and clients time out on slow starts.
|
|
19996
|
-
- id: perf.latency
|
|
19997
|
-
title: Tool-list latency and size
|
|
19998
|
-
severity: info
|
|
19999
|
-
safety: passive
|
|
20000
|
-
scored: false
|
|
20001
|
-
steps: [{ action: analyse, analyser: perf-latency }]
|
|
20002
|
-
fix: Keep tools/list fast and small; cache it and trim long descriptions.
|
|
20003
|
-
- id: perf.memory
|
|
20004
|
-
title: Memory and CPU of a local server
|
|
20005
|
-
severity: info
|
|
20006
|
-
safety: passive
|
|
20007
|
-
scored: false
|
|
20008
|
-
appliesTo: { transports: [stdio] }
|
|
20009
|
-
steps: [{ action: analyse, analyser: perf-memory }]
|
|
20010
|
-
fix: Reduce idle memory and CPU; local servers run beside the user's other tools.
|
|
20011
|
-
- id: perf.burst
|
|
20012
|
-
title: Behaviour under a short burst (rate limiting)
|
|
20013
|
-
severity: info
|
|
20014
|
-
safety: active
|
|
20015
|
-
scored: false
|
|
20016
|
-
steps: [{ action: analyse, analyser: perf-burst }]
|
|
20017
|
-
fix: Answer overload with HTTP 429 and Retry-After instead of errors, and set limits per client.
|
|
20018
|
-
references: ["OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (resource abuse)", "CWE-770"]
|
|
20019
|
-
`, "security.yaml": 'packFormat: "0.1"\nid: security\nversion: 0.1.0\ncategory: security\ndescription: Passive security checks on what the server tells agents and users.\nchecks:\n - id: sec.description.hidden-instructions\n title: No instructions to the agent in tool descriptions or schemas\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: hidden-instructions }]\n fix: Describe what each tool does; never instruct the agent (for example to read other data, send data elsewhere or hide actions from the user).\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP03 Tool Poisoning", level: best-practice }]\n references: ["MCP security best practices", "CWE-1427", "OWASP MCP Top 10: MCP03 Tool Poisoning", "OWASP MCP Top 10: MCP06 Intent Flow Subversion"]\n - id: sec.description.invisible-text\n title: No invisible or bidirectional control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: invisible-text }]\n fix: Remove zero-width and bidirectional control characters from names, descriptions and schemas.\n references: ["CWE-1007", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.description.control-characters\n title: No escape sequences or control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: control-characters }]\n fix: Remove terminal escape sequences and control characters; clients may print tool text to a terminal.\n references: ["CWE-150", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.secrets.exposed\n title: No secrets in tool definitions or responses\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: secrets }]\n fix: Remove keys, tokens and passwords from descriptions, schemas, defaults, examples and error messages; load them from a secret store at runtime.\n references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "CWE-798", "CWE-200"]\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP01 Token Mismanagement and Secret Exposure", level: best-practice }]\n - id: sec.errors.leakage\n title: Errors do not expose internals\n severity: medium\n safety: passive\n steps: [{ action: analyse, analyser: error-leakage }]\n fix: Return short, actionable error messages; log stack traces, file paths and database errors on the server only.\n references: ["OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (errors leak internals)", "CWE-209"]\n normative: [{ source: "OWASP MCP Top 10", clause: "Information exposure through errors", level: best-practice }]\n\n' };
|
|
20020
|
-
|
|
20021
|
-
// packages/testkit-core/dist/contracts.js
|
|
20022
|
-
var pick = (m) => {
|
|
20023
|
-
let x = m;
|
|
20024
|
-
while (x && typeof x !== "function" && x.default)
|
|
20025
|
-
x = x.default;
|
|
20026
|
-
return x;
|
|
20027
|
-
};
|
|
20028
|
-
var Ajv2020 = pick(Ajv2020Module);
|
|
20029
|
-
var Ajv2019 = pick(Ajv2019Module);
|
|
20030
|
-
var AjvDraft7 = pick(AjvDraft7Module);
|
|
20031
|
-
var addFormats = pick(addFormatsModule);
|
|
20032
|
-
var contractsDir = fileURLToPath(new URL("../../../contracts/", import.meta.url));
|
|
20033
|
-
var ajv = new Ajv2020({ allErrors: true, strict: false });
|
|
20034
|
-
addFormats(ajv);
|
|
20035
|
-
function contractText(f) {
|
|
20036
|
-
if (existsSync2(contractsDir + f))
|
|
20037
|
-
return readFileSync2(contractsDir + f, "utf8");
|
|
20038
|
-
const t = EMBEDDED_CONTRACTS[f];
|
|
20039
|
-
if (!t)
|
|
20040
|
-
throw new Error(`contract ${f} not found`);
|
|
20041
|
-
return t;
|
|
20042
|
-
}
|
|
20043
|
-
for (const f of ["envelope.schema.json", "receipt.schema.json", "pack.schema.json", "result.schema.json", "test-cases.schema.json"]) {
|
|
20044
|
-
ajv.addSchema(JSON.parse(contractText(f)), f);
|
|
20045
|
-
}
|
|
20046
|
-
function compileContract(file) {
|
|
20047
|
-
const v = ajv.getSchema(file);
|
|
20048
|
-
if (!v)
|
|
20049
|
-
throw new Error(`unknown contract ${file}`);
|
|
20050
|
-
return v;
|
|
20051
|
-
}
|
|
20052
|
-
function schemaDialect(schema) {
|
|
20053
|
-
const id = schema && typeof schema === "object" ? schema.$schema : void 0;
|
|
20054
|
-
if (id === void 0)
|
|
20055
|
-
return "2020-12";
|
|
20056
|
-
const s = String(id);
|
|
20057
|
-
if (/draft-04/.test(s))
|
|
20058
|
-
return "draft-04";
|
|
20059
|
-
if (/draft-06/.test(s))
|
|
20060
|
-
return "draft-06";
|
|
20061
|
-
if (/draft-07/.test(s))
|
|
20062
|
-
return "draft-07";
|
|
20063
|
-
if (/2019-09/.test(s))
|
|
20064
|
-
return "2019-09";
|
|
20065
|
-
if (/2020-12/.test(s))
|
|
20066
|
-
return "2020-12";
|
|
20067
|
-
return "unknown";
|
|
20068
|
-
}
|
|
20069
|
-
function compileUntrustedSchema(schema) {
|
|
20070
|
-
try {
|
|
20071
|
-
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
20072
|
-
return { ok: false, error: "the schema is not a JSON object" };
|
|
20073
|
-
const dialect = schemaDialect(schema);
|
|
20074
|
-
if (dialect === "unknown")
|
|
20075
|
-
return { ok: false, error: `unrecognised $schema dialect ${JSON.stringify(schema.$schema).slice(0, 80)}` };
|
|
20076
|
-
const { $schema: _ignored, ...body } = schema;
|
|
20077
|
-
const Ctor = dialect === "2020-12" ? Ajv2020 : dialect === "2019-09" ? Ajv2019 : AjvDraft7;
|
|
20078
|
-
new Ctor({ strict: false, allErrors: false, validateSchema: true, logger: false }).compile(body);
|
|
20079
|
-
return { ok: true };
|
|
20080
|
-
} catch (e) {
|
|
20081
|
-
return { ok: false, error: e.message };
|
|
20082
|
-
}
|
|
20083
|
-
}
|
|
20084
|
-
|
|
20085
20161
|
// packages/testkit-core/dist/packs.js
|
|
20162
|
+
init_contracts();
|
|
20163
|
+
init_embedded();
|
|
20086
20164
|
var validatePack = compileContract("pack.schema.json");
|
|
20087
20165
|
var PackError = class extends Error {
|
|
20088
20166
|
};
|
|
@@ -20118,6 +20196,12 @@ function loadEmbeddedPacks(opts) {
|
|
|
20118
20196
|
return Object.keys(EMBEDDED_PACKS).sort().map((f) => loadPackText(EMBEDDED_PACKS[f], `embedded:${f}`, opts));
|
|
20119
20197
|
}
|
|
20120
20198
|
|
|
20199
|
+
// packages/testkit-core/dist/index.js
|
|
20200
|
+
init_contracts();
|
|
20201
|
+
|
|
20202
|
+
// packages/testkit-core/dist/analysers.js
|
|
20203
|
+
init_contracts();
|
|
20204
|
+
|
|
20121
20205
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
|
|
20122
20206
|
var util_exports = {};
|
|
20123
20207
|
__export(util_exports, {
|
|
@@ -20283,8 +20367,8 @@ function defineLazy(object3, key, getter) {
|
|
|
20283
20367
|
configurable: true
|
|
20284
20368
|
});
|
|
20285
20369
|
}
|
|
20286
|
-
function objectClone(
|
|
20287
|
-
return Object.create(Object.getPrototypeOf(
|
|
20370
|
+
function objectClone(obj2) {
|
|
20371
|
+
return Object.create(Object.getPrototypeOf(obj2), Object.getOwnPropertyDescriptors(obj2));
|
|
20288
20372
|
}
|
|
20289
20373
|
function assignProp(target, prop, value) {
|
|
20290
20374
|
Object.defineProperty(target, prop, {
|
|
@@ -20355,10 +20439,10 @@ function mergeDefs(...defs) {
|
|
|
20355
20439
|
function cloneDef(schema) {
|
|
20356
20440
|
return mergeDefs(schema._zod.def);
|
|
20357
20441
|
}
|
|
20358
|
-
function getElementAtPath(
|
|
20442
|
+
function getElementAtPath(obj2, path) {
|
|
20359
20443
|
if (!path)
|
|
20360
|
-
return
|
|
20361
|
-
return path.reduce((acc, key) => acc?.[key],
|
|
20444
|
+
return obj2;
|
|
20445
|
+
return path.reduce((acc, key) => acc?.[key], obj2);
|
|
20362
20446
|
}
|
|
20363
20447
|
function promiseAllObject(promisesObj) {
|
|
20364
20448
|
const keys = Object.keys(promisesObj);
|
|
@@ -20794,9 +20878,9 @@ function parsedType(data) {
|
|
|
20794
20878
|
if (Array.isArray(data)) {
|
|
20795
20879
|
return "array";
|
|
20796
20880
|
}
|
|
20797
|
-
const
|
|
20798
|
-
if (
|
|
20799
|
-
return
|
|
20881
|
+
const obj2 = data;
|
|
20882
|
+
if (obj2 && Object.getPrototypeOf(obj2) !== Object.prototype && "constructor" in obj2 && obj2.constructor) {
|
|
20883
|
+
return obj2.constructor.name;
|
|
20800
20884
|
}
|
|
20801
20885
|
}
|
|
20802
20886
|
}
|
|
@@ -20814,8 +20898,8 @@ function issue(...args) {
|
|
|
20814
20898
|
}
|
|
20815
20899
|
return { ...iss };
|
|
20816
20900
|
}
|
|
20817
|
-
function cleanEnum(
|
|
20818
|
-
return Object.entries(
|
|
20901
|
+
function cleanEnum(obj2) {
|
|
20902
|
+
return Object.entries(obj2).filter(([k, _]) => {
|
|
20819
20903
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
20820
20904
|
}).map((el) => el[1]);
|
|
20821
20905
|
}
|
|
@@ -21139,15 +21223,15 @@ var $ZodError = $constructor("$ZodError", initializer);
|
|
|
21139
21223
|
var $ZodRealError = $constructor("$ZodError", initializer, void 0, {
|
|
21140
21224
|
Parent: Error
|
|
21141
21225
|
});
|
|
21142
|
-
function node(
|
|
21143
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
21226
|
+
function node(obj2, key, make) {
|
|
21227
|
+
if (!Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
21144
21228
|
if (key === "__proto__") {
|
|
21145
|
-
Object.defineProperty(
|
|
21229
|
+
Object.defineProperty(obj2, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
21146
21230
|
} else {
|
|
21147
|
-
|
|
21231
|
+
obj2[key] = make();
|
|
21148
21232
|
}
|
|
21149
21233
|
}
|
|
21150
|
-
return
|
|
21234
|
+
return obj2[key];
|
|
21151
21235
|
}
|
|
21152
21236
|
function flattenError(error2, mapper = (issue2) => issue2.message) {
|
|
21153
21237
|
const fieldErrors = {};
|
|
@@ -29590,15 +29674,15 @@ function applyElicitationDefaults(schema, data) {
|
|
|
29590
29674
|
if (!schema || data === null || typeof data !== "object")
|
|
29591
29675
|
return;
|
|
29592
29676
|
if (schema.type === "object" && schema.properties && typeof schema.properties === "object") {
|
|
29593
|
-
const
|
|
29677
|
+
const obj2 = data;
|
|
29594
29678
|
const props = schema.properties;
|
|
29595
29679
|
for (const key of Object.keys(props)) {
|
|
29596
29680
|
const propSchema = props[key];
|
|
29597
|
-
if (
|
|
29598
|
-
|
|
29681
|
+
if (obj2[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) {
|
|
29682
|
+
obj2[key] = propSchema.default;
|
|
29599
29683
|
}
|
|
29600
|
-
if (
|
|
29601
|
-
applyElicitationDefaults(propSchema,
|
|
29684
|
+
if (obj2[key] !== void 0) {
|
|
29685
|
+
applyElicitationDefaults(propSchema, obj2[key]);
|
|
29602
29686
|
}
|
|
29603
29687
|
}
|
|
29604
29688
|
}
|
|
@@ -31930,7 +32014,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
31930
32014
|
};
|
|
31931
32015
|
|
|
31932
32016
|
// packages/transports/dist/index.js
|
|
31933
|
-
var USER_AGENT = "saktum-check/0.
|
|
32017
|
+
var USER_AGENT = "saktum-check/0.2.0 (+https://saktum.dev/check)";
|
|
31934
32018
|
var LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
|
|
31935
32019
|
var LimitError = class extends Error {
|
|
31936
32020
|
};
|
|
@@ -32060,7 +32144,7 @@ var INIT_BODY = JSON.stringify({
|
|
|
32060
32144
|
jsonrpc: "2.0",
|
|
32061
32145
|
id: 1,
|
|
32062
32146
|
method: "initialize",
|
|
32063
|
-
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.
|
|
32147
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.2.0" } }
|
|
32064
32148
|
});
|
|
32065
32149
|
async function httpRequest(url2, init = {}) {
|
|
32066
32150
|
const t0 = Date.now();
|
|
@@ -32429,7 +32513,9 @@ var perfAnalysers = {
|
|
|
32429
32513
|
const slow = perf.initMs > PERF_THRESHOLDS.startupMs;
|
|
32430
32514
|
return { status: "info", message: `${what} in ${perf.initMs} ms.${slow ? " That is slow: agents and clients may time out." : ""}` };
|
|
32431
32515
|
},
|
|
32432
|
-
"perf-latency": ({ perf }) => {
|
|
32516
|
+
"perf-latency": ({ perf, load }) => {
|
|
32517
|
+
if (load)
|
|
32518
|
+
return { status: "info", message: `${load.verdicts[0]} (p50 ${load.latency.p50} ms over ${load.latency.samples} samples; tool list ${Math.round((perf?.listBytes ?? 0) / 1024)} KB).` };
|
|
32433
32519
|
if (perf?.listMs === void 0)
|
|
32434
32520
|
return { status: "inconclusive", message: "Tool-list latency was not measured." };
|
|
32435
32521
|
const notes = [];
|
|
@@ -32449,19 +32535,58 @@ var perfAnalysers = {
|
|
|
32449
32535
|
const heavy = perf.rssMb > PERF_THRESHOLDS.rssMb;
|
|
32450
32536
|
return { status: "info", message: `Uses ${perf.rssMb} MB of memory (including any launcher such as npx); averaged ${perf.cpuPct}% CPU since start-up.${heavy ? " That is a lot of memory for a tool server." : ""}` };
|
|
32451
32537
|
},
|
|
32452
|
-
"perf-
|
|
32453
|
-
|
|
32454
|
-
|
|
32455
|
-
|
|
32456
|
-
|
|
32457
|
-
|
|
32458
|
-
|
|
32459
|
-
|
|
32460
|
-
|
|
32461
|
-
|
|
32538
|
+
"perf-concurrency": ({ load }) => {
|
|
32539
|
+
if (!load)
|
|
32540
|
+
return { status: "inconclusive", message: "The load measurement did not run." };
|
|
32541
|
+
const levels = load.levels.map((l) => `${l.concurrency} caller${l.concurrency === 1 ? "" : "s"}: ${l.ok}/${l.requests} ok, p95 ${l.p95} ms, ${l.throughput}/s`).join("; ");
|
|
32542
|
+
return { status: "info", message: `${load.verdicts.join(" ")} Measured by ${load.operation} (${levels}).${load.memoryGrowthMb !== void 0 ? ` Memory grew by ${load.memoryGrowthMb} MB during the run.` : ""}` };
|
|
32543
|
+
}
|
|
32544
|
+
};
|
|
32545
|
+
var PERF_NEEDS = { "perf-startup": "session", "perf-latency": "session", "perf-memory": "session", "perf-concurrency": "session" };
|
|
32546
|
+
|
|
32547
|
+
// packages/testkit-core/dist/functional-checks.js
|
|
32548
|
+
var notEligible = { status: "skipped", message: "No tools were eligible to call: annotate read-only tools (readOnlyHint), name tools with --call, or add test cases." };
|
|
32549
|
+
var describe2 = (xs) => xs.slice(0, 3).map((x) => `${sanitizeText(x.tool, 50)}: ${x.problems.join("; ")}`).join(" \xB7 ");
|
|
32550
|
+
var functionalAnalysers = {
|
|
32551
|
+
"func-respond": ({ functional }) => {
|
|
32552
|
+
if (!functional?.ran)
|
|
32553
|
+
return { status: "skipped", message: functional?.reason ?? "Functional calls did not run." };
|
|
32554
|
+
const smoke = functional.calls.filter((c) => c.purpose === "smoke");
|
|
32555
|
+
if (!smoke.length)
|
|
32556
|
+
return notEligible;
|
|
32557
|
+
const bad = smoke.filter((c) => c.outcome.kind === "timeout" || c.outcome.kind === "transport-error" || c.outcome.kind === "protocol-error" && c.outcome.code === -32602);
|
|
32558
|
+
if (bad.length)
|
|
32559
|
+
return { status: "fail", subject: "tools", message: `${bad.length} of ${smoke.length} tool(s) failed with valid arguments: ${describe2(bad.map((b) => ({ tool: b.tool, problems: b.problems.length ? b.problems : [b.outcome.kind] })))}.` };
|
|
32560
|
+
const errored = smoke.filter((c) => c.outcome.kind !== "result" || c.outcome.isError).length;
|
|
32561
|
+
return { status: "pass", message: `${smoke.length} tool(s) called with arguments generated from their schemas${errored ? ` (${errored} answered with an error result, for example because they need credentials or real data; that is not counted as a failure)` : ""}.` };
|
|
32562
|
+
},
|
|
32563
|
+
"func-output": ({ functional }) => {
|
|
32564
|
+
if (!functional?.ran)
|
|
32565
|
+
return { status: "skipped", message: functional?.reason ?? "Functional calls did not run." };
|
|
32566
|
+
const ok = functional.calls.filter((c) => c.purpose === "smoke" && c.outcome.kind === "result" && !c.outcome.isError);
|
|
32567
|
+
if (!ok.length)
|
|
32568
|
+
return { status: "skipped", message: "No call returned a successful result to validate (tools may need credentials or real data; add test cases with real inputs)." };
|
|
32569
|
+
const bad = ok.map((c) => ({ tool: c.tool, problems: c.problems })).filter((c) => c.problems.length);
|
|
32570
|
+
return bad.length ? { status: "fail", subject: "tools", message: `${bad.length} of ${ok.length} successful result(s) are malformed or break their declared output schema: ${describe2(bad)}.` } : { status: "pass", message: `${ok.length} successful result(s) are well-formed and match any declared output schema.` };
|
|
32571
|
+
},
|
|
32572
|
+
"func-invalid": ({ functional }) => {
|
|
32573
|
+
if (!functional?.ran)
|
|
32574
|
+
return { status: "skipped", message: functional?.reason ?? "Functional calls did not run." };
|
|
32575
|
+
const probes = functional.calls.filter((c) => c.purpose === "invalid-args");
|
|
32576
|
+
if (!probes.length)
|
|
32577
|
+
return notEligible;
|
|
32578
|
+
const bad = probes.filter((c) => c.problems.length);
|
|
32579
|
+
return bad.length ? { status: "fail", subject: "tools", message: `${bad.length} of ${probes.length} tool(s) handled invalid arguments badly: ${describe2(bad)}.` } : { status: "pass", message: `${probes.length} tool(s) rejected invalid arguments gracefully.` };
|
|
32580
|
+
},
|
|
32581
|
+
"func-survives": ({ functional }) => {
|
|
32582
|
+
if (!functional?.ran)
|
|
32583
|
+
return { status: "skipped", message: functional?.reason ?? "Functional calls did not run." };
|
|
32584
|
+
if (functional.survived === void 0)
|
|
32585
|
+
return notEligible;
|
|
32586
|
+
return functional.survived ? { status: "pass", message: "The server kept responding after all functional calls." } : { status: "fail", message: "The server stopped responding after the functional calls." };
|
|
32462
32587
|
}
|
|
32463
32588
|
};
|
|
32464
|
-
var
|
|
32589
|
+
var FUNCTIONAL_NEEDS = { "func-respond": "session", "func-output": "session", "func-invalid": "session", "func-survives": "session" };
|
|
32465
32590
|
|
|
32466
32591
|
// packages/testkit-core/dist/analysers.js
|
|
32467
32592
|
var textOf = (t) => `${t.name ?? ""}
|
|
@@ -32482,6 +32607,18 @@ var HIDDEN_INSTRUCTION = [
|
|
|
32482
32607
|
/(send|upload|post|forward) (the |all |any )?(conversation|chat history|credentials|api keys?|secrets?|tokens?) to/i
|
|
32483
32608
|
];
|
|
32484
32609
|
var coreAnalysers = {
|
|
32610
|
+
"unknown-tool-code": ({ probes }) => {
|
|
32611
|
+
const o = probes?.unknownTool;
|
|
32612
|
+
if (!o)
|
|
32613
|
+
return { status: "inconclusive", message: "The unknown-tool probe did not run." };
|
|
32614
|
+
if (o.kind === "protocol-error" && (o.code === -32602 || o.code === -32601))
|
|
32615
|
+
return { status: "pass", message: `Unknown tools get JSON-RPC error ${o.code} (${o.code === -32602 ? "invalid params, as in the specification's example" : "method not found, understood by most clients"}).` };
|
|
32616
|
+
if (o.kind === "result" && o.isError)
|
|
32617
|
+
return { status: "pass", message: "Unknown tools get an error result." };
|
|
32618
|
+
if (o.kind === "protocol-error")
|
|
32619
|
+
return { status: "info", message: `Unknown tools get JSON-RPC error ${o.code}. The MCP specification's example uses -32602 (invalid params); -32601 is also widely understood.` };
|
|
32620
|
+
return { status: "info", message: "See the unknown-tool success check for how this server answers unknown tools." };
|
|
32621
|
+
},
|
|
32485
32622
|
handshake: ({ session }) => {
|
|
32486
32623
|
if (!session)
|
|
32487
32624
|
return { status: "inconclusive", message: "No MCP session (the server requires sign-in)." };
|
|
@@ -32553,7 +32690,7 @@ var coreAnalysers = {
|
|
|
32553
32690
|
"context-cost": ({ tools, pricePerMTokUsd }) => {
|
|
32554
32691
|
const { contextCostTokens, largestTools, contextCostPer1kTurnsUsd } = contextCost(tools, pricePerMTokUsd);
|
|
32555
32692
|
const money = contextCostPer1kTurnsUsd !== void 0 ? ` (about $${contextCostPer1kTurnsUsd.toFixed(2)} per 1,000 agent turns at $${pricePerMTokUsd} per million input tokens)` : "";
|
|
32556
|
-
return { status: "info", message: `Tool definitions cost about ${contextCostTokens} tokens of agent context per turn when loaded upfront${money}. Largest: ${largestTools.slice(0, 3).map((s) => `${s.tool} (${s.tokens})`).join(", ") || "none"}.` };
|
|
32693
|
+
return { status: "info", message: `Tool definitions cost about ${contextCostTokens.toLocaleString("en-US")} tokens of agent context per turn when loaded upfront${money}. Largest: ${largestTools.slice(0, 3).map((s) => `${s.tool} (${s.tokens})`).join(", ") || "none"}.` };
|
|
32557
32694
|
}
|
|
32558
32695
|
};
|
|
32559
32696
|
function contextCost(tools, pricePerMTokUsd) {
|
|
@@ -32562,8 +32699,8 @@ function contextCost(tools, pricePerMTokUsd) {
|
|
|
32562
32699
|
const per1k = pricePerMTokUsd !== void 0 && pricePerMTokUsd > 0 ? Math.round(contextCostTokens / 1e6 * pricePerMTokUsd * 1e3 * 100) / 100 : void 0;
|
|
32563
32700
|
return { contextCostTokens, largestTools: sized.slice(0, 5), ...per1k !== void 0 ? { contextCostPer1kTurnsUsd: per1k } : {} };
|
|
32564
32701
|
}
|
|
32565
|
-
var analysers = { ...coreAnalysers, ...authAnalysers, ...leakageAnalysers, ...perfAnalysers };
|
|
32566
|
-
var ANALYSER_NEEDS = { handshake: "session", ...AUTH_NEEDS, ...LEAKAGE_NEEDS, ...PERF_NEEDS };
|
|
32702
|
+
var analysers = { ...coreAnalysers, ...authAnalysers, ...leakageAnalysers, ...perfAnalysers, ...functionalAnalysers };
|
|
32703
|
+
var ANALYSER_NEEDS = { handshake: "session", "unknown-tool-code": "session", ...AUTH_NEEDS, ...LEAKAGE_NEEDS, ...PERF_NEEDS, ...FUNCTIONAL_NEEDS };
|
|
32567
32704
|
var needsOf = (name) => ANALYSER_NEEDS[name] ?? "tools";
|
|
32568
32705
|
|
|
32569
32706
|
// packages/testkit-core/dist/runner.js
|
|
@@ -32584,7 +32721,7 @@ function meets(value, e) {
|
|
|
32584
32721
|
return false;
|
|
32585
32722
|
return true;
|
|
32586
32723
|
}
|
|
32587
|
-
function
|
|
32724
|
+
function describe3(value) {
|
|
32588
32725
|
const c = value;
|
|
32589
32726
|
if (c && typeof c === "object" && "kind" in c) {
|
|
32590
32727
|
if (c.kind === "result")
|
|
@@ -32632,7 +32769,7 @@ async function runCheck(check, ctx) {
|
|
|
32632
32769
|
}
|
|
32633
32770
|
}
|
|
32634
32771
|
if (step.expect && !meets(value, step.expect))
|
|
32635
|
-
return { status: "fail", message: `Got ${
|
|
32772
|
+
return { status: "fail", message: `Got ${describe3(value)}, which does not meet the expectation.` };
|
|
32636
32773
|
} catch (e) {
|
|
32637
32774
|
if (e instanceof LimitError)
|
|
32638
32775
|
return { status: "inconclusive", message: sanitizeText(e.message) };
|
|
@@ -32709,12 +32846,16 @@ function summarise(r, noGrade, isTrust = () => true) {
|
|
|
32709
32846
|
lines.push(`Trust grade ${r.grade}: all ${passed} checks that apply passed.`);
|
|
32710
32847
|
else
|
|
32711
32848
|
lines.push(`Trust grade ${r.grade}: ${fails.length} problem${fails.length === 1 ? "" : "s"} found (${counts.map(([s, n]) => `${n} ${s}`).join(", ")}); ${passed} checks passed.`);
|
|
32849
|
+
const fnFails = r.findings.filter((f) => (f.pack === "functional" || f.pack === "tests") && f.status === "fail" && f.scored);
|
|
32850
|
+
const functionalLine = fnFails.length ? `Functional: ${fnFails.length} problem${fnFails.length === 1 ? "" : "s"}, first ${fnFails[0].title.charAt(0).toLowerCase()}${fnFails[0].title.slice(1)}: ${(fnFails[0].message ?? "").split(/(?<=\.)\s/)[0].replace(/\.$/, "")}.` : void 0;
|
|
32712
32851
|
const rd = r.readiness;
|
|
32713
32852
|
const readinessLine = rd && rd.grade && rd.topImprovement ? `Agent readiness ${rd.grade}: ${rd.topImprovement}.` : void 0;
|
|
32714
32853
|
if (fails[0]) {
|
|
32715
32854
|
const first = (fails[0].message ?? fails[0].title).split(/(?<=\.)\s/)[0].replace(/\.$/, "");
|
|
32716
32855
|
lines.push(`Fix first (${fails[0].severity}): ${first.charAt(0).toLowerCase()}${first.slice(1)}.`);
|
|
32717
|
-
} else if (
|
|
32856
|
+
} else if (functionalLine)
|
|
32857
|
+
lines.push(functionalLine);
|
|
32858
|
+
else if (readinessLine)
|
|
32718
32859
|
lines.push(readinessLine);
|
|
32719
32860
|
else
|
|
32720
32861
|
lines.push("Nothing to fix in this run; keep running it in CI to catch regressions.");
|
|
@@ -32767,11 +32908,340 @@ function readinessFor(tools) {
|
|
|
32767
32908
|
};
|
|
32768
32909
|
}
|
|
32769
32910
|
|
|
32911
|
+
// packages/testkit-core/dist/capabilities.js
|
|
32912
|
+
var CAPABILITY_LABELS = {
|
|
32913
|
+
"reads-private-data": "reads private or account data",
|
|
32914
|
+
"untrusted-content": "brings in untrusted content (web pages, emails, documents)",
|
|
32915
|
+
network: "reaches the network",
|
|
32916
|
+
"code-execution": "runs code or commands",
|
|
32917
|
+
filesystem: "reads or writes files",
|
|
32918
|
+
"writes-or-deletes": "changes or deletes data",
|
|
32919
|
+
"sends-messages": "sends messages or posts content",
|
|
32920
|
+
money: "moves money or makes purchases"
|
|
32921
|
+
};
|
|
32922
|
+
var RULES = [
|
|
32923
|
+
{ cap: "code-execution", name: /(^|[_-])(exec|execute|eval|shell|bash|terminal|psql|run_command|run_code|run_script)([_-]|$)|exec_in_/i, text: /\b(execute|run)s? (a |an |the )?(shell|terminal|bash|command|script|code|program|sql|query)\b/i, strong: /\b(arbitrary (code|commands?)|shell commands?|(executes?|runs?) (shell|terminal|bash) commands?|runs? (javascript|python) code|starts? (a |an )?(new )?(terminal|shell) (process|session))\b/i, arg: /^(command|cmd|script|code|shell)$/i },
|
|
32924
|
+
{ cap: "filesystem", name: /(^|[_-])(read_file|write_file|edit_file|move_file|list_directory|create_directory|directory_tree|filesystem|fs)([_-]|$)/i, text: /\b(local )?file ?system\b|\bon (the )?(local )?(disk|machine)\b|\b(files?|director(y|ies)) (on|in) the (user'?s )?(computer|machine|disk)\b/i, arg: /^(path|filepath|file_path|directory|dir)$/i },
|
|
32925
|
+
{ cap: "network", name: /(^|[_-])(fetch|http|download|webhook|crawl|scrape|browse|navigate)([_-]|$)/i, text: /\b(fetch(es)? (a |the )?(url|web ?page|website)|http requests?|crawls?|scrapes?|web ?hooks?|downloads? .{0,20} from)\b/i, strong: /\b(http requests?|fetch(es)? (a |the |any )?(url|web ?page|website))\b/i, arg: /^(url|uri|endpoint|webhook|href)$/i },
|
|
32926
|
+
{ cap: "untrusted-content", name: /(^|[_-])(fetch|crawl|scrape|browse|web_search|read_email|get_email|read_emails|read_message|read_messages)([_-]|$)/i, text: /\b(web ?pages?|websites?|internet|emails?|inbox|scrap(e|es|ing)|crawl(s|ing)?)\b/i, strong: /\b(search(es)? the (web|internet)|web search|scrap(e|es|ing) (web|pages|sites)|crawl(s|ing)? (a |the )?(web|site|website)|web ?pages?)\b/i },
|
|
32927
|
+
{ cap: "reads-private-data", arg: /^(sql)$/i, name: /(^|[_-])(query|sql|customers?|contacts?|inbox|calendar|crm|database|db)([_-]|$)/i, text: /\b(reads?|retrieves?|gets?|lists?|search(es)?|quer(y|ies)|looks? up|fetch(es)?|returns?)\b.{0,40}\b(database|customers?|contacts?|account (data|details)|personal|private|inbox|calendar|crm)\b/i },
|
|
32928
|
+
{ cap: "writes-or-deletes", name: /(^|[_-])(create|update|delete|remove|write|insert|upsert|drop|patch|edit|modify|move|rename|overwrite|reset|commit|push|purge)([_-]|$)/i, text: /\b(deletes?|removes?|overwrites?|modif(y|ies)|updates?|creates?|writes?) (a |an |the |one or more )?(new )?\w+/i },
|
|
32929
|
+
{ cap: "sends-messages", name: /(^|[_-])(send|notify|reply|tweet|sms|send_message|send_email|post_message)([_-]|$)/i, text: /\bsends? (an? )?(new )?(email|message|sms|notification)|\bposts? (a |an )?(new )?(message|comment|tweet|reply)\b|\brepl(y|ies) to (a |the )?(specific )?(message|thread|email)/i, strong: /\bsends? (an? )?(email|sms|text message|slack message)s?\b|\bposts? (a |an )?(new )?message to (a |the )?(slack )?channel\b/i },
|
|
32930
|
+
{ cap: "money", name: /(^|[_-])(pay|payment|payments|charge|refund|refunds|invoice|invoices|payout|purchase|billing)([_-]|$)/i, text: /\b(payments?|charges? (a |the )?(card|customer)|refunds?|invoices?|transfers? (funds|money)|purchases?)\b/i, strong: /\b(refunds? (a |the )?(payment|charge)|charges? (a |the )?(card|customer)|creates? (a |an )?(invoice|payment|payout))\b/i }
|
|
32931
|
+
];
|
|
32932
|
+
function capabilityProfile(tools) {
|
|
32933
|
+
const found = /* @__PURE__ */ new Map();
|
|
32934
|
+
const add = (c, tool, declared = false) => {
|
|
32935
|
+
const e = found.get(c) ?? { tools: /* @__PURE__ */ new Set(), declared: false };
|
|
32936
|
+
e.tools.add(sanitizeText(tool, 60));
|
|
32937
|
+
e.declared ||= declared;
|
|
32938
|
+
found.set(c, e);
|
|
32939
|
+
};
|
|
32940
|
+
for (const t of tools) {
|
|
32941
|
+
const a = t.annotations ?? {};
|
|
32942
|
+
if (a.openWorldHint === true)
|
|
32943
|
+
add("network", t.name, true);
|
|
32944
|
+
if (a.destructiveHint === true || a.readOnlyHint === false)
|
|
32945
|
+
add("writes-or-deletes", t.name, true);
|
|
32946
|
+
const args = Object.keys((t.inputSchema ?? {}).properties ?? {});
|
|
32947
|
+
const desc = (t.description ?? "").trim().split(/(?<=[.!?])\s/)[0].slice(0, 280);
|
|
32948
|
+
for (const r of RULES) {
|
|
32949
|
+
if (r.cap === "writes-or-deletes" && a.readOnlyHint === true)
|
|
32950
|
+
continue;
|
|
32951
|
+
const signals = Number(r.name.test(t.name)) + Number(r.text.test(desc)) + Number(Boolean(r.arg && args.some((x) => r.arg.test(x))));
|
|
32952
|
+
if (signals >= 2 || r.strong && r.strong.test(desc))
|
|
32953
|
+
add(r.cap, t.name);
|
|
32954
|
+
}
|
|
32955
|
+
}
|
|
32956
|
+
const has2 = (c) => found.has(c);
|
|
32957
|
+
const lethalTrifecta = has2("reads-private-data") && has2("untrusted-content") && (has2("network") || has2("sends-messages"));
|
|
32958
|
+
const order = Object.keys(CAPABILITY_LABELS);
|
|
32959
|
+
return {
|
|
32960
|
+
capabilities: order.filter(has2).map((c) => ({ capability: c, label: CAPABILITY_LABELS[c], tools: [...found.get(c).tools].slice(0, 8), basis: found.get(c).declared ? "declared" : "inferred" })),
|
|
32961
|
+
lethalTrifecta,
|
|
32962
|
+
note: "Inferred from annotations, tool names, descriptions and argument names; it describes what the tools appear able to do, not a finding."
|
|
32963
|
+
};
|
|
32964
|
+
}
|
|
32965
|
+
|
|
32966
|
+
// packages/testkit-core/dist/functional.js
|
|
32967
|
+
init_contracts();
|
|
32968
|
+
var FUNCTIONAL_LIMITS = { maxSmokeTools: 8, perCallTimeoutMs: 15e3, survivalWaitMs: 500 };
|
|
32969
|
+
var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
32970
|
+
function exampleFor(schema, depth = 0) {
|
|
32971
|
+
const s = obj(schema);
|
|
32972
|
+
if (depth > 6)
|
|
32973
|
+
return null;
|
|
32974
|
+
if ("const" in s)
|
|
32975
|
+
return s.const;
|
|
32976
|
+
if (Array.isArray(s.examples) && s.examples.length)
|
|
32977
|
+
return s.examples[0];
|
|
32978
|
+
if ("default" in s)
|
|
32979
|
+
return s.default;
|
|
32980
|
+
if (Array.isArray(s.enum) && s.enum.length)
|
|
32981
|
+
return s.enum[0];
|
|
32982
|
+
for (const k of ["oneOf", "anyOf"])
|
|
32983
|
+
if (Array.isArray(s[k]) && s[k].length)
|
|
32984
|
+
return exampleFor(s[k][0], depth + 1);
|
|
32985
|
+
if (Array.isArray(s.allOf) && s.allOf.length)
|
|
32986
|
+
return exampleFor(Object.assign({}, ...s.allOf.map(obj)), depth + 1);
|
|
32987
|
+
const type = Array.isArray(s.type) ? s.type.find((t) => t !== "null") : s.type;
|
|
32988
|
+
switch (type ?? (s.properties ? "object" : void 0)) {
|
|
32989
|
+
case "object": {
|
|
32990
|
+
const out = {};
|
|
32991
|
+
const props = obj(s.properties);
|
|
32992
|
+
for (const key of Array.isArray(s.required) ? s.required : [])
|
|
32993
|
+
out[key] = exampleFor(props[key], depth + 1);
|
|
32994
|
+
return out;
|
|
32995
|
+
}
|
|
32996
|
+
case "array": {
|
|
32997
|
+
const n = typeof s.minItems === "number" ? Math.min(s.minItems, 3) : 0;
|
|
32998
|
+
return Array.from({ length: n }, () => exampleFor(s.items, depth + 1));
|
|
32999
|
+
}
|
|
33000
|
+
case "integer":
|
|
33001
|
+
case "number": {
|
|
33002
|
+
let v = typeof s.minimum === "number" ? s.minimum : typeof s.exclusiveMinimum === "number" ? s.exclusiveMinimum + 1 : 1;
|
|
33003
|
+
if (typeof s.maximum === "number" && v > s.maximum)
|
|
33004
|
+
v = s.maximum;
|
|
33005
|
+
return type === "integer" ? Math.ceil(v) : v;
|
|
33006
|
+
}
|
|
33007
|
+
case "boolean":
|
|
33008
|
+
return false;
|
|
33009
|
+
case "null":
|
|
33010
|
+
return null;
|
|
33011
|
+
case "string": {
|
|
33012
|
+
const fmt2 = { uri: "https://example.com", url: "https://example.com", email: "user@example.com", date: "2026-01-15", "date-time": "2026-01-15T09:00:00Z", uuid: "123e4567-e89b-42d3-a456-426614174000", hostname: "example.com", ipv4: "192.0.2.1" };
|
|
33013
|
+
let v = fmt2[String(s.format)] ?? "example";
|
|
33014
|
+
if (typeof s.minLength === "number" && v.length < s.minLength)
|
|
33015
|
+
v = v.padEnd(s.minLength, "x");
|
|
33016
|
+
if (typeof s.maxLength === "number" && v.length > s.maxLength)
|
|
33017
|
+
v = v.slice(0, Math.max(1, s.maxLength));
|
|
33018
|
+
return v;
|
|
33019
|
+
}
|
|
33020
|
+
default:
|
|
33021
|
+
return "example";
|
|
33022
|
+
}
|
|
33023
|
+
}
|
|
33024
|
+
function invalidArgsFor(schema) {
|
|
33025
|
+
const s = obj(schema);
|
|
33026
|
+
const required2 = Array.isArray(s.required) ? s.required : [];
|
|
33027
|
+
if (required2.length)
|
|
33028
|
+
return {};
|
|
33029
|
+
const first = Object.entries(obj(s.properties))[0];
|
|
33030
|
+
if (!first)
|
|
33031
|
+
return void 0;
|
|
33032
|
+
const t = obj(first[1]).type;
|
|
33033
|
+
return { [first[0]]: t === "string" ? 12345 : "not-the-right-type" };
|
|
33034
|
+
}
|
|
33035
|
+
var isReadOnly = (t) => t.annotations?.readOnlyHint === true;
|
|
33036
|
+
function resultProblems(tool, o) {
|
|
33037
|
+
if (o.kind !== "result" || o.isError)
|
|
33038
|
+
return [];
|
|
33039
|
+
const p = [];
|
|
33040
|
+
if (!Array.isArray(o.content))
|
|
33041
|
+
p.push("content is not an array");
|
|
33042
|
+
else
|
|
33043
|
+
for (const c of o.content) {
|
|
33044
|
+
const it = obj(c);
|
|
33045
|
+
if (typeof it.type !== "string") {
|
|
33046
|
+
p.push("a content item has no type");
|
|
33047
|
+
break;
|
|
33048
|
+
}
|
|
33049
|
+
if (it.type === "text" && typeof it.text !== "string") {
|
|
33050
|
+
p.push("a text content item has no text");
|
|
33051
|
+
break;
|
|
33052
|
+
}
|
|
33053
|
+
}
|
|
33054
|
+
const outSchema = tool.outputSchema;
|
|
33055
|
+
if (outSchema) {
|
|
33056
|
+
if (o.structuredContent === void 0)
|
|
33057
|
+
p.push("the tool declares an outputSchema but returned no structuredContent");
|
|
33058
|
+
else {
|
|
33059
|
+
const v = compileUntrustedSchemaValidator(outSchema);
|
|
33060
|
+
if (!v.ok)
|
|
33061
|
+
p.push(`its outputSchema is not valid JSON Schema (${v.error.slice(0, 80)})`);
|
|
33062
|
+
else if (!v.validate(o.structuredContent))
|
|
33063
|
+
p.push(`structuredContent does not match its outputSchema (${v.errors().slice(0, 120)})`);
|
|
33064
|
+
}
|
|
33065
|
+
}
|
|
33066
|
+
return p;
|
|
33067
|
+
}
|
|
33068
|
+
function invalidArgProblems(o) {
|
|
33069
|
+
const p = [];
|
|
33070
|
+
if (o.kind === "timeout")
|
|
33071
|
+
p.push("timed out instead of rejecting the invalid arguments");
|
|
33072
|
+
else if (o.kind === "transport-error")
|
|
33073
|
+
p.push("the connection failed (the server may have crashed)");
|
|
33074
|
+
else if (o.kind === "result" && !o.isError)
|
|
33075
|
+
p.push("accepted arguments that violate its input schema and reported success");
|
|
33076
|
+
const text = outcomeText(o);
|
|
33077
|
+
const leak = LEAK_PATTERNS.find((l) => l.re.test(text));
|
|
33078
|
+
if (leak)
|
|
33079
|
+
p.push(`its error exposes ${/^[aeiou]/i.test(leak.name) ? "an" : "a"} ${leak.name}`);
|
|
33080
|
+
return p;
|
|
33081
|
+
}
|
|
33082
|
+
async function runFunctional(session, tools, opts) {
|
|
33083
|
+
if (!opts.active)
|
|
33084
|
+
return { ran: false, reason: "Tools are called only with --active, against servers you own.", calledTools: [], notCalled: [], calls: [] };
|
|
33085
|
+
const allow = new Set(opts.allowTools ?? []);
|
|
33086
|
+
const notCalled = [];
|
|
33087
|
+
const eligible = [];
|
|
33088
|
+
for (const t of tools) {
|
|
33089
|
+
if (allow.has(t.name) || isReadOnly(t))
|
|
33090
|
+
eligible.push(t);
|
|
33091
|
+
else
|
|
33092
|
+
notCalled.push({ tool: t.name, why: t.annotations?.destructiveHint ? "destructive (never called automatically)" : "not annotated read-only (name it with --call to include it)" });
|
|
33093
|
+
}
|
|
33094
|
+
const chosen = eligible.slice(0, FUNCTIONAL_LIMITS.maxSmokeTools);
|
|
33095
|
+
for (const t of eligible.slice(FUNCTIONAL_LIMITS.maxSmokeTools))
|
|
33096
|
+
notCalled.push({ tool: t.name, why: `limit of ${FUNCTIONAL_LIMITS.maxSmokeTools} tools per run` });
|
|
33097
|
+
const calls = [];
|
|
33098
|
+
for (const t of chosen) {
|
|
33099
|
+
const args = exampleFor(t.inputSchema);
|
|
33100
|
+
const inCheck = compileUntrustedSchemaValidator(t.inputSchema);
|
|
33101
|
+
if (inCheck.ok && !inCheck.validate(args)) {
|
|
33102
|
+
notCalled.push({ tool: t.name, why: "could not generate arguments that satisfy its input schema (add a test case for it)" });
|
|
33103
|
+
continue;
|
|
33104
|
+
}
|
|
33105
|
+
const outcome = await session.callTool(t.name, args);
|
|
33106
|
+
const problems = outcome.kind === "result" ? resultProblems(t, outcome) : outcome.kind === "protocol-error" && outcome.code === -32602 ? ["rejected arguments that satisfy its own input schema"] : outcome.kind === "protocol-error" ? [] : [`${outcome.kind === "timeout" ? "timed out" : "the call failed"}`];
|
|
33107
|
+
calls.push({ tool: t.name, purpose: "smoke", args, outcome, problems });
|
|
33108
|
+
const bad = invalidArgsFor(t.inputSchema);
|
|
33109
|
+
if (bad) {
|
|
33110
|
+
const o2 = await session.callTool(t.name, bad);
|
|
33111
|
+
calls.push({ tool: t.name, purpose: "invalid-args", args: bad, outcome: o2, problems: invalidArgProblems(o2) });
|
|
33112
|
+
}
|
|
33113
|
+
}
|
|
33114
|
+
let survived;
|
|
33115
|
+
if (calls.length) {
|
|
33116
|
+
await new Promise((r) => setTimeout(r, FUNCTIONAL_LIMITS.survivalWaitMs));
|
|
33117
|
+
try {
|
|
33118
|
+
await session.listTools();
|
|
33119
|
+
survived = true;
|
|
33120
|
+
} catch {
|
|
33121
|
+
survived = false;
|
|
33122
|
+
}
|
|
33123
|
+
}
|
|
33124
|
+
return { ran: true, calledTools: [...new Set(calls.map((c) => c.tool))], notCalled, calls, survived };
|
|
33125
|
+
}
|
|
33126
|
+
function subsetMatch(expected, actual) {
|
|
33127
|
+
if (expected === null || typeof expected !== "object")
|
|
33128
|
+
return expected === actual;
|
|
33129
|
+
if (Array.isArray(expected))
|
|
33130
|
+
return Array.isArray(actual) && expected.length === actual.length && expected.every((e, i) => subsetMatch(e, actual[i]));
|
|
33131
|
+
if (!actual || typeof actual !== "object")
|
|
33132
|
+
return false;
|
|
33133
|
+
return Object.entries(expected).every(([k, v]) => subsetMatch(v, actual[k]));
|
|
33134
|
+
}
|
|
33135
|
+
async function runTestCases(session, tools, cases, opts) {
|
|
33136
|
+
const out = [];
|
|
33137
|
+
for (const tc of cases) {
|
|
33138
|
+
const tool = tools.find((t) => t.name === tc.tool);
|
|
33139
|
+
if (!tool) {
|
|
33140
|
+
out.push({ id: tc.id, tool: tc.tool, status: "fail", problems: [`the server does not list a tool named ${sanitizeText(tc.tool, 60)}`] });
|
|
33141
|
+
continue;
|
|
33142
|
+
}
|
|
33143
|
+
if (tc.sideEffects && !opts.active) {
|
|
33144
|
+
out.push({ id: tc.id, tool: tc.tool, status: "skipped", problems: ["has side effects: runs only with --active against a server you own"] });
|
|
33145
|
+
continue;
|
|
33146
|
+
}
|
|
33147
|
+
const o = await session.callTool(tc.tool, tc.input);
|
|
33148
|
+
const p = [];
|
|
33149
|
+
const e = tc.expect;
|
|
33150
|
+
const isError = o.kind === "result" ? o.isError : true;
|
|
33151
|
+
if (o.kind !== "result" && e.isError !== true)
|
|
33152
|
+
p.push(o.kind === "protocol-error" ? `protocol error ${o.code}: ${sanitizeText(o.message, 120)}` : o.kind === "timeout" ? "timed out" : "the call failed");
|
|
33153
|
+
if (e.isError !== void 0 && isError !== e.isError)
|
|
33154
|
+
p.push(e.isError ? "expected an error result but the call succeeded" : "expected success but got an error result");
|
|
33155
|
+
const text = outcomeText(o);
|
|
33156
|
+
if (e.textContains !== void 0 && !text.includes(e.textContains))
|
|
33157
|
+
p.push(`the result does not contain "${sanitizeText(e.textContains, 60)}"`);
|
|
33158
|
+
if (e.structured !== void 0 && !(o.kind === "result" && subsetMatch(e.structured, o.structuredContent)))
|
|
33159
|
+
p.push("structuredContent does not match the expected values");
|
|
33160
|
+
if (e.outputSchema)
|
|
33161
|
+
p.push(...resultProblems(tool, o).filter((x) => /outputSchema|structuredContent/.test(x)));
|
|
33162
|
+
if (e.latencyMs?.lt !== void 0 && o.latencyMs >= e.latencyMs.lt)
|
|
33163
|
+
p.push(`took ${o.latencyMs} ms (expected under ${e.latencyMs.lt} ms)`);
|
|
33164
|
+
out.push({ id: tc.id, tool: tc.tool, status: p.length ? "fail" : "pass", problems: p, latencyMs: o.latencyMs });
|
|
33165
|
+
}
|
|
33166
|
+
return out;
|
|
33167
|
+
}
|
|
33168
|
+
async function parseTestCases(text) {
|
|
33169
|
+
const { parse: parse3 } = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
33170
|
+
const { compileContract: compileContract2 } = await Promise.resolve().then(() => (init_contracts(), contracts_exports));
|
|
33171
|
+
const data = parse3(text);
|
|
33172
|
+
const validate2 = compileContract2("test-cases.schema.json");
|
|
33173
|
+
if (!validate2(data))
|
|
33174
|
+
throw new Error(`Invalid test cases: ${(validate2.errors ?? []).map((e) => `${e.instancePath || "/"} ${e.message}`).join("; ")}`);
|
|
33175
|
+
return data.tests;
|
|
33176
|
+
}
|
|
33177
|
+
|
|
33178
|
+
// packages/testkit-core/dist/load.js
|
|
33179
|
+
var LOAD = { latencySamples: 10, levels: [1, 5, 20], perLevelRequests: 20 };
|
|
33180
|
+
function percentile(values, p) {
|
|
33181
|
+
if (!values.length)
|
|
33182
|
+
return 0;
|
|
33183
|
+
const s = [...values].sort((a, b) => a - b);
|
|
33184
|
+
return s[Math.min(s.length - 1, Math.max(0, Math.ceil(p / 100 * s.length) - 1))];
|
|
33185
|
+
}
|
|
33186
|
+
async function measureLoad(session, op) {
|
|
33187
|
+
const operation = op ? `calling ${op.tool}` : "listing tools";
|
|
33188
|
+
const once = async () => {
|
|
33189
|
+
const t = Date.now();
|
|
33190
|
+
try {
|
|
33191
|
+
if (op) {
|
|
33192
|
+
const o = await session.callTool(op.tool, op.args);
|
|
33193
|
+
const limited = o.kind === "protocol-error" && /429|rate.?limit/i.test(o.message);
|
|
33194
|
+
return { ms: Date.now() - t, ok: o.kind === "result" && !o.isError, limited };
|
|
33195
|
+
}
|
|
33196
|
+
await session.listTools();
|
|
33197
|
+
return { ms: Date.now() - t, ok: true, limited: false };
|
|
33198
|
+
} catch (e) {
|
|
33199
|
+
return { ms: Date.now() - t, ok: false, limited: /429|rate.?limit/i.test(String(e.message)) };
|
|
33200
|
+
}
|
|
33201
|
+
};
|
|
33202
|
+
const lat = [];
|
|
33203
|
+
for (let i = 0; i < LOAD.latencySamples; i++)
|
|
33204
|
+
lat.push((await once()).ms);
|
|
33205
|
+
const levels = [];
|
|
33206
|
+
for (const c of LOAD.levels) {
|
|
33207
|
+
const results = [];
|
|
33208
|
+
const t0 = Date.now();
|
|
33209
|
+
let next = 0;
|
|
33210
|
+
await Promise.all(Array.from({ length: c }, async () => {
|
|
33211
|
+
while (next < LOAD.perLevelRequests) {
|
|
33212
|
+
next++;
|
|
33213
|
+
results.push(await once());
|
|
33214
|
+
}
|
|
33215
|
+
}));
|
|
33216
|
+
const secs = Math.max(1e-3, (Date.now() - t0) / 1e3);
|
|
33217
|
+
levels.push({
|
|
33218
|
+
concurrency: c,
|
|
33219
|
+
requests: results.length,
|
|
33220
|
+
ok: results.filter((r) => r.ok).length,
|
|
33221
|
+
rateLimited: results.filter((r) => r.limited).length,
|
|
33222
|
+
errors: results.filter((r) => !r.ok && !r.limited).length,
|
|
33223
|
+
p95: percentile(results.map((r) => r.ms), 95),
|
|
33224
|
+
throughput: Math.round(results.length / secs * 10) / 10
|
|
33225
|
+
});
|
|
33226
|
+
}
|
|
33227
|
+
const p50 = percentile(lat, 50), p95 = percentile(lat, 95);
|
|
33228
|
+
const verdicts = [];
|
|
33229
|
+
verdicts.push(p95 < 300 ? `Fast: ${operation} takes ${p95} ms at p95, fine for interactive agents.` : p95 < 1e3 ? `Acceptable: ${p95} ms at p95 for ${operation}; agents will notice delays in long tool chains.` : `Slow: ${p95} ms at p95 for ${operation}; agents and clients may time out.`);
|
|
33230
|
+
const top = levels[levels.length - 1];
|
|
33231
|
+
const base = levels[0];
|
|
33232
|
+
if (top.errors > 0)
|
|
33233
|
+
verdicts.push(`Under ${top.concurrency} concurrent callers, ${top.errors} of ${top.requests} requests failed: check limits and connection handling.`);
|
|
33234
|
+
else if (top.rateLimited > 0)
|
|
33235
|
+
verdicts.push(`Under ${top.concurrency} concurrent callers it rate-limited ${top.rateLimited} requests, which is healthy behaviour.`);
|
|
33236
|
+
else
|
|
33237
|
+
verdicts.push(`Handled ${top.concurrency} concurrent callers with no errors (${top.throughput} requests per second; p95 ${top.p95} ms against ${base.p95} ms with one caller).`);
|
|
33238
|
+
return { operation, latency: { p50, p95, samples: lat.length }, levels, verdicts };
|
|
33239
|
+
}
|
|
33240
|
+
|
|
32770
33241
|
// packages/testkit-core/dist/engine.js
|
|
32771
|
-
var ENGINE_VERSION = "0.
|
|
33242
|
+
var ENGINE_VERSION = "0.2.0";
|
|
32772
33243
|
var UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
|
|
32773
33244
|
var INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
|
|
32774
|
-
var BURST_REQUESTS = 20;
|
|
32775
33245
|
function isProtocolFailure(e) {
|
|
32776
33246
|
const m = String(e?.message ?? e);
|
|
32777
33247
|
return !/ENOENT|EACCES|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|fetch failed|timed out|spawn|Connection closed|socket hang up/i.test(m);
|
|
@@ -32786,8 +33256,9 @@ var baseOf = (pack, check) => ({
|
|
|
32786
33256
|
references: check.references
|
|
32787
33257
|
});
|
|
32788
33258
|
var MIN_GRADED_CHECKS = 5;
|
|
32789
|
-
function finish(target, opts, startedAt, findings, extra, metrics, sandbox, noGrade, readiness = null) {
|
|
32790
|
-
const categoryOf = (id) => opts.packs.find((p) => p.pack.id === id)?.pack.category ?? "other";
|
|
33259
|
+
function finish(target, opts, startedAt, findings, extra, metrics, sandbox, noGrade, readiness = null, more = {}) {
|
|
33260
|
+
const categoryOf = (id) => id === "tests" ? "functional" : opts.packs.find((p) => p.pack.id === id)?.pack.category ?? "other";
|
|
33261
|
+
applySuppressions(findings, opts.ignore);
|
|
32791
33262
|
const scores = score(findings, categoryOf);
|
|
32792
33263
|
const ran = findings.filter((f) => f.scored && (f.status === "pass" || f.status === "fail") && categoryOf(f.pack) in TRUST_WEIGHTS).length;
|
|
32793
33264
|
const reason = noGrade ?? (ran < MIN_GRADED_CHECKS ? { kind: "too-few" } : void 0);
|
|
@@ -32804,29 +33275,39 @@ function finish(target, opts, startedAt, findings, extra, metrics, sandbox, noGr
|
|
|
32804
33275
|
metrics,
|
|
32805
33276
|
readiness,
|
|
32806
33277
|
coverage: { trustChecksRun: ran },
|
|
33278
|
+
...more,
|
|
33279
|
+
...opts.ignore?.length ? { suppressions: opts.ignore.map((i) => ({ check: i.check, reason: sanitizeText(i.reason, 200) })) } : {},
|
|
32807
33280
|
run: { startedAt: startedAt.toISOString(), durationMs: Date.now() - startedAt.getTime(), mode: opts.mode ?? "passive", runner: "self", sandbox }
|
|
32808
33281
|
};
|
|
32809
33282
|
r.summary = summarise(r, reason, (f) => categoryOf(f.pack) in TRUST_WEIGHTS);
|
|
32810
33283
|
return r;
|
|
32811
33284
|
}
|
|
32812
|
-
|
|
32813
|
-
|
|
32814
|
-
|
|
32815
|
-
|
|
32816
|
-
const
|
|
32817
|
-
|
|
32818
|
-
|
|
32819
|
-
|
|
32820
|
-
} catch (e) {
|
|
32821
|
-
if (/\b429\b|rate.?limit/i.test(String(e.message)))
|
|
32822
|
-
rateLimited++;
|
|
32823
|
-
else
|
|
32824
|
-
errors++;
|
|
33285
|
+
function applySuppressions(findings, ignore) {
|
|
33286
|
+
if (!ignore?.length)
|
|
33287
|
+
return;
|
|
33288
|
+
for (const f of findings) {
|
|
33289
|
+
const rule = ignore.find((i) => i.check === f.check || i.check.endsWith("*") && f.check.startsWith(i.check.slice(0, -1)));
|
|
33290
|
+
if (rule) {
|
|
33291
|
+
f.suppressed = { reason: sanitizeText(rule.reason, 200) };
|
|
33292
|
+
f.scored = false;
|
|
32825
33293
|
}
|
|
32826
|
-
|
|
32827
|
-
|
|
32828
|
-
|
|
32829
|
-
return {
|
|
33294
|
+
}
|
|
33295
|
+
}
|
|
33296
|
+
function summariseFunctional(f) {
|
|
33297
|
+
return {
|
|
33298
|
+
ran: f.ran,
|
|
33299
|
+
reason: f.reason,
|
|
33300
|
+
calledTools: f.calledTools,
|
|
33301
|
+
notCalled: f.notCalled,
|
|
33302
|
+
survived: f.survived,
|
|
33303
|
+
calls: f.calls.map((c) => ({
|
|
33304
|
+
tool: sanitizeText(c.tool, 60),
|
|
33305
|
+
purpose: c.purpose,
|
|
33306
|
+
outcome: c.outcome.kind === "result" ? c.outcome.isError ? "error result" : "success" : c.outcome.kind === "protocol-error" ? `protocol error ${c.outcome.code}` : c.outcome.kind,
|
|
33307
|
+
latencyMs: c.outcome.latencyMs,
|
|
33308
|
+
problems: c.problems.map((x) => sanitizeText(x, 200))
|
|
33309
|
+
}))
|
|
33310
|
+
};
|
|
32830
33311
|
}
|
|
32831
33312
|
async function runTrustCheck(target, opts) {
|
|
32832
33313
|
const startedAt = /* @__PURE__ */ new Date();
|
|
@@ -32862,6 +33343,7 @@ async function runTrustCheck(target, opts) {
|
|
|
32862
33343
|
}
|
|
32863
33344
|
ctx.session = session;
|
|
32864
33345
|
try {
|
|
33346
|
+
let testResults;
|
|
32865
33347
|
let listError;
|
|
32866
33348
|
let listShape = false;
|
|
32867
33349
|
if (session) {
|
|
@@ -32886,8 +33368,23 @@ async function runTrustCheck(target, opts) {
|
|
|
32886
33368
|
ctx.perf.cpuPct = u.cpuPct;
|
|
32887
33369
|
}
|
|
32888
33370
|
}
|
|
32889
|
-
if (mode === "active")
|
|
32890
|
-
ctx.perf.
|
|
33371
|
+
if (mode === "active" && !listError) {
|
|
33372
|
+
const rssBefore = ctx.perf.rssMb;
|
|
33373
|
+
ctx.functional = await runFunctional(session, ctx.tools, { active: true, allowTools: opts.callTools });
|
|
33374
|
+
const smokeOk = ctx.functional.calls.find((c) => c.purpose === "smoke" && c.outcome.kind === "result" && !c.outcome.isError && c.problems.length === 0);
|
|
33375
|
+
ctx.load = await measureLoad(session, smokeOk ? { tool: smokeOk.tool, args: smokeOk.args } : void 0);
|
|
33376
|
+
if (session.pid && rssBefore !== void 0) {
|
|
33377
|
+
const after = await processUsage(session.pid);
|
|
33378
|
+
if (after) {
|
|
33379
|
+
ctx.load.memoryGrowthMb = Math.round((after.rssMb - rssBefore) * 10) / 10;
|
|
33380
|
+
if (ctx.load.memoryGrowthMb > Math.max(50, rssBefore * 0.5))
|
|
33381
|
+
ctx.load.verdicts.push(`Memory grew by ${ctx.load.memoryGrowthMb} MB during the run: check for leaks.`);
|
|
33382
|
+
}
|
|
33383
|
+
}
|
|
33384
|
+
} else if (mode !== "active")
|
|
33385
|
+
ctx.functional = { ran: false, reason: "Tools are called only with --active, against servers you own.", calledTools: [], notCalled: [], calls: [] };
|
|
33386
|
+
if (opts.testCases?.length && !listError)
|
|
33387
|
+
testResults = await runTestCases(session, ctx.tools, opts.testCases, { active: mode === "active" });
|
|
32891
33388
|
}
|
|
32892
33389
|
const tools = ctx.tools;
|
|
32893
33390
|
const fingerprint = sha256Tag(canonicalize([...tools].sort((a, b) => String(a.name).localeCompare(String(b.name)))));
|
|
@@ -32918,6 +33415,17 @@ async function runTrustCheck(target, opts) {
|
|
|
32918
33415
|
findings.push({ ...base, status: v.status, message: v.message, subject: v.subject, evidence: v.evidence, ...v.status === "pass" || v.status === "skipped" || v.status === "info" ? { fix: void 0 } : {} });
|
|
32919
33416
|
}
|
|
32920
33417
|
}
|
|
33418
|
+
for (const t of testResults ?? [])
|
|
33419
|
+
findings.push({
|
|
33420
|
+
check: `test.${sanitizeText(t.id, 80)}`,
|
|
33421
|
+
pack: "tests",
|
|
33422
|
+
severity: "medium",
|
|
33423
|
+
scored: t.status !== "skipped",
|
|
33424
|
+
status: t.status,
|
|
33425
|
+
title: `Test case ${sanitizeText(t.id, 80)} (${sanitizeText(t.tool, 60)})`,
|
|
33426
|
+
message: t.status === "pass" ? `Passed${t.latencyMs !== void 0 ? ` in ${t.latencyMs} ms` : ""}.` : sanitizeText(t.problems.join("; "), 400),
|
|
33427
|
+
...t.status === "fail" ? { fix: "Fix the tool, or update the test case if the expectation is wrong." } : {}
|
|
33428
|
+
});
|
|
32921
33429
|
const cost = contextCost(tools, price);
|
|
32922
33430
|
const metrics = { ...cost, pricePerMTokUsd: price, performance: { ...ctx.perf } };
|
|
32923
33431
|
if (!session || listError) {
|
|
@@ -32926,19 +33434,27 @@ async function runTrustCheck(target, opts) {
|
|
|
32926
33434
|
delete metrics.contextCostPer1kTurnsUsd;
|
|
32927
33435
|
}
|
|
32928
33436
|
const noGrade = signInRequired ? { kind: "sign-in" } : listError ? { kind: "list-failed", error: sanitizeText(listError, 160) } : tools.length === 0 ? { kind: "no-tools", toolsCapability: Boolean(session?.capabilities?.tools) } : void 0;
|
|
32929
|
-
return finish(target, { ...opts, mode }, startedAt, findings, session ? { protocolVersion: session.protocolVersion, serverInfo: session.serverInfo, toolsFingerprint: fingerprint, toolCount: tools.length } : { toolCount: 0 }, metrics, session?.sandbox ?? "none", noGrade, session && !listError ? readinessFor(tools) : null
|
|
33437
|
+
return finish(target, { ...opts, mode }, startedAt, findings, session ? { protocolVersion: session.protocolVersion, serverInfo: session.serverInfo, toolsFingerprint: fingerprint, toolCount: tools.length } : { toolCount: 0 }, metrics, session?.sandbox ?? "none", noGrade, session && !listError ? readinessFor(tools) : null, {
|
|
33438
|
+
...session && !listError && tools.length ? { capabilities: capabilityProfile(tools) } : {},
|
|
33439
|
+
...ctx.functional ? { functional: summariseFunctional(ctx.functional) } : {},
|
|
33440
|
+
...ctx.load ? { load: ctx.load } : {},
|
|
33441
|
+
...testResults ? { tests: testResults } : {}
|
|
33442
|
+
});
|
|
32930
33443
|
} finally {
|
|
32931
33444
|
if (session && !opts.session)
|
|
32932
33445
|
await session.close();
|
|
32933
33446
|
}
|
|
32934
33447
|
}
|
|
32935
33448
|
|
|
33449
|
+
// packages/testkit-core/dist/index.js
|
|
33450
|
+
init_embedded();
|
|
33451
|
+
|
|
32936
33452
|
// packages/report/dist/index.js
|
|
32937
33453
|
var SEV_ORDER = ["critical", "high", "medium", "low", "info"];
|
|
32938
33454
|
var rank = (s) => SEV_ORDER.indexOf(s);
|
|
32939
33455
|
var SYMBOL = { fail: "\u2717 FAIL", inconclusive: "! INCONCLUSIVE", pass: "\u2713 PASS", skipped: "- SKIPPED", info: "i INFO" };
|
|
32940
33456
|
var FEEDBACK_URL = "https://github.com/soodhere/saktum-check/discussions";
|
|
32941
|
-
var COVERAGE_NOTE = "
|
|
33457
|
+
var COVERAGE_NOTE = "This version tests conformance, sign-in basics, security hygiene, functional behaviour (with --active or test cases), performance and agent readiness; deeper sign-in, injection and supply-chain checks arrive in later releases.";
|
|
32942
33458
|
var DISCLAIMER = "Findings describe this server at the time of the run. They are not a guarantee of security or correctness.";
|
|
32943
33459
|
var SELF_SIGNED_NOTE = "Assurance level L1 (self-tested): the signature proves this report was not changed after the run, not that it was run independently.";
|
|
32944
33460
|
var OWASP_MCP = [
|
|
@@ -32966,7 +33482,7 @@ var PARTIAL = {
|
|
|
32966
33482
|
MCP02: "danger annotations only; scope tests in v0.2 to v0.6",
|
|
32967
33483
|
MCP05: "schema validity only; active injection tests in v0.2",
|
|
32968
33484
|
MCP06: "hidden-instruction scanning only; adversarial agent tests in v0.6",
|
|
32969
|
-
MCP08: "error handling only; audit trails need runtime receipts
|
|
33485
|
+
MCP08: "error handling only; audit trails need runtime receipts from the Saktum gateway"
|
|
32970
33486
|
};
|
|
32971
33487
|
function owaspCoverage(r) {
|
|
32972
33488
|
return OWASP_MCP.map(([id, name]) => {
|
|
@@ -32983,6 +33499,59 @@ function owaspCoverage(r) {
|
|
|
32983
33499
|
};
|
|
32984
33500
|
});
|
|
32985
33501
|
}
|
|
33502
|
+
var PACK_DIMENSION = { conformance: "Conformance", auth: "Sign-in", security: "Security", functional: "Functional", tests: "Functional", performance: "Performance", "agent-experience": "Agent readiness" };
|
|
33503
|
+
var dim = (f) => PACK_DIMENSION[f.pack] ?? "Other";
|
|
33504
|
+
function trustCard(r) {
|
|
33505
|
+
const rows = [];
|
|
33506
|
+
const counted = (d) => r.findings.filter((f) => dim(f) === d && f.scored && !f.suppressed && (f.status === "pass" || f.status === "fail"));
|
|
33507
|
+
for (const d of ["Security", "Conformance", "Sign-in"]) {
|
|
33508
|
+
const fs = counted(d);
|
|
33509
|
+
const fails = fs.filter((f) => f.status === "fail");
|
|
33510
|
+
if (!fs.length) {
|
|
33511
|
+
const skipped = r.findings.find((f) => dim(f) === d && f.status === "skipped");
|
|
33512
|
+
const inconclusive = r.findings.find((f) => dim(f) === d && f.status === "inconclusive");
|
|
33513
|
+
rows.push({ dimension: d, mark: "-", text: skipped ? `not applicable: ${(skipped.message ?? "").replace(/\.$/, "").toLowerCase()}` : inconclusive ? `not tested: ${(inconclusive.message ?? "").replace(/\.$/, "")}` : "not tested" });
|
|
33514
|
+
} else
|
|
33515
|
+
rows.push({ dimension: d, mark: fails.length ? "\u2717" : "\u2713", text: fails.length ? `${fails.length} of ${fs.length} checks failed (worst: ${fails.sort((a, b) => rank(a.severity) - rank(b.severity))[0].severity})` : `${fs.length} checks passed` });
|
|
33516
|
+
}
|
|
33517
|
+
const fn = counted("Functional");
|
|
33518
|
+
const fnFails = fn.filter((f) => f.status === "fail");
|
|
33519
|
+
const called = r.functional?.calledTools.length ?? 0;
|
|
33520
|
+
if (fn.length)
|
|
33521
|
+
rows.push({ dimension: "Functional", mark: fnFails.length ? "\u2717" : "\u2713", text: `${fn.length - fnFails.length} of ${fn.length} functional checks passed${called ? ` (${called} tool${called === 1 ? "" : "s"} called)` : ""}${r.tests?.length ? `, ${r.tests.filter((t) => t.status === "pass").length} of ${r.tests.length} test cases` : ""}` });
|
|
33522
|
+
else
|
|
33523
|
+
rows.push({ dimension: "Functional", mark: "-", text: r.functional && !r.functional.ran ? "not tested: run with --active (read-only tools only) or add test cases with --tests" : "not tested: no tools were eligible to call (annotate read-only tools, use --call, or add test cases)" });
|
|
33524
|
+
if (r.load)
|
|
33525
|
+
rows.push({ dimension: "Performance", mark: r.load.levels.some((l) => l.errors) ? "!" : "\u2713", text: r.load.verdicts.join(" ") });
|
|
33526
|
+
else
|
|
33527
|
+
rows.push({ dimension: "Performance", mark: "-", text: `start-up and tool-list latency only${r.metrics.performance?.listMs !== void 0 ? ` (${r.metrics.performance.listMs} ms)` : ""}; run with --active for latency percentiles and concurrency` });
|
|
33528
|
+
if (r.readiness)
|
|
33529
|
+
rows.push({ dimension: "Agent readiness", mark: r.readiness.grade ?? "-", text: r.readiness.topImprovement ? `${r.readiness.topImprovement}` : "annotations, descriptions and context cost all good" });
|
|
33530
|
+
if (r.capabilities) {
|
|
33531
|
+
const caps = r.capabilities.capabilities.map((c) => c.label);
|
|
33532
|
+
rows.push({ dimension: "Capabilities", mark: r.capabilities.lethalTrifecta ? "!" : "i", text: caps.length ? `${caps.join("; ")}${r.capabilities.lethalTrifecta ? ". Warning: private data + untrusted content + outbound channel (the lethal trifecta); limit what agents can combine" : ""}` : "no notable capabilities inferred" });
|
|
33533
|
+
}
|
|
33534
|
+
return rows;
|
|
33535
|
+
}
|
|
33536
|
+
function scopeOfRun(r) {
|
|
33537
|
+
const lines = [];
|
|
33538
|
+
const ran = r.findings.filter((f) => f.status !== "skipped").length;
|
|
33539
|
+
const skipped = r.findings.filter((f) => f.status === "skipped");
|
|
33540
|
+
const reasons = /* @__PURE__ */ new Map();
|
|
33541
|
+
for (const f of skipped) {
|
|
33542
|
+
const k = (f.message ?? "skipped").replace(/\.$/, "");
|
|
33543
|
+
reasons.set(k, (reasons.get(k) ?? 0) + 1);
|
|
33544
|
+
}
|
|
33545
|
+
lines.push(`Mode: ${r.run.mode}${r.run.mode === "passive" ? " (no tool was called; only listing, a call to a non-existent tool, and read-only probes)" : " (tools were called as listed above)"}.`);
|
|
33546
|
+
lines.push(`${ran} checks ran; ${skipped.length} did not apply to this run.`);
|
|
33547
|
+
for (const [why, n] of reasons)
|
|
33548
|
+
lines.push(` ${n} \xB7 ${why}`);
|
|
33549
|
+
const later = owaspCoverage(r).filter((c) => !c.tested && c.later && !c.later.startsWith("not applicable")).map((c) => `${c.id} (${c.later})`);
|
|
33550
|
+
if (later.length)
|
|
33551
|
+
lines.push(`Not yet tested by this version: ${later.join("; ")}.`);
|
|
33552
|
+
lines.push("Full list of checks, with the standard behind each: saktum checks.");
|
|
33553
|
+
return lines;
|
|
33554
|
+
}
|
|
32986
33555
|
function renderTerminal(r) {
|
|
32987
33556
|
const s = (x, n) => sanitizeText(x, n);
|
|
32988
33557
|
const lines = [];
|
|
@@ -32997,12 +33566,15 @@ function renderTerminal(r) {
|
|
|
32997
33566
|
const rd = r.readiness;
|
|
32998
33567
|
lines.push(` AGENT READINESS ${rd.grade ?? "-"} (score ${rd.score} \xB7 annotations ${rd.toolsAnnotated}/${rd.toolCount} tools \xB7 ${rd.contextTokens.toLocaleString("en-US")} tokens per turn)`);
|
|
32999
33568
|
}
|
|
33569
|
+
const fn = r.findings.filter((f) => (f.pack === "functional" || f.pack === "tests") && f.scored && !f.suppressed && (f.status === "pass" || f.status === "fail"));
|
|
33570
|
+
lines.push(` FUNCTIONAL ${fn.length ? `${fn.filter((f) => f.status === "pass").length} of ${fn.length} checks passed${r.functional?.calledTools.length ? ` \xB7 ${r.functional.calledTools.length} tool${r.functional.calledTools.length === 1 ? "" : "s"} called` : ""}${r.tests?.length ? ` \xB7 ${r.tests.length} test cases` : ""}` : "not tested (run with --active, or add test cases)"}`);
|
|
33000
33571
|
lines.push(` ${COVERAGE_NOTE}`);
|
|
33001
33572
|
for (const line of r.summary ?? [])
|
|
33002
33573
|
lines.push(` ${s(line, 300)}`);
|
|
33003
33574
|
lines.push("");
|
|
33004
|
-
|
|
33005
|
-
|
|
33575
|
+
lines.push("TRUST CARD");
|
|
33576
|
+
for (const row of trustCard(r))
|
|
33577
|
+
lines.push(` ${row.dimension.padEnd(16)} ${row.mark.padEnd(2)} ${s(row.text, 400)}`);
|
|
33006
33578
|
lines.push("");
|
|
33007
33579
|
const shown = [...r.findings].filter((f) => f.status === "fail" || f.status === "inconclusive").sort((a, b) => rank(a.severity) - rank(b.severity));
|
|
33008
33580
|
for (const f of shown) {
|
|
@@ -33014,15 +33586,50 @@ function renderTerminal(r) {
|
|
|
33014
33586
|
if (f.fix && f.status === "fail")
|
|
33015
33587
|
lines.push(` Fix: ${s(f.fix, 300)}`);
|
|
33016
33588
|
}
|
|
33017
|
-
const
|
|
33589
|
+
const passedF = r.findings.filter((f) => f.status === "pass");
|
|
33590
|
+
const byDim = /* @__PURE__ */ new Map();
|
|
33591
|
+
for (const f of passedF)
|
|
33592
|
+
byDim.set(dim(f), (byDim.get(dim(f)) ?? 0) + 1);
|
|
33018
33593
|
const skipped = r.findings.filter((f) => f.status === "skipped").length;
|
|
33019
|
-
lines.push(`${SYMBOL.pass} ${
|
|
33594
|
+
lines.push(`${SYMBOL.pass} ${passedF.length} checks passed (${[...byDim].map(([d, n]) => `${n} ${d.toLowerCase()}`).join(", ")})${skipped ? ` \xB7 ${skipped} not applicable` : ""}`);
|
|
33020
33595
|
const info = r.findings.filter((f) => f.status === "info");
|
|
33021
33596
|
if (info.length) {
|
|
33022
33597
|
lines.push("");
|
|
33023
33598
|
for (const f of info)
|
|
33024
33599
|
lines.push(`i ${s(f.title)}: ${s(f.message, 300)}`);
|
|
33025
33600
|
}
|
|
33601
|
+
if (r.functional?.ran) {
|
|
33602
|
+
lines.push("");
|
|
33603
|
+
lines.push("TOOLS CALLED");
|
|
33604
|
+
for (const c of r.functional.calls)
|
|
33605
|
+
lines.push(` ${s(c.tool, 40).padEnd(30)} ${c.purpose.padEnd(13)} ${s(c.outcome, 40).padEnd(18)} ${String(c.latencyMs).padStart(5)} ms${c.problems.length ? ` \u2717 ${s(c.problems.join("; "), 200)}` : ""}`);
|
|
33606
|
+
for (const n of r.functional.notCalled)
|
|
33607
|
+
lines.push(` ${s(n.tool, 40).padEnd(30)} not called: ${s(n.why, 160)}`);
|
|
33608
|
+
}
|
|
33609
|
+
if (r.tests?.length) {
|
|
33610
|
+
lines.push("");
|
|
33611
|
+
lines.push("TEST CASES");
|
|
33612
|
+
for (const t of r.tests)
|
|
33613
|
+
lines.push(` ${t.status === "pass" ? "\u2713" : t.status === "fail" ? "\u2717" : "-"} ${s(t.id, 60).padEnd(30)} ${s(t.tool, 40).padEnd(24)} ${t.status === "pass" ? `${t.latencyMs ?? ""} ms` : s(t.problems.join("; "), 200)}`);
|
|
33614
|
+
}
|
|
33615
|
+
if (r.capabilities?.capabilities.length) {
|
|
33616
|
+
lines.push("");
|
|
33617
|
+
lines.push("CAPABILITIES (inferred from annotations, names and descriptions; informational)");
|
|
33618
|
+
for (const c of r.capabilities.capabilities)
|
|
33619
|
+
lines.push(` ${s(c.label, 80).padEnd(58)} ${c.basis === "declared" ? "declared" : "inferred"}: ${s(c.tools.join(", "), 160)}`);
|
|
33620
|
+
if (r.capabilities.lethalTrifecta)
|
|
33621
|
+
lines.push(" ! This server combines private data, untrusted content and an outbound channel (the lethal trifecta). Limit what an agent can do with it.");
|
|
33622
|
+
}
|
|
33623
|
+
if (r.suppressions?.length) {
|
|
33624
|
+
lines.push("");
|
|
33625
|
+
lines.push("IGNORED BY THE PROVIDER (not scored)");
|
|
33626
|
+
for (const x of r.suppressions)
|
|
33627
|
+
lines.push(` ${s(x.check, 60)}: ${s(x.reason, 200)}`);
|
|
33628
|
+
}
|
|
33629
|
+
lines.push("");
|
|
33630
|
+
lines.push("SCOPE OF THIS RUN");
|
|
33631
|
+
for (const l of scopeOfRun(r))
|
|
33632
|
+
lines.push(` ${s(l, 400)}`);
|
|
33026
33633
|
lines.push("");
|
|
33027
33634
|
lines.push("OWASP MCP Top 10 coverage in this run:");
|
|
33028
33635
|
for (const c of owaspCoverage(r)) {
|
|
@@ -33050,10 +33657,39 @@ function renderHtml(r) {
|
|
|
33050
33657
|
<p class="grade">Trust ${e(r.grade ?? "-")}${r.readiness ? ` · Agent readiness ${e(r.readiness.grade ?? "-")}` : ""}</p>
|
|
33051
33658
|
<p><small>${e(COVERAGE_NOTE)}</small></p>
|
|
33052
33659
|
${(r.summary ?? []).map((l) => `<p>${e(l)}</p>`).join("")}
|
|
33053
|
-
<table>${
|
|
33660
|
+
<h2>Trust card</h2><table>${trustCard(r).map((x) => `<tr><td>${e(x.dimension)}</td><td>${e(x.mark)}</td><td>${e(x.text)}</td></tr>`).join("")}</table>
|
|
33661
|
+
<h2>Findings</h2><table>${rows}</table>
|
|
33662
|
+
<h2>Scope of this run</h2>${scopeOfRun(r).map((l) => `<p>${e(l)}</p>`).join("")}
|
|
33054
33663
|
<h2>OWASP MCP Top 10 coverage</h2><table>${cov}</table>
|
|
33055
33664
|
<p><small>${e(SELF_SIGNED_NOTE)} ${e(DISCLAIMER)}</small></p></body></html>`;
|
|
33056
33665
|
}
|
|
33666
|
+
function badgeSvg(r) {
|
|
33667
|
+
const colour = (g) => ({ A: "#2e7d32", B: "#558b2f", C: "#f9a825", D: "#ef6c00", F: "#c62828" })[g ?? ""] ?? "#757575";
|
|
33668
|
+
const right = `trust ${r.grade ?? "-"} \xB7 readiness ${r.readiness?.grade ?? "-"}`;
|
|
33669
|
+
const lw = 52, rw = 7 * right.length + 14, w = lw + rw;
|
|
33670
|
+
const worst = [r.grade, r.readiness?.grade].filter(Boolean).sort().pop();
|
|
33671
|
+
const title = escapeHtml(`Saktum Check ${r.tool.version}: trust ${r.grade ?? "-"}, agent readiness ${r.readiness?.grade ?? "-"}; self-tested (L1) on ${r.run.startedAt.slice(0, 10)}`);
|
|
33672
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="20" role="img" aria-label="${title}"><title>${title}</title><rect width="${lw}" height="20" fill="#3b2e8c"/><rect x="${lw}" width="${rw}" height="20" fill="${colour(worst)}"/><g fill="#fff" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11"><text x="8" y="14">saktum</text><text x="${lw + 7}" y="14">${escapeHtml(right)}</text></g></svg>
|
|
33673
|
+
`;
|
|
33674
|
+
}
|
|
33675
|
+
function checksTable(packs, markdown = false) {
|
|
33676
|
+
const rows = packs.flatMap(({ pack }) => pack.checks.map((c) => ({
|
|
33677
|
+
id: c.id,
|
|
33678
|
+
title: c.title,
|
|
33679
|
+
area: PACK_DIMENSION[pack.id] ?? pack.category,
|
|
33680
|
+
severity: c.severity,
|
|
33681
|
+
scored: c.scored === false || c.severity === "info" ? "no" : "yes",
|
|
33682
|
+
when: `${c.safety === "active" ? "--active only" : "every run"}${c.appliesTo?.transports ? `, ${c.appliesTo.transports.join("/")} servers` : ""}`,
|
|
33683
|
+
basis: (c.normative ?? []).map((n) => `${n.source}${n.clause ? `: ${n.clause}` : ""} (${n.level})`).concat((c.references ?? []).filter((x) => /OWASP|CWE|RFC/.test(x))).slice(0, 3).join("; ")
|
|
33684
|
+
})));
|
|
33685
|
+
if (markdown)
|
|
33686
|
+
return [
|
|
33687
|
+
"| Check | What it tests | Area | Severity | Scored | When it runs | Standard |",
|
|
33688
|
+
"| --- | --- | --- | --- | --- | --- | --- |",
|
|
33689
|
+
...rows.map((x) => `| \`${x.id}\` | ${x.title} | ${x.area} | ${x.severity} | ${x.scored} | ${x.when} | ${x.basis.replace(/\|/g, "/")} |`)
|
|
33690
|
+
].join("\n") + "\n";
|
|
33691
|
+
return rows.map((x) => `${x.id.padEnd(34)} ${x.area.padEnd(16)} ${x.severity.padEnd(9)} ${x.when.padEnd(32)} ${x.title}`).join("\n") + "\n";
|
|
33692
|
+
}
|
|
33057
33693
|
|
|
33058
33694
|
// packages/cli/dist/doctor.js
|
|
33059
33695
|
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
@@ -33207,13 +33843,26 @@ var parseEnv = (kvs) => Object.fromEntries(kvs.map((kv) => {
|
|
|
33207
33843
|
}));
|
|
33208
33844
|
async function main(argv = process.argv) {
|
|
33209
33845
|
let exitCode = 0;
|
|
33210
|
-
const program2 = new Command().name("saktum").version(ENGINE_VERSION).description("Saktum Check: test MCP servers for conformance, sign-in, security and agent
|
|
33211
|
-
|
|
33846
|
+
const program2 = new Command().name("saktum").version(ENGINE_VERSION).description("Saktum Check: test MCP servers for trust (conformance, sign-in, security), functional behaviour, performance and agent readiness.").exitOverride();
|
|
33847
|
+
const withCheckOptions = (c, testsDefault) => c.option("--packs <dir>", "directory of packs (default: the built-in packs)").option("--out <file>", "signed JSON result", "saktum-report.json").option("--html <file>", "also write an HTML report").option("--badge <file>", "also write a README badge (SVG) with the trust and agent-readiness grades").option("--fail-on <severity>", "exit 1 if any failure at or above this severity", "high").option("--active", "call tools and measure load (only against servers you own; read-only tools unless named with --call)", false).option("--call <tool>", "with --active: also call this tool even if it is not annotated read-only (repeatable)", collect, []).option("--tests <file>", "run your test cases (YAML or JSON, see docs/TESTS.md)", testsDefault).option("--ignore <check=reason>", "ignore a check, with a reason shown in the report; check IDs may end with * (repeatable)", collect, []).option("--key <path>", "signing key file (created on first use)").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable); your own environment is never passed", collect, []).option("--header <Name: value>", 'HTTP header for a remote server, e.g. "Authorization: Bearer <token>" (repeatable)', collect, []).option("--price-per-mtok <usd>", "your model's price per million input tokens, for the context-cost estimate", "3");
|
|
33848
|
+
const runCheckCommand = async (targetParts, o) => {
|
|
33212
33849
|
if (!SEV.includes(o.failOn))
|
|
33213
33850
|
throw new Error(`--fail-on must be one of ${SEV.join(", ")}`);
|
|
33214
33851
|
const price = Number(o.pricePerMtok);
|
|
33215
33852
|
if (!Number.isFinite(price) || price < 0)
|
|
33216
33853
|
throw new Error("--price-per-mtok must be a number of US dollars, e.g. 3");
|
|
33854
|
+
const ignore = o.ignore.map((x) => {
|
|
33855
|
+
const i = x.indexOf("=");
|
|
33856
|
+
if (i < 1 || !x.slice(i + 1).trim())
|
|
33857
|
+
throw new Error(`--ignore must look like check.id="reason" (a reason is required)`);
|
|
33858
|
+
return { check: x.slice(0, i).trim(), reason: x.slice(i + 1).trim() };
|
|
33859
|
+
});
|
|
33860
|
+
let testCases;
|
|
33861
|
+
if (o.tests) {
|
|
33862
|
+
if (!existsSync3(o.tests))
|
|
33863
|
+
throw new Error(`Test file not found: ${o.tests}. See docs/TESTS.md for the format.`);
|
|
33864
|
+
testCases = await parseTestCases(readFileSync4(o.tests, "utf8"));
|
|
33865
|
+
}
|
|
33217
33866
|
const target = parseTarget(targetParts);
|
|
33218
33867
|
if (target.kind === "stdio" && o.env.length)
|
|
33219
33868
|
target.env = parseEnv(o.env);
|
|
@@ -33222,25 +33871,37 @@ async function main(argv = process.argv) {
|
|
|
33222
33871
|
const packs = o.packs ? loadPackDir(o.packs) : existsSync3(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
33223
33872
|
let result;
|
|
33224
33873
|
try {
|
|
33225
|
-
result = await runTrustCheck(target, { packs, mode: o.active ? "active" : "passive", pricePerMTokUsd: price });
|
|
33874
|
+
result = await runTrustCheck(target, { packs, mode: o.active ? "active" : "passive", pricePerMTokUsd: price, callTools: o.call, testCases, ignore });
|
|
33226
33875
|
} catch (e) {
|
|
33227
33876
|
process.stderr.write(`Could not connect to ${sanitizeText(targetParts.join(" "), 120)}: ${sanitizeText(e.message, 300)}
|
|
33228
33877
|
`);
|
|
33229
33878
|
process.stderr.write(`Hint: run saktum doctor ${targetParts[0]?.startsWith("http") ? "" : "-- "}${sanitizeText(targetParts.join(" "), 120)} to see why.
|
|
33230
33879
|
`);
|
|
33231
|
-
|
|
33232
|
-
return;
|
|
33880
|
+
return 2;
|
|
33233
33881
|
}
|
|
33234
33882
|
const signed = signDocument(result, loadOrCreateKey(o.key));
|
|
33235
33883
|
writeFileSync2(o.out, JSON.stringify(signed, null, 2));
|
|
33236
33884
|
if (o.html)
|
|
33237
33885
|
writeFileSync2(o.html, renderHtml(signed));
|
|
33886
|
+
if (o.badge)
|
|
33887
|
+
writeFileSync2(o.badge, badgeSvg(signed));
|
|
33238
33888
|
process.stdout.write(renderTerminal(signed) + "\n");
|
|
33239
33889
|
process.stdout.write(`
|
|
33240
|
-
Signed result: ${sanitizeText(o.out)} (verify with: saktum verify ${sanitizeText(o.out)})
|
|
33890
|
+
Signed result: ${sanitizeText(o.out)} (verify with: saktum verify ${sanitizeText(o.out)})${o.badge ? `
|
|
33891
|
+
Badge: ${sanitizeText(o.badge)}` : ""}
|
|
33241
33892
|
`);
|
|
33242
33893
|
const threshold = SEV.indexOf(o.failOn);
|
|
33243
|
-
|
|
33894
|
+
return signed.findings.some((f) => f.status === "fail" && !f.suppressed && SEV.indexOf(f.severity) <= threshold) ? 1 : 0;
|
|
33895
|
+
};
|
|
33896
|
+
withCheckOptions(program2.command("check").description("Test an MCP server: a URL, or the command that starts a local server (after --)").argument("<target...>", "https://host/mcp or -- node server.js")).action(async (targetParts, o) => {
|
|
33897
|
+
exitCode = await runCheckCommand(targetParts, o);
|
|
33898
|
+
});
|
|
33899
|
+
withCheckOptions(program2.command("test").description("Run your test cases (saktum.tests.yaml by default) plus every check, against a server").argument("<target...>", "https://host/mcp or -- node server.js"), "saktum.tests.yaml").action(async (targetParts, o) => {
|
|
33900
|
+
exitCode = await runCheckCommand(targetParts, o);
|
|
33901
|
+
});
|
|
33902
|
+
program2.command("checks").description("List every check: what it tests, the standard behind it, and when it runs").option("--markdown", "print a Markdown table (as in docs/CHECKS.md)", false).option("--packs <dir>", "directory of packs (default: the built-in packs)").action((o) => {
|
|
33903
|
+
const packs = o.packs ? loadPackDir(o.packs) : existsSync3(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
33904
|
+
process.stdout.write(checksTable(packs, o.markdown));
|
|
33244
33905
|
});
|
|
33245
33906
|
program2.command("doctor").description("Check your environment, and why a server will not start or connect").argument("[target...]", "optional: the same target you would pass to check").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (targetParts, o) => {
|
|
33246
33907
|
const r = await runDoctor(targetParts ?? [], o.env, o.header);
|