CodeSampleX

샘플

resedit 1.7.2

검증된 샘플 — npm resedit 1.7.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: NtExecutable.createEmpty creates an empty PE executable structure and…

sha256:a23436f8759a50a5fea9a7d79b8be363d60557e20b6ad4a8865acdf2f9f5b784

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

케이스

HOW
목표
verify pkg:npm/resedit@1.7.2
패키지
환경
node 22.23.2
생성일
2026-08-28T05:14:14Z

컨트랙트

  1. NtExecutable.createEmpty creates an empty PE executable structure and NtExecutableResource manages its resource entries
  2. Resource.VersionInfo sets file version, product version, and string table metadata in executable resources
  3. Resource.StringTable adds localized string table entries by integer ID into executable resources
  4. NtExecutable.generate produces a PE binary containing resource entries and NtExecutable.from re-parses identical resources from binary

파일

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • 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/resedit@1.7.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/resedit@1.7.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.
csx.json
{"case":{"caseId":"case:sha256:e9b38c81623fe0c3b7283aea4a720a8e3019b2fdc7167bd7aa623067e5fbb660","contract":["NtExecutable.createEmpty creates an empty PE executable structure and NtExecutableResource manages its resource entries","Resource.VersionInfo sets file version, product version, and string table metadata in executable resources","Resource.StringTable adds localized string table entries by integer ID into executable resources","NtExecutable.generate produces a PE binary containing resource entries and NtExecutable.from re-parses identical resources from binary"],"goal":"verify pkg:npm/resedit@1.7.2","kind":"HOW","packages":["pkg:npm/resedit@1.7.2"],"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/resedit@1.7.2"],"schemaVersion":1,"subject":"pkg:npm/resedit@1.7.2","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const ResEdit = require('resedit');

/**
 * Creates an empty PE executable structure and populates it with VersionInfo and StringTable resources.
 *
 * @param {Object} [options]
 * @param {boolean} [options.is32Bit=false]
 * @param {boolean} [options.isDLL=false]
 * @param {number} [options.lang=1033]
 * @param {number} [options.codepage=1200]
 * @param {Object} [options.versionNumbers]
 * @param {Object} [options.stringValues]
 * @param {Object} [options.tableStrings]
 * @returns {{ exe: ResEdit.NtExecutable, res: ResEdit.NtExecutableResource, binary: ArrayBuffer }}
 */
function createExecutableWithResources(options = {}) {
  const is32Bit = options.is32Bit || false;
  const isDLL = options.isDLL || false;
  const lang = options.lang !== undefined ? options.lang : 1033;
  const codepage = options.codepage !== undefined ? options.codepage : 1200;

  const exe = ResEdit.NtExecutable.createEmpty(is32Bit, isDLL);
  const res = ResEdit.NtExecutableResource.from(exe);

  if (options.versionNumbers || options.stringValues) {
    const vi = ResEdit.Resource.VersionInfo.createEmpty();
    vi.lang = lang;

    if (options.versionNumbers) {
      const { fileVersion, productVersion } = options.versionNumbers;
      if (fileVersion) {
        vi.setFileVersion(
          fileVersion.major || 0,
          fileVersion.minor || 0,
          fileVersion.patch || 0,
          fileVersion.build || 0,
          lang
        );
      }
      if (productVersion) {
        vi.setProductVersion(
          productVersion.major || 0,
          productVersion.minor || 0,
          productVersion.patch || 0,
          productVersion.build || 0,
          lang
        );
      }
    }

    if (options.stringValues) {
      vi.setStringValues({ lang, codepage }, options.stringValues);
    }

    vi.outputToResourceEntries(res.entries);
  }

  if (options.tableStrings) {
    const st = new ResEdit.Resource.StringTable();
    st.lang = lang;
    for (const [idStr, text] of Object.entries(options.tableStrings)) {
      st.setById(Number(idStr), text);
    }
    st.replaceStringEntriesForExecutable(res);
  }

  res.outputResource(exe);
  const binary = exe.generate();

  return { exe, res, binary };
}

/**
 * Parses a PE binary and extracts its VersionInfo and StringTable resources.
 *
 * @param {ArrayBuffer|Buffer} binary
 * @param {number} [lang=1033]
 * @param {number} [codepage=1200]
 * @returns {{ versionInfo: Object|null, stringTable: Object }}
 */
function readExecutableResources(binary, lang = 1033, codepage = 1200) {
  const exe = ResEdit.NtExecutable.from(binary);
  const res = ResEdit.NtExecutableResource.from(exe);

  const viList = ResEdit.Resource.VersionInfo.fromEntries(res.entries);
  let versionInfo = null;
  if (viList.length > 0) {
    const vi = viList[0];
    versionInfo = {
      fixedInfo: {
        fileVersionMS: vi.fixedInfo.fileVersionMS,
        fileVersionLS: vi.fixedInfo.fileVersionLS,
        productVersionMS: vi.fixedInfo.productVersionMS,
        productVersionLS: vi.fixedInfo.productVersionLS
      },
      strings: vi.getStringValues({ lang, codepage })
    };
  }

  const st = ResEdit.Resource.StringTable.fromEntries(lang, res.entries);
  const strings = {};
  for (const item of st.getAllStrings()) {
    strings[item.id] = item.text;
  }

  return { versionInfo, stringTable: strings };
}

module.exports = {
  createExecutableWithResources,
  readExecutableResources,
  ResEdit
};
package-lock.json
{
  "name": "sample-resedit",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-resedit",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "resedit": "1.7.2"
      }
    },
    "node_modules/pe-library": {
      "version": "0.4.1",
      "resolved": "https://registry.npmjs.org/pe-library/-/pe-library-0.4.1.tgz",
      "integrity": "sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==",
      "license": "MIT",
      "engines": {
        "node": ">=12",
        "npm": ">=6"
      },
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/jet2jet"
      }
    },
    "node_modules/resedit": {
      "version": "1.7.2",
      "resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz",
      "integrity": "sha512-vHjcY2MlAITJhC0eRD/Vv8Vlgmu9Sd3LX9zZvtGzU5ZImdTN3+d6e/4mnTyV8vEbyf1sgNIrWxhWlrys52OkEA==",
      "license": "MIT",
      "dependencies": {
        "pe-library": "^0.4.1"
      },
      "engines": {
        "node": ">=12",
        "npm": ">=6"
      },
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/jet2jet"
      }
    }
  }
}
package.json
{
  "name": "sample-resedit",
  "version": "1.0.0",
  "private": true,
  "description": "verify pkg:npm/resedit@1.7.2",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "resedit": "1.7.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/resedit@1.7.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/resedit@1.7.2"
  ]
}
test/contract.js
'use strict';

