샘플
safe-buffer 5.1.2
검증된 샘플 — npm safe-buffer 5.1.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Buffer.alloc allocates zero-filled buffer of requested size or…
sha256:a843debe1e0809f76992637a25306ee12b01ba1098dce6b6357faca4116a6c1f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-23 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
케이스
HOW- 목표
- verify pkg:npm/safe-buffer@5.1.2
- 환경
- node 22.23.2
- 생성일
- 2026-08-23T07:35:27Z
컨트랙트
- Buffer.alloc allocates zero-filled buffer of requested size or filled with specified value
- Buffer.from creates buffer from string with specified encoding
- Buffer.from creates buffer from array of byte values
- Buffer.from creates buffer copy from existing buffer or arrayBuffer slice
- Buffer.allocUnsafe allocates uninitialized buffer of requested size
- Buffer.concat joins multiple buffer instances into a single buffer
- Buffer.isBuffer correctly identifies buffer instances and rejects non-buffers
- Buffer.byteLength accurately measures string byte lengths for various encodings
- SlowBuffer creates un-pooled buffer instance of requested size
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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/safe-buffer@5.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/safe-buffer@5.1.2
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:95a762b237a9553587d2a2607c85fb36d47124f1b006483c0550041e2f04c37f","contract":["Buffer.alloc allocates zero-filled buffer of requested size or filled with specified value","Buffer.from creates buffer from string with specified encoding","Buffer.from creates buffer from array of byte values","Buffer.from creates buffer copy from existing buffer or arrayBuffer slice","Buffer.allocUnsafe allocates uninitialized buffer of requested size","Buffer.concat joins multiple buffer instances into a single buffer","Buffer.isBuffer correctly identifies buffer instances and rejects non-buffers","Buffer.byteLength accurately measures string byte lengths for various encodings","SlowBuffer creates un-pooled buffer instance of requested size"],"goal":"verify pkg:npm/safe-buffer@5.1.2","kind":"HOW","packages":["pkg:npm/safe-buffer@5.1.2"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/safe-buffer@5.1.2"],"schemaVersion":1,"subject":"pkg:npm/safe-buffer@5.1.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-safe-buffer",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-safe-buffer",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"safe-buffer": "5.1.2"
}
},
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
}
}
}
{
"name": "sample-safe-buffer",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for safe-buffer@5.1.2",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"safe-buffer": "5.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/safe-buffer@5.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/safe-buffer@5.1.2"
]
}
const { Buffer, SlowBuffer } = require('safe-buffer');
/**
* Creates a zero-filled or custom-filled Buffer of the specified size.
*
* @param {number} size - Number of bytes to allocate.
* @param {string|Buffer|number} [fill=0] - Value to pre-fill the buffer with.
* @param {string} [encoding='utf8'] - The encoding if fill is a string.
* @returns {Buffer} The allocated Buffer instance.
*/
function createAllocatedBuffer(size, fill, encoding) {
return Buffer.alloc(size, fill, encoding);
}
/**
* Creates a Buffer from a string, array, ArrayBuffer, or existing Buffer.
*
* @param {string|Array|ArrayBuffer|Buffer} value - The input value to copy into a Buffer.
* @param {string|number} [encodingOrOffset] - Encoding (if string) or offset (if ArrayBuffer).
* @param {number} [length] - Length (if ArrayBuffer).
* @returns {Buffer} The newly created Buffer instance.
*/
function createBufferFrom(value, encodingOrOffset, length) {
return Buffer.from(value, encodingOrOffset, length);
}
/**
* Creates an uninitialized Buffer of the specified size.
*
* @param {number} size - Number of bytes to allocate.
* @returns {Buffer} The allocated Buffer instance.
*/
function createUnsafeBuffer(size) {
return Buffer.allocUnsafe(size);
}
/**
* Concatenates a list of Buffer instances into a single Buffer.
*
* @param {Buffer[]} list - Array of Buffer instances to concatenate.
* @param {number} [totalLength] - Total length of the concatenated Buffer.
* @returns {Buffer} The concatenated Buffer.
*/
function concatBuffers(list, totalLength) {
return Buffer.concat(list, totalLength);
}
/**
* Checks whether an object is a Buffer.
*
* @param {*} value - The value to test.
* @returns {boolean} True if the value is a Buffer, false otherwise.
*/
function checkIsBuffer(value) {
return Buffer.isBuffer(value);
}
module.exports = {
Buffer,
SlowBuffer,
createAllocatedBuffer,
createBufferFrom,
createUnsafeBuffer,
concatBuffers,
checkIsBuffer
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
Buffer,
SlowBuffer,
createAllocatedBuffer,
createBufferFrom,
createUnsafeBuffer,
concatBuffers,
checkIsBuffer
} = require('../src/index.js');
async function testAll() {
// 1. Buffer.alloc allocates zero-filled buffer of requested size or filled with specified value
const zeroBuf = createAllocatedBuffer(5);
assert.equal(zeroBuf.length, 5, 'Buffer.alloc length must equal requested size');
assert.deepEqual(Array.from(zeroBuf), [0, 0, 0, 0, 0], 'Buffer.alloc default fill must be 0');
const filledBuf = createAllocatedBuffer(4, 0xa5);
assert.equal(filledBuf.length, 4);
assert.deepEqual(Array.from(filledBuf), [0xa5, 0xa5, 0xa5, 0xa5], 'Buffer.alloc must fill with specified byte');
const stringFilledBuf = createAllocatedBuffer(6, 'ab', 'utf8');
assert.equal(stringFilledBuf.toString('utf8'), 'ababab', 'Buffer.alloc must fill with repeated pattern');
// 2. Buffer.from creates buffer from string with specified encoding
const utf8Buf = createBufferFrom('hello world', 'utf8');
assert.equal(utf8Buf.toString('utf8'), 'hello world');
assert.equal(utf8Buf.length, 11);
const hexBuf = createBufferFrom('deadbeef', 'hex');
assert.equal(hexBuf.length, 4);
assert.deepEqual(Array.from(hexBuf), [0xde, 0xad, 0xbe, 0xef]);
const base64Buf = createBufferFrom('aGVsbG8=', 'base64');
assert.equal(base64Buf.toString('utf8'), 'hello');
// 3. Buffer.from creates buffer from array of byte values
const arrayBuf = createBufferFrom([10, 20, 30, 40]);
assert.equal(arrayBuf.length, 4);
assert.equal(arrayBuf[0], 10);
assert.equal(arrayBuf[3], 40);
// 4. Buffer.from creates buffer copy from existing buffer or arrayBuffer slice
const sourceBuf = createBufferFrom('original');
const copyBuf = createBufferFrom(sourceBuf);
assert.equal(copyBuf.toString(), 'original');
copyBuf[0] = 0x58; // 'X'
assert.equal(sourceBuf.toString(), 'original', 'copied buffer modification must not mutate source');
const ab = new ArrayBuffer(8);
const u8View = new Uint8Array(ab);
u8View.set([1, 2, 3, 4, 5, 6, 7, 8]);
const slicedFromAb = createBufferFrom(ab, 2, 4);
assert.equal(slicedFromAb.length, 4);
assert.deepEqual(Array.from(slicedFromAb), [3, 4, 5, 6]);
// 5. Buffer.allocUnsafe allocates uninitialized buffer of requested size
const unsafeBuf = createUnsafeBuffer(16);
assert.equal(unsafeBuf.length, 16);
assert.ok(checkIsBuffer(unsafeBuf));
// 6. Buffer.concat joins multiple buffer instances into a single buffer
const b1 = createBufferFrom('part1-');
const b2 = createBufferFrom('part2');
const merged = concatBuffers([b1, b2]);
assert.equal(merged.toString('utf8'), 'part1-part2');
assert.equal(merged.length, 11);
const truncatedConcat = concatBuffers([b1, b2], 5);
assert.equal(truncatedConcat.length, 5);
assert.equal(truncatedConcat.toString('utf8'), 'part1');
// 7. Buffer.isBuffer correctly identifies buffer instances and rejects non-buffers
assert.equal(checkIsBuffer(createAllocatedBuffer(1)), true);
assert.equal(checkIsBuffer(createBufferFrom('abc')), true);
assert.equal(checkIsBuffer(new Uint8Array(4)), false);
assert.equal(checkIsBuffer('string'), false);
assert.equal(checkIsBuffer({}), false);
assert.equal(checkIsBuffer(null), false);
assert.equal(checkIsBuffer(undefined), false);
// 8. Buffer.byteLength accurately measures string byte lengths for various encodings
assert.equal(Buffer.byteLength('hello', 'utf8'), 5);
assert.equal(Buffer.byteLength('안녕하세요', 'utf8'), 15);
assert.equal(Buffer.byteLength('deadbeef', 'hex'), 4);
assert.equal(Buffer.byteLength('aGVsbG8=', 'base64'), 5);
// 9. SlowBuffer creates un-pooled buffer instance of requested size
const slow = new SlowBuffer(8);
assert.equal(slow.length, 8);
assert.ok(checkIsBuffer(slow));
console.log('All safe-buffer contract tests passed successfully.');
}
testAll().catch((err) => {
console.error('Contract test failure:', err);
process.exit(1);
});
오리진 시더
익명