Ejemplo
walker 1.0.8: verify directory traversal with filterDir and event listeners
Muestra verificada para npm walker 1.0.8: verify directory traversal with filterDir and event listeners. El contrato se ejecutó en node 22 · linux alpine/x64…
sha256:90d77c204b79b342d4f4e44b3116bb38bb963ac15709907f51ec854c49653d85
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-28 |
Caso
HOW- Objetivo
- verify pkg:npm/walker@1.0.8 directory traversal with filterDir and event listeners
- Paquetes
- Símbolos
-
- Walker
- Walker.filterDir
- Walker.on
- Creado
- 2026-08-28T08:56:31Z
Contrato
- Walker is exported as a function constructor from walker
- Walker recursively traverses directory hierarchy emitting entry, dir, and file events with fs.Stats
- Walker.filterDir returns false to prune matching subdirectories and prevent traversal into their child nodes
- Walker emits end event when all asynchronous file system traversal tasks have finished
- Walker emits error event when attempting to traverse a non-existent path
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código fuente
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/walker@1.0.8 directory traversal with filterDir and event listeners
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/walker@1.0.8
Demonstrate these symbols/APIs:
- Walker
- Walker.filterDir
- Walker.on
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:ad111b88d038723f5e763ca8127e306798411cf6fd2ffe08c431949d466f550c","contract":["Walker is exported as a function constructor from walker","Walker recursively traverses directory hierarchy emitting entry, dir, and file events with fs.Stats","Walker.filterDir returns false to prune matching subdirectories and prevent traversal into their child nodes","Walker emits end event when all asynchronous file system traversal tasks have finished","Walker emits error event when attempting to traverse a non-existent path"],"goal":"verify pkg:npm/walker@1.0.8 directory traversal with filterDir and event listeners","kind":"HOW","packages":["pkg:npm/walker@1.0.8"],"schemaVersion":1,"symbols":["Walker","Walker.filterDir","Walker.on"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/walker@1.0.8"],"schemaVersion":1,"subject":"pkg:npm/walker@1.0.8","symbols":["Walker","Walker.filterDir","Walker.on"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-walker-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-walker-verification",
"version": "1.0.0",
"dependencies": {
"walker": "1.0.8"
}
},
"node_modules/makeerror": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz",
"integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==",
"license": "BSD-3-Clause",
"dependencies": {
"tmpl": "1.0.5"
}
},
"node_modules/tmpl": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
"integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==",
"license": "BSD-3-Clause"
},
"node_modules/walker": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz",
"integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==",
"license": "Apache-2.0",
"dependencies": {
"makeerror": "1.0.12"
}
}
}
}
{
"name": "sample-walker-verification",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"walker": "1.0.8"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/walker@1.0.8 directory traversal with filterDir and event listeners",
"kind": "HOW",
"packages": [
"pkg:npm/walker@1.0.8"
],
"symbols": [
"Walker",
"Walker.filterDir",
"Walker.on"
]
}
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import path from 'node:path';
import os from 'node:os';
import Walker from 'walker';
async function main() {
// Test 1: Walker export
assert.equal(typeof Walker, 'function', 'Walker should be exported as a function/constructor');
const tmpBase = await fs.mkdtemp(path.join(os.tmpdir(), 'walker-test-'));
try {
const dirA = path.join(tmpBase, 'dirA');
const dirB = path.join(dirA, 'dirB');
await fs.mkdir(dirB, { recursive: true });
const file1 = path.join(tmpBase, 'file1.txt');
const file2 = path.join(dirA, 'file2.txt');
const file3 = path.join(dirB, 'file3.txt');
await fs.writeFile(file1, 'hello 1', 'utf8');
await fs.writeFile(file2, 'hello 2', 'utf8');
await fs.writeFile(file3, 'hello 3', 'utf8');
// Test 2: Full directory traversal with events
const entries = [];
const dirs = [];
const files = [];
await new Promise((resolve, reject) => {
Walker(tmpBase)
.on('entry', (entry, stat) => {
assert(stat && typeof stat.isFile === 'function', 'entry stat must be an fs.Stats instance');
entries.push(entry);
})
.on('dir', (dir, stat) => {
assert(stat && stat.isDirectory(), 'dir stat must be a directory');
dirs.push(dir);
})
.on('file', (file, stat) => {
assert(stat && stat.isFile(), 'file stat must be a file');
files.push(file);
})
.on('error', (err) => {
reject(err);
})
.on('end', () => {
resolve();
});
});
assert.equal(dirs.length, 3, 'Should traverse 3 directories (root, dirA, dirB)');
assert(dirs.includes(tmpBase), 'dirs should include root');
assert(dirs.includes(dirA), 'dirs should include dirA');
assert(dirs.includes(dirB), 'dirs should include dirB');
assert.equal(files.length, 3, 'Should traverse 3 files');
assert(files.includes(file1), 'files should include file1');
assert(files.includes(file2), 'files should include file2');
assert(files.includes(file3), 'files should include file3');
assert.equal(entries.length, 6, 'Should emit 6 entry events in total (3 dirs + 3 files)');
// Test 3: filterDir functionality
const filteredEntries = [];
const filteredDirs = [];
const filteredFiles = [];
await new Promise((resolve, reject) => {
Walker(tmpBase)
.filterDir((dir, stat) => {
assert(stat && stat.isDirectory(), 'filterDir callback receives fs.Stats');
if (dir === dirB) {
return false;
}
return true;
})
.on('entry', (entry) => {
filteredEntries.push(entry);
})
.on('dir', (dir) => {
filteredDirs.push(dir);
})
.on('file', (file) => {
filteredFiles.push(file);
})
.on('error', (err) => {
reject(err);
})
.on('end', () => {
resolve();
});
});
assert(filteredDirs.includes(tmpBase), 'filteredDirs should include root');
assert(filteredDirs.includes(dirA), 'filteredDirs should include dirA');
assert(!filteredDirs.includes(dirB), 'filteredDirs should NOT include pruned dirB');
assert(filteredFiles.includes(file1), 'filteredFiles should include file1');
assert(filteredFiles.includes(file2), 'filteredFiles should include file2');
assert(!filteredFiles.includes(file3), 'filteredFiles should NOT include file3 inside pruned dirB');
assert.equal(filteredEntries.length, 4, 'Should emit 4 entries when dirB is pruned');
// Test 4: Error handling for non-existent path
const nonExistentPath = path.join(tmpBase, 'non_existent_directory_12345');
let errorEmitted = false;
let endAfterError = false;
await new Promise((resolve) => {
Walker(nonExistentPath)
.on('error', (err, entry) => {
assert(err instanceof Error, 'err should be an Error');
assert.equal(err.code, 'ENOENT', 'err code should be ENOENT');
assert.equal(entry, nonExistentPath, 'error entry should match the queried path');
errorEmitted = true;
})
.on('end', () => {
endAfterError = true;
resolve();
});
});
assert.equal(errorEmitted, true, 'error event must be emitted for missing directory');
assert.equal(endAfterError, true, 'end event must be emitted even after error');
console.log('All contract tests passed.');
} finally {
await fs.rm(tmpBase, { recursive: true, force: true });
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Seeder de origen
anónimo