nulladrift 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -323,6 +323,18 @@ function sanitizeUrl(raw) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
// ../core/src/risk/untrusted.ts
|
|
327
|
+
function objectsIn(value) {
|
|
328
|
+
if (!Array.isArray(value)) return [];
|
|
329
|
+
return value.filter((member) => typeof member === "object" && member !== null);
|
|
330
|
+
}
|
|
331
|
+
function objectOr(value) {
|
|
332
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
333
|
+
}
|
|
334
|
+
function stringOr(value) {
|
|
335
|
+
return typeof value === "string" ? value : void 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
326
338
|
// ../core/src/risk/capability.ts
|
|
327
339
|
var CAPABILITY_SEVERITIES = ["critical", "high", "medium", "low"];
|
|
328
340
|
var CAPABILITY_KINDS = [
|
|
@@ -398,8 +410,9 @@ function argumentNames(inputSchema, depth = 0) {
|
|
|
398
410
|
return names;
|
|
399
411
|
}
|
|
400
412
|
function toolCapabilities(tool2) {
|
|
401
|
-
const
|
|
402
|
-
const
|
|
413
|
+
const subject = objectOr(tool2);
|
|
414
|
+
const name = normalize(stringOr(subject.name) ?? "");
|
|
415
|
+
const args = argumentNames(subject.inputSchema).map((argument) => [argument, normalize(argument)]);
|
|
403
416
|
const found = /* @__PURE__ */ new Map();
|
|
404
417
|
for (const rule of RULES) {
|
|
405
418
|
if (found.has(rule.kind)) continue;
|
|
@@ -416,11 +429,12 @@ function toolCapabilities(tool2) {
|
|
|
416
429
|
}
|
|
417
430
|
function surfaceCapabilities(tools) {
|
|
418
431
|
const byKind = /* @__PURE__ */ new Map();
|
|
419
|
-
for (const tool2 of tools) {
|
|
432
|
+
for (const tool2 of objectsIn(tools)) {
|
|
433
|
+
const label = stringOr(tool2.name) ?? "?";
|
|
420
434
|
for (const capability of toolCapabilities(tool2)) {
|
|
421
435
|
const existing = byKind.get(capability.kind);
|
|
422
|
-
if (existing) existing.tools.push(
|
|
423
|
-
else byKind.set(capability.kind, { ...capability, tools: [
|
|
436
|
+
if (existing) existing.tools.push(label);
|
|
437
|
+
else byKind.set(capability.kind, { ...capability, tools: [label] });
|
|
424
438
|
}
|
|
425
439
|
}
|
|
426
440
|
return [...byKind.values()].sort(
|
|
@@ -855,11 +869,11 @@ function capabilityViolations(lock, denied) {
|
|
|
855
869
|
if (!denied || denied.length === 0) return [];
|
|
856
870
|
const forbidden = new Set(denied);
|
|
857
871
|
const found = [];
|
|
858
|
-
for (const [server2, subject] of Object.entries(lock
|
|
859
|
-
for (const tool2 of subject.tools
|
|
872
|
+
for (const [server2, subject] of Object.entries(lock?.subjects ?? {})) {
|
|
873
|
+
for (const tool2 of objectsIn(objectOr(subject).tools)) {
|
|
860
874
|
for (const capability of toolCapabilities(tool2)) {
|
|
861
875
|
if (!forbidden.has(capability.kind)) continue;
|
|
862
|
-
found.push({ server: server2, tool: tool2.name ?? "?", kind: capability.kind, severity: capability.severity, evidence: capability.evidence });
|
|
876
|
+
found.push({ server: server2, tool: stringOr(tool2.name) ?? "?", kind: capability.kind, severity: capability.severity, evidence: capability.evidence });
|
|
863
877
|
}
|
|
864
878
|
}
|
|
865
879
|
}
|
|
@@ -894,29 +908,29 @@ function surfaceText(subject) {
|
|
|
894
908
|
const push = (field, text) => {
|
|
895
909
|
if (typeof text === "string" && text.length > 0) out.push({ field, text });
|
|
896
910
|
};
|
|
897
|
-
push("instructions", subject
|
|
898
|
-
for (const tool2 of subject
|
|
899
|
-
const where = tool2.name ?? "?";
|
|
911
|
+
push("instructions", subject?.instructions);
|
|
912
|
+
for (const tool2 of objectsIn(subject?.tools)) {
|
|
913
|
+
const where = stringOr(tool2.name) ?? "?";
|
|
900
914
|
push(`${where}.title`, tool2.title);
|
|
901
915
|
push(`${where}.description`, tool2.description);
|
|
902
916
|
schemaText(tool2.inputSchema, `${where}.inputSchema`, out);
|
|
903
917
|
schemaText(tool2.outputSchema, `${where}.outputSchema`, out);
|
|
904
918
|
}
|
|
905
|
-
for (const prompt2 of subject
|
|
906
|
-
const where = prompt2.name ?? "?";
|
|
919
|
+
for (const prompt2 of objectsIn(subject?.prompts)) {
|
|
920
|
+
const where = stringOr(prompt2.name) ?? "?";
|
|
907
921
|
push(`prompt:${where}.title`, prompt2.title);
|
|
908
922
|
push(`prompt:${where}.description`, prompt2.description);
|
|
909
|
-
for (const argument of prompt2.arguments
|
|
910
|
-
push(`prompt:${where}.${argument.name ?? "?"}`, argument.description);
|
|
923
|
+
for (const argument of objectsIn(prompt2.arguments)) {
|
|
924
|
+
push(`prompt:${where}.${stringOr(argument.name) ?? "?"}`, argument.description);
|
|
911
925
|
}
|
|
912
926
|
}
|
|
913
|
-
for (const resource2 of subject
|
|
914
|
-
const where = resource2.name ?? resource2.uri ?? "?";
|
|
927
|
+
for (const resource2 of objectsIn(subject?.resources)) {
|
|
928
|
+
const where = stringOr(resource2.name) ?? stringOr(resource2.uri) ?? "?";
|
|
915
929
|
push(`resource:${where}.title`, resource2.title);
|
|
916
930
|
push(`resource:${where}.description`, resource2.description);
|
|
917
931
|
}
|
|
918
|
-
for (const template of subject
|
|
919
|
-
const where = template.name ?? template.uriTemplate ?? "?";
|
|
932
|
+
for (const template of objectsIn(subject?.resourceTemplates)) {
|
|
933
|
+
const where = stringOr(template.name) ?? stringOr(template.uriTemplate) ?? "?";
|
|
920
934
|
push(`template:${where}.title`, template.title);
|
|
921
935
|
push(`template:${where}.description`, template.description);
|
|
922
936
|
}
|
|
@@ -1431,7 +1445,7 @@ import { dirname, join as join2 } from "path";
|
|
|
1431
1445
|
import { ClientCredentialsProvider, UnauthorizedError } from "@modelcontextprotocol/client";
|
|
1432
1446
|
|
|
1433
1447
|
// src/lib/version.ts
|
|
1434
|
-
var VERSION = "0.3.
|
|
1448
|
+
var VERSION = "0.3.1";
|
|
1435
1449
|
var USER_AGENT = `nulladrift/${VERSION}`;
|
|
1436
1450
|
|
|
1437
1451
|
// src/mcp/oauth.ts
|
|
@@ -3200,7 +3214,7 @@ function describeSurface(subject, previous) {
|
|
|
3200
3214
|
if (typeof subject !== "object" || subject === null) return [];
|
|
3201
3215
|
const entry = subject;
|
|
3202
3216
|
const lines = [];
|
|
3203
|
-
const capabilities = surfaceCapabilities(entry.tools
|
|
3217
|
+
const capabilities = surfaceCapabilities(entry.tools);
|
|
3204
3218
|
if (capabilities.length > 0) {
|
|
3205
3219
|
const worst = capabilities.some((c) => c.severity === "critical" || c.severity === "high");
|
|
3206
3220
|
const text = ` after accepting, this server can: ${capabilities.map((c) => c.kind).join(", ")}`;
|