Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified dist/diff.js
Binary file not shown.
Binary file modified src/diff.ts
Binary file not shown.
35 changes: 35 additions & 0 deletions test/heuristics.test.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -340,6 +340,41 @@
assert.equal(delta.resolvedFindings, undefined);
});

test('diffReports: same kind/subject/file and severity but different message is surfaced as [CHANGED]', () => {
// A medium finding mutated into a *different* medium at the same
// place. The (kind, subject, file) key matches, so without a content
// check this would be dropped as pre-existing.
const base = makeReport([makeFinding({ message: 'github launches npx server-github.' })]);
const head = makeReport([makeFinding({ message: 'github launches npx server-evil.' })]);

const delta = diffReports(base, head);
assert.equal(delta.findingCount, 1);
assert.equal(delta.findings[0].severity, 'medium');
assert.match(delta.findings[0].message, /^\[CHANGED\]/);
assert.match(delta.findings[0].message, /server-evil/);
});

test('diffReports: same severity with a changed signature is surfaced as [CHANGED]', () => {
// When reports carry signatures (the audit path always signs), the
// content identity comes from the signature rather than the message.
const base = makeReport([makeFinding({ signature: 'aaaaaaaaaaaaaaaa' })]);
const head = makeReport([makeFinding({ signature: 'bbbbbbbbbbbbbbbb' })]);

const delta = diffReports(base, head);
assert.equal(delta.findingCount, 1);
assert.match(delta.findings[0].message, /^\[CHANGED\]/);
});

test('diffReports: same severity and identical signature stays out of the delta', () => {
// Identical signatures mean the violation is unchanged even if some
// unrelated report field differs — it is pre-existing, not a regression.
const base = makeReport([makeFinding({ signature: 'cafef00dcafef00d', message: 'phrasing A' })]);
const head = makeReport([makeFinding({ signature: 'cafef00dcafef00d', message: 'phrasing B' })]);

const delta = diffReports(base, head);
assert.equal(delta.findingCount, 0);
});

test('makeMeshContext: indexes servers by name across surfaces in a single pass', () => {
const policies = {
mcpSurfaces: [
Expand Down