const assert = require('assert');
const ResEdit = require('resedit');
const { createExecutableWithResources, readExecutableResources } = require('../index.js');

async function testResEditContract() {
  // 1. Contract: NtExecutable.createEmpty creates an empty PE executable structure and NtExecutableResource manages its resource entries
  const exe = ResEdit.NtExecutable.createEmpty(false, false);
  assert.ok(exe, 'NtExecutable.createEmpty must return an executable instance');
  const res = ResEdit.NtExecutableResource.from(exe);
  assert.ok(res, 'NtExecutableResource.from must return a resource instance');
  assert.ok(Array.isArray(res.entries), 'res.entries must be an array');

  // 2. Contract: Resource.VersionInfo sets file version, product version, and string table metadata in executable resources
  const vi = ResEdit.Resource.VersionInfo.createEmpty();
  vi.lang = 1033;
  vi.setFileVersion(2, 4, 6, 8, 1033);
  vi.setProductVersion(1, 0, 0, 1, 1033);
  vi.setStringValues(
    { lang: 1033, codepage: 1200 },
    {
      FileDescription: 'Sample ResEdit Executable',
      ProductName: 'CodeSampleX ResEdit Tool',
      FileVersion: '2.4.6.8',
      ProductVersion: '1.0.0.1',
      CompanyName: 'Example Org'
    }
  );
  vi.outputToResourceEntries(res.entries);

  // 3. Contract: Resource.StringTable adds localized string table entries by integer ID into executable resources
  const st = new ResEdit.Resource.StringTable();
  st.lang = 1033;
  st.setById(101, 'Hello from ResEdit string table');
  st.setById(202, 'Resource string 202');
  st.replaceStringEntriesForExecutable(res);

  // 4. Contract: NtExecutable.generate produces a PE binary containing resource entries and NtExecutable.from re-parses identical resources from binary
  res.outputResource(exe);
  const binary = exe.generate();
  assert.ok(binary instanceof ArrayBuffer, 'exe.generate must return an ArrayBuffer');
  assert.ok(binary.byteLength > 0, 'generated binary must not be empty');

  const parsedExe = ResEdit.NtExecutable.from(binary);
  const parsedRes = ResEdit.NtExecutableResource.from(parsedExe);

  const parsedViList = ResEdit.Resource.VersionInfo.fromEntries(parsedRes.entries);
  assert.strictEqual(parsedViList.length, 1, 'parsed binary must contain exactly one VersionInfo resource');
  const parsedVi = parsedViList[0];
  const parsedStrings = parsedVi.getStringValues({ lang: 1033, codepage: 1200 });
  assert.strictEqual(parsedStrings.FileDescription, 'Sample ResEdit Executable');
  assert.strictEqual(parsedStrings.ProductName, 'CodeSampleX ResEdit Tool');
  assert.strictEqual(parsedStrings.FileVersion, '2.4.6.8');
  assert.strictEqual(parsedStrings.ProductVersion, '1.0.0.1');
  assert.strictEqual(parsedStrings.CompanyName, 'Example Org');

  // Verify fixed version numbers (HIWORD / LOWORD representation)
  assert.strictEqual(parsedVi.fixedInfo.fileVersionMS, (2 << 16) | 4);
  assert.strictEqual(parsedVi.fixedInfo.fileVersionLS, (6 << 16) | 8);

  const parsedSt = ResEdit.Resource.StringTable.fromEntries(1033, parsedRes.entries);
  assert.strictEqual(parsedSt.getById(101), 'Hello from ResEdit string table');
  assert.strictEqual(parsedSt.getById(202), 'Resource string 202');
  assert.strictEqual(parsedSt.getById(999), null, 'non-existent ID must return null');

  // 5. Verify helper functions from index.js
  const helperResult = createExecutableWithResources({
    lang: 1033,
    codepage: 1200,
    versionNumbers: {
      fileVersion: { major: 3, minor: 1, patch: 4, build: 1 },
      productVersion: { major: 3, minor: 0, patch: 0, build: 0 }
    },
    stringValues: {
      FileDescription: 'Helper Generated App',
      ProductName: 'Helper Product'
    },
    tableStrings: {
      301: 'Helper String 301',
      302: 'Helper String 302'
    }
  });

  const readBack = readExecutableResources(helperResult.binary, 1033, 1200);
  assert.ok(readBack.versionInfo, 'versionInfo must be parsed');
  assert.strictEqual(readBack.versionInfo.strings.FileDescription, 'Helper Generated App');
  assert.strictEqual(readBack.versionInfo.strings.ProductName, 'Helper Product');
  assert.strictEqual(readBack.stringTable[301], 'Helper String 301');
  assert.strictEqual(readBack.stringTable[302], 'Helper String 302');

  console.log('Contract tests passed successfully.');
}

testResEditContract().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

오리진 시더

익명