nulladrift 0.6.0 → 0.6.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/README.md CHANGED
@@ -21,6 +21,12 @@ flagged the BCC. What `nulladrift` would have told you is narrower and still wor
21
21
  *the server you reviewed and approved as 1.0.15 is now answering as 1.0.16, and you never
22
22
  looked at it.* On a server that sends your mail, that is a reason to go look.
23
23
 
24
+ Since 0.6.0 it says so without taking the server's word for it. The lock records the npm package
25
+ behind the command by its integrity hash, so the day 1.0.16 became `latest`, `check` would have
26
+ reported `server.artifact.changed` -- a different release running, with nothing in the declared
27
+ surface to say what it does -- even had the server gone on reporting 1.0.15. It still reads no
28
+ code, so it would not have found the BCC. It would have failed the build until somebody looked.
29
+
24
30
  The broader class this does catch is the **rug pull**: a server that changes what a tool
25
31
  *claims to do* after you approved it. A description that grows a paragraph of instructions
26
32
  aimed at your agent. A schema that quietly accepts a new `path` argument. A
@@ -66,8 +72,10 @@ not a smaller audit, the spec lets the tool list vary with who is asking, so `ch
66
72
  those servers as needing credentials rather than pinning whatever an anonymous client sees.
67
73
 
68
74
  `init` reads the config files your clients already use, `.mcp.json`, `.vscode/mcp.json`,
69
- `.cursor/mcp.json`, `~/.claude.json`, `claude_desktop_config.json`, so there is nothing
70
- to configure to try it.
75
+ `.cursor/mcp.json` and `~/.cursor/mcp.json`, `~/.claude.json`, `claude_desktop_config.json`,
76
+ Windsurf's `~/.codeium/windsurf/mcp_config.json` and Copilot's `~/.copilot/mcp-config.json`, so
77
+ there is nothing to configure to try it. `nulladrift logout <server>` deletes what `login`
78
+ stored.
71
79
 
72
80
  ## What lands in the lock
73
81
 
@@ -124,6 +132,14 @@ describes the new code. The same npm version arriving with different bytes is
124
132
  `server.artifact.substituted`, which has no innocent explanation. `--no-provenance` skips the
125
133
  registry lookups for an air-gapped run.
126
134
 
135
+ **What it leaves out: credentials, wherever a config puts them.** `env` and header values are
136
+ recorded by name only, and a URL loses its query string and `user:password`. A credential
137
+ written literally (`--api-key sk-...`, `-e GITHUB_TOKEN=ghp_...`, a connection string's password,
138
+ a key in a hosted server's URL path) is replaced with `REDACTED`, and `init`, `check` and `push`
139
+ say which server it was. Write it as `${VAR}` instead; the lock keeps the placeholder. If an
140
+ earlier `mcp.lock` was committed with the key in it, rotate the key: taking it out of the file
141
+ does not take it out of git history.
142
+
127
143
  Format and rationale: [docs/lockfile.md](docs/lockfile.md). JSON Schema:
128
144
  [schema/mcp.lock.schema.json](schema/mcp.lock.schema.json). Worked example:
129
145
  [examples/mcp.lock](examples/mcp.lock).
@@ -156,8 +172,10 @@ scanning, or any AppSec tool that reads SARIF, with no integration to write.
156
172
  The CLI alone needs no account and no network, and that stays true.
157
173
  - **Not a dependency scanner.** `npm audit` and OSV already cover the servers' own
158
174
  dependency trees. The capability layer is the part nothing else covers.
159
- - **Not a guarantee of behaviour.** It pins what a server *declares*. Postmark is the
160
- standing reminder that declaration and behaviour are different things.
175
+ - **Not a guarantee of behaviour.** It pins what a server *declares* and, for a stdio server,
176
+ which artifact runs. It does not read the code: a release that changes what a tool does shows
177
+ up as a different artifact, not as a description of the change. Postmark is the standing
178
+ reminder that declaration and behaviour are different things.
161
179
 
162
180
  ## The hosted control plane
163
181
 
@@ -238,8 +256,10 @@ the public registry is already there.
238
256
 
239
257
  Resources, resource templates, prompts and declared capabilities used to be on this list and are
240
258
  not any more: `mcplock` pins all of them and `mcpdrift` pins most. Running the other way, three
241
- of these tools can prove a reading came from somewhere, through signing or a transparency log,
242
- and this one cannot.
259
+ of these tools can prove a reading came from somewhere, through signing or a transparency log.
260
+ Since 0.6.0 this one can say which CI build sent a reading, on the provider's signature, but
261
+ nothing signs the reading's contents and there is no log. 0.6.0 also pins the artifact behind
262
+ each stdio server, which until then only MCPTrust did.
243
263
 
244
264
  [docs/comparison.md](docs/comparison.md) has the field-by-field matrix, how it was measured, and
245
265
  the cases where the alternatives are the better choice.
@@ -337,3 +357,13 @@ Requires Node 22+.
337
357
  ## Licence
338
358
 
339
359
  MIT. See [LICENSE](LICENSE).
360
+
361
+ **The licence covers the code, not the name.** "Nulladrift" and the pin mark identify this
362
+ project, and the MIT licence grants no rights to either. You are welcome to say a fork or a
363
+ product is based on Nulladrift, to write about it, and to link to it. Please do not name a fork, a
364
+ package or a hosted service "Nulladrift", or use the mark in a way that suggests it is this
365
+ project or that we endorse it. The mark, and how to use it when you write about the project, is
366
+ at [nulladrift.com/brand](https://nulladrift.com/brand).
367
+
368
+ Contributions come in under the same MIT licence, signed off under the Developer Certificate of
369
+ Origin; [CONTRIBUTING.md](CONTRIBUTING.md#sign-off-every-commit) says how.
package/dist/index.js CHANGED
@@ -190,6 +190,122 @@ function resealMcpServer(entry) {
190
190
  };
191
191
  }
192
192
 
193
+ // ../core/src/lock/credentials.ts
194
+ var REDACTED = "REDACTED";
195
+ var CREDENTIAL_NAME = /(?:^|[-_.])(?:api[-_]?key|apikey|access[-_]?key|secret(?:[-_]?key)?|client[-_]?secret|token|access[-_]?token|auth[-_]?token|refresh[-_]?token|bearer|password|passwd|pass|pwd|private[-_]?key|credentials?)$/i;
196
+ var ISSUER_FORMATS = [
197
+ /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
198
+ // AWS access key id
199
+ /\bgh[pousr]_[A-Za-z0-9]{36,}\b/g,
200
+ // GitHub
201
+ /\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
202
+ /\bglpat-[A-Za-z0-9_-]{20,}/g,
203
+ // GitLab
204
+ /\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
205
+ // Slack
206
+ /\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\b/g,
207
+ // Stripe
208
+ /\bsk-ant-[A-Za-z0-9_-]{20,}/g,
209
+ // Anthropic
210
+ /\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g,
211
+ // OpenAI
212
+ /\bAIza[0-9A-Za-z_-]{35}\b/g,
213
+ // Google API key
214
+ /\bnpm_[A-Za-z0-9]{36}\b/g,
215
+ /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
216
+ // JWT
217
+ ];
218
+ var PLACEHOLDER = /\$\{|^\$[A-Za-z_]/;
219
+ function looksRandom(value) {
220
+ if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;
221
+ if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;
222
+ const kind = (character) => /[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3;
223
+ let switches = 0;
224
+ for (let index = 1; index < value.length; index += 1) {
225
+ if (kind(value[index] ?? "") !== kind(value[index - 1] ?? "")) switches += 1;
226
+ }
227
+ return switches >= value.length / 3;
228
+ }
229
+ function decoded(value) {
230
+ try {
231
+ return decodeURIComponent(value);
232
+ } catch {
233
+ return value;
234
+ }
235
+ }
236
+ function isSecretValue(value) {
237
+ if (value === "" || value === REDACTED || PLACEHOLDER.test(value)) return false;
238
+ if (/^(?:[./~]|[A-Za-z]:\\|[a-z][a-z0-9+.-]*:\/\/)/i.test(value)) return false;
239
+ return true;
240
+ }
241
+ function redactFormats(value) {
242
+ let out = value;
243
+ for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);
244
+ return out;
245
+ }
246
+ function redactUrl(value) {
247
+ if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) return value;
248
+ let url;
249
+ try {
250
+ url = new URL(value);
251
+ } catch {
252
+ return value;
253
+ }
254
+ let changed = false;
255
+ if (url.password && !PLACEHOLDER.test(decoded(url.password))) {
256
+ url.password = REDACTED;
257
+ changed = true;
258
+ }
259
+ for (const [key, parameter] of [...url.searchParams]) {
260
+ if (CREDENTIAL_NAME.test(key) && isSecretValue(parameter)) {
261
+ url.searchParams.set(key, REDACTED);
262
+ changed = true;
263
+ }
264
+ }
265
+ return changed ? url.toString() : value;
266
+ }
267
+ function redactArgs(args) {
268
+ const out = [...args];
269
+ for (let index = 0; index < out.length; index += 1) {
270
+ const argument = out[index] ?? "";
271
+ const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);
272
+ if (assignment) {
273
+ const [, name = "", value = ""] = assignment;
274
+ if (CREDENTIAL_NAME.test(name.replace(/^-+/, "")) && isSecretValue(value)) {
275
+ out[index] = `${name}=${REDACTED}`;
276
+ continue;
277
+ }
278
+ if (!PLACEHOLDER.test(value)) out[index] = `${name}=${looksRandom(value) ? REDACTED : redactFormats(redactUrl(value))}`;
279
+ continue;
280
+ }
281
+ const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);
282
+ const next = out[index + 1];
283
+ if (flag && next !== void 0 && !next.startsWith("-") && CREDENTIAL_NAME.test(flag[1] ?? "") && isSecretValue(next)) {
284
+ out[index + 1] = REDACTED;
285
+ index += 1;
286
+ continue;
287
+ }
288
+ if (PLACEHOLDER.test(argument)) continue;
289
+ if (looksRandom(argument)) {
290
+ out[index] = REDACTED;
291
+ continue;
292
+ }
293
+ out[index] = redactFormats(redactUrl(argument));
294
+ }
295
+ return out;
296
+ }
297
+ function redactPath(pathname) {
298
+ return pathname.split("/").map((segment) => {
299
+ if (segment === "" || PLACEHOLDER.test(decoded(segment))) return segment;
300
+ if (looksRandom(segment)) return REDACTED;
301
+ return redactFormats(segment);
302
+ }).join("/");
303
+ }
304
+ function countRedacted(transport2) {
305
+ const occurrences = (text) => text.split(REDACTED).length - 1;
306
+ return (transport2.args ?? []).reduce((total, argument) => total + occurrences(argument), 0) + occurrences(transport2.url ?? "");
307
+ }
308
+
193
309
  // ../core/src/lock/jsonschema.ts
194
310
  var MAX_REF_DEPTH = 32;
195
311
  var MAX_VISIT_DEPTH = 12;
@@ -198,12 +314,12 @@ function asObject(value) {
198
314
  return value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value) ? value : void 0;
199
315
  }
200
316
  function decodeToken(token) {
201
- let decoded = token;
317
+ let decoded2 = token;
202
318
  try {
203
- decoded = decodeURIComponent(token);
319
+ decoded2 = decodeURIComponent(token);
204
320
  } catch {
205
321
  }
206
- return decoded.replace(/~1/g, "/").replace(/~0/g, "~");
322
+ return decoded2.replace(/~1/g, "/").replace(/~0/g, "~");
207
323
  }
208
324
  function resolvePointer(root, ref) {
209
325
  if (!ref.startsWith("#")) return void 0;
@@ -330,6 +446,7 @@ function sanitizeUrl(raw) {
330
446
  url.hash = "";
331
447
  url.username = "";
332
448
  url.password = "";
449
+ url.pathname = redactPath(url.pathname);
333
450
  return url.toString();
334
451
  } catch {
335
452
  return raw;
@@ -1065,10 +1182,10 @@ import { z } from "zod";
1065
1182
 
1066
1183
  // src/config/expand.ts
1067
1184
  import { homedir } from "os";
1068
- var PLACEHOLDER = /\$\{([^}]+)\}/g;
1185
+ var PLACEHOLDER2 = /\$\{([^}]+)\}/g;
1069
1186
  function expand(input, context) {
1070
1187
  const unresolved = [];
1071
- const value = input.replace(PLACEHOLDER, (match, body) => {
1188
+ const value = input.replace(PLACEHOLDER2, (match, body) => {
1072
1189
  if (body === "workspaceFolder") return context.workspaceFolder;
1073
1190
  if (body === "userHome") return homedir();
1074
1191
  if (body === "pathSeparator" || body === "/") return "/";
@@ -1165,7 +1282,11 @@ function resolveTransport(name, entry, context) {
1165
1282
  type: "stdio",
1166
1283
  command: take(entry.command),
1167
1284
  args: (entry.args ?? []).map((argument) => take(String(argument))),
1168
- asWritten: { command: String(entry.command), args: (entry.args ?? []).map((argument) => String(argument)) },
1285
+ asWritten: {
1286
+ command: String(entry.command),
1287
+ args: (entry.args ?? []).map((argument) => String(argument)),
1288
+ ...entry.cwd ? { cwd: String(entry.cwd) } : {}
1289
+ },
1169
1290
  env: Object.fromEntries(Object.entries(scalarsToStrings(entry.env)).map(([key, value]) => [key, take(value)])),
1170
1291
  cwd: entry.cwd ? take(entry.cwd) : void 0
1171
1292
  };
@@ -1393,13 +1514,13 @@ function lockTransport(server2) {
1393
1514
  const { transport: transport2 } = server2;
1394
1515
  if (transport2.type === "stdio") {
1395
1516
  const command = transport2.asWritten?.command ?? transport2.command;
1396
- const args = transport2.asWritten?.args ?? transport2.args;
1517
+ const args = redactArgs(transport2.asWritten?.args ?? transport2.args);
1397
1518
  return {
1398
1519
  type: "stdio",
1399
1520
  command,
1400
1521
  args: args.length > 0 ? args : void 0,
1401
1522
  envKeys: Object.keys(transport2.env).length > 0 ? Object.keys(transport2.env).sort() : void 0,
1402
- cwd: transport2.cwd
1523
+ cwd: transport2.asWritten ? transport2.asWritten.cwd : transport2.cwd
1403
1524
  };
1404
1525
  }
1405
1526
  const headerKeys = Object.keys(transport2.headers);
@@ -1505,7 +1626,7 @@ import { readFile as readFile3 } from "fs/promises";
1505
1626
  import { isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
1506
1627
 
1507
1628
  // src/lib/version.ts
1508
- var VERSION = "0.6.0";
1629
+ var VERSION = "0.6.1";
1509
1630
  var USER_AGENT = `nulladrift/${VERSION} (+https://github.com/Nulladrift/nulladrift)`;
1510
1631
 
1511
1632
  // src/lock/provenance.ts
@@ -2817,6 +2938,18 @@ function renderHumanReport(report) {
2817
2938
  `;
2818
2939
  }
2819
2940
 
2941
+ // src/report/redacted.ts
2942
+ function redactedLine(count) {
2943
+ const values = count === 1 ? "1 value that looks like a credential is" : `${count} values that look like credentials are`;
2944
+ return `${values} left out of the lock. Write each as \${VAR} instead, and rotate any an earlier mcp.lock committed.`;
2945
+ }
2946
+ function redactedNotes(lock) {
2947
+ return Object.entries(lock.subjects).flatMap(([name, entry]) => {
2948
+ const count = countRedacted(entry.transport);
2949
+ return count > 0 ? [`${name}: ${redactedLine(count)}`] : [];
2950
+ });
2951
+ }
2952
+
2820
2953
  // src/report/json.ts
2821
2954
  function renderJsonReport(report, exitCode) {
2822
2955
  return `${JSON.stringify(
@@ -3214,6 +3347,8 @@ async function buildReport(options) {
3214
3347
  previous: committed,
3215
3348
  provenance: options.provenance
3216
3349
  });
3350
+ for (const note of redactedNotes(result.lock)) process.stderr.write(`${yellow("note:")} ${note}
3351
+ `);
3217
3352
  const changes = diffLockfiles(committed, result.lock);
3218
3353
  const allowUnreachable = options.allowUnreachable || committed.policy?.allowUnreachable === true;
3219
3354
  const report = {
@@ -3435,6 +3570,8 @@ async function runInit(options) {
3435
3570
  lines.push(` ${green("\u2713")} ${bold(name)} ${dim(counts)}`);
3436
3571
  const deprecated = entry?.transport.type === "sse" ? " \xB7 HTTP+SSE transport is deprecated in the spec" : "";
3437
3572
  lines.push(` ${dim(`${entry?.protocol.era}/${entry?.protocol.version} \xB7 from ${entry?.source.file}${deprecated}`)}`);
3573
+ const redacted = entry ? countRedacted(entry.transport) : 0;
3574
+ if (redacted > 0) lines.push(` ${yellow(redactedLine(redacted))}`);
3438
3575
  const tools = entry?.tools ?? [];
3439
3576
  const capabilities = surfaceCapabilities(tools);
3440
3577
  if (capabilities.length > 0) {
@@ -3717,6 +3854,8 @@ async function runPush(options) {
3717
3854
  timeoutMs: options.timeoutMs,
3718
3855
  provenance: options.provenance
3719
3856
  });
3857
+ for (const note of redactedNotes(result.lock)) process.stderr.write(`${yellow("note:")} ${note}
3858
+ `);
3720
3859
  if (Object.keys(result.lock.subjects).length === 0 && result.unreachable.length === 0) {
3721
3860
  const looked = result.discovery.filesRead.length > 0 ? result.discovery.filesRead.join(", ") : "no client config files exist for this project";
3722
3861
  process.stderr.write(`No MCP servers found, so there is nothing to push.