샘플
walker 1.0.8: verify directory traversal with filterDir and event listeners
검증된 샘플 — npm walker 1.0.8: verify directory traversal with filterDir and event listeners. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:90d77c204b79b342d4f4e44b3116bb38bb963ac15709907f51ec854c49653d85
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/walker@1.0.8 directory traversal with filterDir and event listeners
- 패키지
- 심벌
-
- Walker
- Walker.filterDir
- Walker.on
- 생성일
- 2026-08-28T08:56:31Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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);
});
오리진 시더
익명