MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / validateExactTarMemberListing

Function validateExactTarMemberListing

pkg/npm/install.js:108–127  ·  view source on GitHub ↗
(listing, expectedNames)

Source from the content-addressed store, hash-verified

106}
107
108function validateExactTarMemberListing(listing, expectedNames) {
109 if (listing.includes('\0')) {
110 throw new Error('tar member listing contains a NUL byte');
111 }
112 const members = listing.split(/\r?\n/);
113 if (members[members.length - 1] === '') members.pop();
114 const expected = new Set(expectedNames);
115 const seen = new Set();
116 for (const member of members) {
117 if (!member || !expected.has(member) || seen.has(member)) {
118 throw new Error(`archive contains an unexpected or duplicate root member: ${JSON.stringify(member)}`);
119 }
120 seen.add(member);
121 }
122 if (members.length !== expectedNames.length || seen.size !== expected.size) {
123 throw new Error(
124 `archive must contain exactly these root files: ${expectedNames.join(', ')}`,
125 );
126 }
127}
128
129function requireRegularArchive(archivePath) {
130 if (!fs.statSync(archivePath).isFile()) {

Callers 2

extractExactTarArchiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected