CodeSampleX

샘플

plist 3.1.1

검증된 샘플 — npm plist 3.1.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: plist.build serializes JavaScript primitives, objects, and arrays into…

sha256:8cfd91961f0a15a922a266168d4d287dddba2b279522b4c7ae6078940636e4a2

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-27

케이스

HOW
목표
verify pkg:npm/plist@3.1.1
패키지
환경
node 22.23.2
생성일
2026-08-27T16:57:22Z

컨트랙트

  1. plist.build serializes JavaScript primitives, objects, and arrays into valid XML plist format
  2. plist.parse parses XML plist strings containing strings, integers, reals, dates, buffers, and booleans
  3. plist.build and plist.parse preserve nested data structures across round-trip serialization
  4. plist.build properly escapes special XML characters in dictionary keys and string values
  5. plist.parse throws an error when given invalid or malformed XML without a plist root element
  6. plist.parse ignores __proto__ keys to prevent prototype pollution vulnerabilities

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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/plist@3.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/plist@3.1.1

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.
csx.json
{"case":{"caseId":"case:sha256:7263e5465b9dd5dd30895e83231eb74b5e0ce443759b5bd3e6c273e866c2952c","contract":["plist.build serializes JavaScript primitives, objects, and arrays into valid XML plist format","plist.parse parses XML plist strings containing strings, integers, reals, dates, buffers, and booleans","plist.build and plist.parse preserve nested data structures across round-trip serialization","plist.build properly escapes special XML characters in dictionary keys and string values","plist.parse throws an error when given invalid or malformed XML without a plist root element","plist.parse ignores __proto__ keys to prevent prototype pollution vulnerabilities"],"goal":"verify pkg:npm/plist@3.1.1","kind":"HOW","packages":["pkg:npm/plist@3.1.1"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/plist@3.1.1"],"schemaVersion":1,"subject":"pkg:npm/plist@3.1.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-plist-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-plist-verify",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "plist": "3.1.1"
      }
    },
    "node_modules/@xmldom/xmldom": {
      "version": "0.9.12",
      "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.12.tgz",
      "integrity": "sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==",
      "license": "MIT",
      "engines": {
        "node": ">=14.6"
      }
    },
    "node_modules/base64-js": {
      "version": "1.5.1",
      "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
      "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/feross"
        },
        {
          "type": "patreon",
          "url": "https://www.patreon.com/feross"
        },
        {
          "type": "consulting",
          "url": "https://feross.org/support"
        }
      ],
      "license": "MIT"
    },
    "node_modules/plist": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.1.tgz",
      "integrity": "sha512-ZIfcLJC+7E7FBFnDxm9MPmt7D+DidyQ26lewieO75AdhA2ayMtsJSES0iWzqJQbcVRSrTufQoy0DR94xHue0oA==",
      "license": "MIT",
      "dependencies": {
        "@xmldom/xmldom": "^0.9.10",
        "base64-js": "^1.5.1",
        "xmlbuilder": "^15.1.1"
      },
      "engines": {
        "node": ">=10.4.0"
      }
    },
    "node_modules/xmlbuilder": {
      "version": "15.1.1",
      "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz",
      "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==",
      "license": "MIT",
      "engines": {
        "node": ">=8.0"
      }
    }
  }
}
package.json
{
  "name": "sample-plist-verify",
  "version": "1.0.0",
  "description": "verify pkg:npm/plist@3.1.1",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "plist": "3.1.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/plist@3.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/plist@3.1.1"
  ]
}
src/index.js
const plist = require('plist');

/**
 * Builds an XML Property List string from JavaScript data.
 *
 * @param {*} data - JavaScript data structure to serialize.
 * @param {object} [options] - Optional formatting options.
 * @returns {string} The formatted XML Property List document string.
 */
function buildPlist(data, options) {
  return plist.build(data, options);
}

/**
 * Parses an XML Property List string into a JavaScript data structure.
 *
 * @param {string} xml - The XML string to parse.
 * @returns {*} The parsed JavaScript structure.
 */
function parsePlist(xml) {
  return plist.parse(xml);
}

module.exports = {
  buildPlist,
  parsePlist,
};
test/contract.js
const assert = require('node:assert/strict');
const plist = require('plist');
const { buildPlist, parsePlist } = require('../src/index.js');

