mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-13 09:53:15 +08:00
Externalizing the integration templates (#1492/#1493) and the UI bundle
(#1501/#1503) was done to reduce the Microsoft `Wacatac.B!ml` surface. It did
not work: across dry runs the flagged artifact count stayed at ~3 and the
detections merely moved between artifacts.
Dissection of run 31286803592 shows there is no structural cause to fix. The
verdicts split across every axis at once — linux-amd64 (dynamic) flagged while
linux-amd64-portable (static) is clean, but linux-arm64 (dynamic) clean while
linux-arm64-portable (static) is flagged. The two macOS binaries have identical
segment structure and split clean/flagged. Siblings from one build landed in
different variant buckets (.B vs .C). Entropy is low everywhere
(code_vectors.bin 4.166, grammar tables 3.464 bits/byte, against 7.5-8.0 for
packed payloads), so the packed-payload hypothesis is excluded too.
So the complexity bought nothing, and installation goes back to being
self-contained: one binary that carries its own UI and agent integration
templates, with no adjacent data file that has to resolve before `install`
works. Only the UI-capable composition ships from now on, under the historical
unsuffixed archive name.
Removed: src/ui/asset_pack.{c,h}, asset_pack_stub.c, asset_manifest_stub.c,
scripts/pack-ui-assets.mjs, src/cli/integration_assets.{c,h},
assets/cbm-integrations.json, scripts/gen-integrations-hash.sh, the
--verify-runtime-assets probe (nothing adjacent left to verify), and the
composition gates A6/A7 whose property is now deliberately inverted.
Restored: scripts/embed-frontend.sh, src/ui/embedded_{assets.h,stub.c}, the
compiled-in hook/adapter template bodies, and the embed/EMBED_OBJS build path.
Kept from the reverted commits, re-applied by hand where a wholesale file
restore would have dropped them:
- cbm_module_path_utf8() in both self-path sites. GetModuleFileNameA renders
through the ANSI code page and mangles non-ASCII install paths.
- the /__cbm/ui-readiness HMAC proof, secure_random and cbm_hmac_sha256, so
`daemon start --open` still waits for a genuine CBM listener.
- X-Content-Type-Options: nosniff on served assets.
- the MinGW noexecstack gate, -lbcrypt, and the cppcheck/zip CI fixes.
Archives are now codebase-memory-mcp-<os>-<arch>[-portable] with exactly four
members (binary, LICENSE, installer, THIRD_PARTY_NOTICES.md). That restores the
names every static package manifest already points at — aur, chocolatey,
homebrew, scoop, winget and glama were all broken by the -ui- rename.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
118 lines
3.4 KiB
JavaScript
118 lines
3.4 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const {
|
|
UNIX_ARCHIVE_NAMES,
|
|
WINDOWS_BINARY_NAME,
|
|
extractExactTarArchive,
|
|
installWindowsBinaryAtomically,
|
|
validateExactTarMemberListing,
|
|
} = require('../install.js');
|
|
|
|
function exactUnixListing(extra = []) {
|
|
return [...UNIX_ARCHIVE_NAMES, ...extra].join('\n') + '\n';
|
|
}
|
|
|
|
test('Unix archive validation rejects traversal and unexpected members', () => {
|
|
assert.throws(
|
|
() => validateExactTarMemberListing(
|
|
exactUnixListing(['../../.ssh/authorized_keys']), UNIX_ARCHIVE_NAMES,
|
|
),
|
|
/unexpected or duplicate/,
|
|
);
|
|
assert.throws(
|
|
() => validateExactTarMemberListing(
|
|
exactUnixListing(['unexpected-root-file']), UNIX_ARCHIVE_NAMES,
|
|
),
|
|
/unexpected or duplicate/,
|
|
);
|
|
});
|
|
|
|
test('Unix extraction requests only the validated root executable', () => {
|
|
const calls = [];
|
|
const runner = (command, args) => {
|
|
calls.push({ command, args: [...args] });
|
|
return calls.length === 1 ? exactUnixListing() : Buffer.alloc(0);
|
|
};
|
|
|
|
extractExactTarArchive(
|
|
'/tmp/release.tar.gz', '/tmp/extract', UNIX_ARCHIVE_NAMES,
|
|
'codebase-memory-mcp', runner,
|
|
);
|
|
|
|
assert.deepEqual(calls[0].args, ['-tzf', '/tmp/release.tar.gz']);
|
|
assert.deepEqual(
|
|
calls[1].args,
|
|
['-xzf', '/tmp/release.tar.gz', '-C', '/tmp/extract', 'codebase-memory-mcp'],
|
|
);
|
|
});
|
|
|
|
function writeBinary(directory, tag) {
|
|
fs.mkdirSync(directory, { recursive: true });
|
|
fs.writeFileSync(path.join(directory, WINDOWS_BINARY_NAME), `binary:${tag}`);
|
|
}
|
|
|
|
function fakeBinaryVerifier(binaryPath) {
|
|
const binary = fs.readFileSync(binaryPath, 'utf8');
|
|
if (!/^binary:(.+)$/.test(binary)) {
|
|
throw new Error('cached Windows binary failed verification');
|
|
}
|
|
}
|
|
|
|
function withBinaryDirectories(callback) {
|
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cbm-npm-binary-test-'));
|
|
const source = path.join(root, 'source');
|
|
const destination = path.join(root, 'destination');
|
|
fs.mkdirSync(destination);
|
|
try {
|
|
callback({ source, destination });
|
|
} finally {
|
|
fs.rmSync(root, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
function assertBinary(directory, tag) {
|
|
assert.equal(
|
|
fs.readFileSync(path.join(directory, WINDOWS_BINARY_NAME), 'utf8'),
|
|
`binary:${tag}`,
|
|
);
|
|
}
|
|
|
|
test('Windows publication repairs a corrupt cached binary', () => {
|
|
withBinaryDirectories(({ source, destination }) => {
|
|
writeBinary(source, 'candidate');
|
|
writeBinary(destination, 'old');
|
|
fs.writeFileSync(path.join(destination, WINDOWS_BINARY_NAME), 'corrupt');
|
|
|
|
installWindowsBinaryAtomically(source, destination, fakeBinaryVerifier);
|
|
|
|
assertBinary(destination, 'candidate');
|
|
});
|
|
});
|
|
|
|
test('Windows publication installs into an empty cache', () => {
|
|
withBinaryDirectories(({ source, destination }) => {
|
|
writeBinary(source, 'candidate');
|
|
|
|
installWindowsBinaryAtomically(source, destination, fakeBinaryVerifier);
|
|
|
|
assertBinary(destination, 'candidate');
|
|
});
|
|
});
|
|
|
|
test('Windows publication preserves a valid concurrent winner', () => {
|
|
withBinaryDirectories(({ source, destination }) => {
|
|
writeBinary(source, 'loser');
|
|
writeBinary(destination, 'winner');
|
|
|
|
installWindowsBinaryAtomically(source, destination, fakeBinaryVerifier);
|
|
|
|
assertBinary(destination, 'winner');
|
|
});
|
|
});
|