MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / testTamperingDetection

Function testTamperingDetection

test/sign.e2e.test.ts:377–397  ·  view source on GitHub ↗

* Test tampering detection

()

Source from the content-addressed store, hash-verified

375 * Test tampering detection
376 */
377async function testTamperingDetection() {
378 // Create a copy and sign it
379 const testFile = path.join(TEST_DIR, "test-tampered.dxt");
380 fs.copyFileSync(TEST_MCPB, testFile);
381 signMcpbFile(testFile, SELF_SIGNED_CERT, SELF_SIGNED_KEY);
382
383 // Read the signed file
384 const signedContent = fs.readFileSync(testFile);
385
386 // Tamper with the content (change a byte in the ZIP portion)
387 const tamperedContent = Buffer.from(signedContent);
388 tamperedContent[10] = (tamperedContent[10] + 1) % 256;
389 fs.writeFileSync(testFile, tamperedContent);
390
391 // Try to verify - should fail
392 const result = await verifyMcpbFile(testFile);
393 expect(result.status).toBe("unsigned");
394
395 // Clean up
396 fs.unlinkSync(testFile);
397}
398
399/**
400 * Test unsigned file verification

Callers 1

sign.e2e.test.tsFile · 0.85

Calls 2

signMcpbFileFunction · 0.85
verifyMcpbFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…