示例
resedit 1.7.2
已验证示例 — npm resedit 1.7.2. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: NtExecutable.createEmpty creates an empty PE executable structure and…
sha256:a23436f8759a50a5fea9a7d79b8be363d60557e20b6ad4a8865acdf2f9f5b784
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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
契约
- 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
文件
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
源代码
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.
{"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"}
'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
};
{
"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"
}
}
}
}
{
"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"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/resedit@1.7.2",
"kind": "HOW",
"packages": [
"pkg:npm/resedit@1.7.2"
]
}
'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);
});
原始种子者
匿名