샘플
js-yaml 3.15.1: safeLoad
검증된 샘플 — npm js-yaml 3.15.1: safeLoad. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert yaml.safeLoad parses key-value mappings into…
sha256:82519a2442ff929ee10c2b7d75009ece5f95eaab5fda04a2a6b428c6690a0296
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 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-30 |
케이스
HOW- 목표
- verify js-yaml.safeLoad in pkg:npm/js-yaml@3.15.1
- 패키지
- 심벌
-
- js-yaml.safeLoad
- 환경
- node 22.23.2
- 생성일
- 2026-08-30T17:13:36Z
컨트랙트
- assert yaml.safeLoad parses key-value mappings into javascript objects
- assert yaml.safeLoad parses scalar integers, floats, booleans, and null literals
- assert yaml.safeLoad parses nested structures, mappings, and sequences into arrays and objects
- assert yaml.safeLoad parses sequences into javascript arrays
- assert yaml.safeLoad parses folded and literal multiline block scalars
- assert yaml.safeLoad returns undefined for empty string and null for comment-only content
- assert yaml.safeLoad parses content using custom schemas such as JSON_SCHEMA
- assert yaml.safeLoad throws YAMLException on invalid YAML syntax
- assert yaml.safeLoad throws YAMLException and rejects unsafe JavaScript function constructors
파일
- PROMPT.md
- csx.json
- index.js
- 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 js-yaml.safeLoad in pkg:npm/js-yaml@3.15.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/js-yaml@3.15.1
Demonstrate these symbols/APIs:
- js-yaml.safeLoad
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.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:246ab6803ab9e6a555c1cf13989cba63db87976c4955e3a34dbe144ff1c31d8a","constraints":{"executionContext":"node"},"contract":["assert yaml.safeLoad parses key-value mappings into javascript objects","assert yaml.safeLoad parses scalar integers, floats, booleans, and null literals","assert yaml.safeLoad parses nested structures, mappings, and sequences into arrays and objects","assert yaml.safeLoad parses sequences into javascript arrays","assert yaml.safeLoad parses folded and literal multiline block scalars","assert yaml.safeLoad returns undefined for empty string and null for comment-only content","assert yaml.safeLoad parses content using custom schemas such as JSON_SCHEMA","assert yaml.safeLoad throws YAMLException on invalid YAML syntax","assert yaml.safeLoad throws YAMLException and rejects unsafe JavaScript function constructors"],"goal":"verify js-yaml.safeLoad in pkg:npm/js-yaml@3.15.1","kind":"HOW","packages":["pkg:npm/js-yaml@3.15.1"],"schemaVersion":1,"symbols":["js-yaml.safeLoad"]},"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/js-yaml@3.15.1"],"schemaVersion":1,"subject":"pkg:npm/js-yaml@3.15.1","symbols":["js-yaml.safeLoad"],"verifierAdapter":"node-typescript@1"}
const yaml = require('js-yaml');
function parseYaml(content, options) {
return yaml.safeLoad(content, options);
}
function parseYamlScalar(content) {
return yaml.safeLoad(content);
}
function parseYamlMapping(content) {
return yaml.safeLoad(content);
}
function parseYamlSequence(content) {
return yaml.safeLoad(content);
}
function parseYamlWithSchema(content, schema) {
return yaml.safeLoad(content, { schema });
}
module.exports = {
safeLoad: yaml.safeLoad,
YAMLException: yaml.YAMLException,
CORE_SCHEMA: yaml.CORE_SCHEMA,
JSON_SCHEMA: yaml.JSON_SCHEMA,
parseYaml,
parseYamlScalar,
parseYamlMapping,
parseYamlSequence,
parseYamlWithSchema,
};
{
"name": "sample-js-yaml",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-js-yaml",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"js-yaml": "3.15.1"
}
},
"node_modules/argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"license": "BSD-2-Clause",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/js-yaml": {
"version": "3.15.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.15.1.tgz",
"integrity": "sha512-S99WuO3HlhO3XN41EtYUNl9zzXjoJx7QvmipxsJVxtCBT0YHEFy+iOJhjSvrmV12nYhWpZaM8lPHkJm0yUMbag==",
"license": "MIT",
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-js-yaml",
"version": "1.0.0",
"description": "Minimal clean-room sample verifying js-yaml.safeLoad in js-yaml",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"js-yaml": "3.15.1"
}
}
{
"schemaVersion": 1,
"goal": "verify js-yaml.safeLoad in pkg:npm/js-yaml@3.15.1",
"kind": "HOW",
"packages": [
"pkg:npm/js-yaml@3.15.1"
],
"symbols": [
"js-yaml.safeLoad"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import indexPkg from '../index.js';
const {
safeLoad,
YAMLException,
CORE_SCHEMA,
JSON_SCHEMA,
parseYaml,
parseYamlScalar,
parseYamlMapping,
parseYamlSequence,
parseYamlWithSchema,
} = indexPkg;
// 1. Basic key-value mapping
const mappingYaml = 'name: CodeSampleX\nversion: 1.0.0\nenabled: true';
const mappingResult = parseYamlMapping(mappingYaml);
assert.deepStrictEqual(
mappingResult,
{ name: 'CodeSampleX', version: '1.0.0', enabled: true },
'yaml.safeLoad must parse key-value mappings into javascript objects'
);
// 2. Scalar types (integers, floats, booleans, null)
const intVal = parseYamlScalar('12345');
assert.strictEqual(intVal, 12345, 'yaml.safeLoad must parse integers');
const floatVal = parseYamlScalar('3.14159');
assert.strictEqual(floatVal, 3.14159, 'yaml.safeLoad must parse floats');
const boolTrue = parseYamlScalar('true');
assert.strictEqual(boolTrue, true, 'yaml.safeLoad must parse boolean true');
const boolFalse = parseYamlScalar('false');
assert.strictEqual(boolFalse, false, 'yaml.safeLoad must parse boolean false');
const nullVal = parseYamlScalar('null');
assert.strictEqual(nullVal, null, 'yaml.safeLoad must parse null literals');
// 3. Nested objects and sequences
const nestedYaml = `
project:
title: Test Suite
tags:
- parser
- yaml
- node
config:
retries: 3
`;
const nestedResult = parseYaml(nestedYaml);
assert.deepStrictEqual(
nestedResult,
{
project: {
title: 'Test Suite',
tags: ['parser', 'yaml', 'node'],
config: {
retries: 3,
},
},
},
'yaml.safeLoad must parse nested structures and sequences'
);
// 4. Sequence parsing
const sequenceYaml = `
- apple
- banana
- cherry
`;
const sequenceResult = parseYamlSequence(sequenceYaml);
assert.deepStrictEqual(
sequenceResult,
['apple', 'banana', 'cherry'],
'yaml.safeLoad must parse lists into javascript arrays'
);
// 5. Multiline strings and folded block scalars
const blockYaml = `
description: >
This is a long line
that folds into a single
paragraph.
literal: |
Line 1
Line 2
`;
const blockResult = parseYaml(blockYaml);
assert.strictEqual(
blockResult.description,
'This is a long line that folds into a single paragraph.\n',
'yaml.safeLoad must parse folded multiline strings'
);
assert.strictEqual(
blockResult.literal,
'Line 1\nLine 2\n',
'yaml.safeLoad must parse literal block multiline strings'
);
// 6. Empty string returns undefined and comment-only string returns null
const emptyResult = parseYaml('');
assert.strictEqual(emptyResult, undefined, 'yaml.safeLoad must return undefined for empty string');
const commentResult = parseYaml('# Only comments\n# nothing else\n');
assert.strictEqual(commentResult, null, 'yaml.safeLoad must return null for comment-only content');
// 7. Schema options (e.g. JSON_SCHEMA)
const jsonSchemaYaml = 'key: "value"';
const jsonSchemaResult = parseYamlWithSchema(jsonSchemaYaml, JSON_SCHEMA);
assert.deepStrictEqual(
jsonSchemaResult,
{ key: 'value' },
'yaml.safeLoad must parse content with JSON_SCHEMA'
);
// 8. Syntax error throws YAMLException
assert.throws(
() => {
safeLoad('invalid: [unclosed list');
},
(err) => {
return err instanceof YAMLException || (err && err.name === 'YAMLException');
},
'yaml.safeLoad must throw YAMLException on invalid syntax'
);
// 9. Unsafe JavaScript functions are rejected by safeLoad
assert.throws(
() => {
safeLoad('fn: !!js/function "function () { return 42; }"');
},
(err) => {
return err instanceof YAMLException || (err && err.name === 'YAMLException');
},
'yaml.safeLoad must reject unsafe function constructors'
);
console.log('All js-yaml.safeLoad contract assertions passed.');
오리진 시더
익명