// Contract 1: plist.build serializes JavaScript primitives, objects, and arrays into valid XML plist format
{
  const data = {
    title: 'CodeSampleX Configuration',
    version: 1,
    enabled: true,
    tags: ['core', 'parser'],
  };
  const xml = buildPlist(data);

  assert.ok(xml.includes('<?xml version="1.0" encoding="UTF-8"?>'), 'Must include standard XML declaration');
  assert.ok(xml.includes('DOCTYPE plist PUBLIC') && xml.includes('PropertyList-1.0.dtd'), 'Must include Apple plist DOCTYPE');
  assert.ok(xml.includes('<plist version="1.0">'), 'Must include plist root element');
  assert.ok(xml.includes('<dict>'), 'Objects must serialize as dict');
  assert.ok(xml.includes('<key>title</key>'), 'Object keys must serialize as key elements');
  assert.ok(xml.includes('<string>CodeSampleX Configuration</string>'), 'Strings must serialize as string elements');
  assert.ok(xml.includes('<integer>1</integer>'), 'Integers must serialize as integer elements');
  assert.ok(xml.includes('<true/>'), 'Booleans must serialize as true/false self-closing tags');
  assert.ok(xml.includes('<array>'), 'Arrays must serialize as array elements');
}

// Contract 2: plist.parse parses XML plist strings containing strings, integers, reals, dates, buffers, and booleans
{
  const xml = `<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Sample Project</string>
  <key>count</key>
  <integer>100</integer>
  <key>ratio</key>
  <real>2.718</real>
  <key>active</key>
  <true/>
  <key>archived</key>
  <false/>
  <key>createdAt</key>
  <date>2026-08-27T16:00:00Z</date>
  <key>payload</key>
  <data>SGVsbG8gV29ybGQ=</data>
</dict>
</plist>`;

  const result = parsePlist(xml);
  assert.strictEqual(result.name, 'Sample Project');
  assert.strictEqual(result.count, 100);
  assert.strictEqual(result.ratio, 2.718);
  assert.strictEqual(result.active, true);
  assert.strictEqual(result.archived, false);
  assert.ok(result.createdAt instanceof Date);
  assert.strictEqual(result.createdAt.toISOString(), '2026-08-27T16:00:00.000Z');
  assert.ok(Buffer.isBuffer(result.payload));
  assert.strictEqual(result.payload.toString('utf8'), 'Hello World');
}

// Contract 3: plist.build and plist.parse preserve nested data structures across round-trip serialization
{
  const original = {
    service: 'CodeSampleX',
    metadata: {
      version: 3,
      tags: ['alpha', 'beta'],
      metrics: {
        score: 99.5,
      },
    },
    items: [
      { id: 1, label: 'first' },
      { id: 2, label: 'second' },
    ],
  };

  const xml = buildPlist(original);
  const parsed = parsePlist(xml);

  assert.deepStrictEqual(parsed, original, 'Round-trip parsing must preserve nested data structure');
}

// Contract 4: plist.build properly escapes special XML characters in dictionary keys and string values
{
  const specialData = {
    'custom&key<1>': 'AT&T <wireless> "quoted" \'single\'',
  };

  const xml = buildPlist(specialData);
  assert.ok(xml.includes('&amp;'), 'Ampersands must be escaped');
  assert.ok(xml.includes('&lt;'), 'Left angle brackets must be escaped');
  assert.ok(xml.includes('&gt;'), 'Right angle brackets must be escaped');
  assert.ok(!xml.includes('<wireless>'), 'Raw tag characters must not appear unescaped in text');

  const parsed = parsePlist(xml);
  assert.strictEqual(parsed['custom&key<1>'], 'AT&T <wireless> "quoted" \'single\'');
}

// Contract 5: plist.parse throws an error when given invalid or malformed XML without a plist root element
{
  const malformedXml = '<invalid><data>no plist tag</data></invalid>';
  assert.throws(
    () => {
      parsePlist(malformedXml);
    },
    (err) => {
      return err instanceof Error;
    },
    'Should throw an error on malformed XML lacking plist root'
  );
}

// Contract 6: plist.parse ignores __proto__ keys to prevent prototype pollution vulnerabilities
{
  const protoPollutionXml = `<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
  <key>__proto__</key>
  <dict>
    <key>polluted</key>
    <string>yes</string>
  </dict>
  <key>normalKey</key>
  <string>normalValue</string>
</dict>
</plist>`;

  try {
    const parsed = parsePlist(protoPollutionXml);
    assert.strictEqual(parsed.normalKey, 'normalValue');
  } catch (err) {
    assert.ok(err instanceof Error, 'If parse throws on __proto__, it must be an Error');
  }

  const testObj = {};
  assert.strictEqual(testObj.polluted, undefined, 'Object.prototype must not be polluted');
}

console.log('All contract tests passed successfully.');

오리진 시더

익명