CodeSampleX

샘플

proxy-addr 2.0.7: compile

검증된 샘플 — npm proxy-addr 2.0.7: compile. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert compile throws TypeError when argument is missing…

sha256:09f70f13613c62e0424d47e926f6336da1b0262804f68a3a0a717536e5399018

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

케이스

HOW
목표
verify proxy-addr.compile in pkg:npm/proxy-addr@2.0.7
패키지
심벌
  • proxy-addr.compile
환경
node 22.23.2
생성일
2026-08-23T04:23:17Z

컨트랙트

  1. assert compile throws TypeError when argument is missing or falsy
  2. assert compile throws TypeError when argument is not a string or array
  3. assert compile throws TypeError when argument contains invalid IP address or out-of-range CIDR mask
  4. assert compile with empty array returns trust function that evaluates all addresses to false
  5. assert compile with single IP or CIDR returns trust function matching exact address and subnet range
  6. assert compile with built-in range names expands loopback linklocal and uniquelocal subnets
  7. assert compile with netmask notation parses subnet mask into valid CIDR trust evaluator
  8. assert compiled trust function correctly handles IPv4-mapped IPv6 address comparisons and invalid IP queries
  9. assert compile with array of mixed CIDR subnets and built-in names evaluates multi-subnet trust correctly

파일

  • PROMPT.md
  • csx.json
  • 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 proxy-addr.compile in pkg:npm/proxy-addr@2.0.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/proxy-addr@2.0.7
Demonstrate these symbols/APIs:
  - proxy-addr.compile

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:83db85cac5cd31fea0d584d088464a442e229af5265c74a04076b3741bc24075","contract":["assert compile throws TypeError when argument is missing or falsy","assert compile throws TypeError when argument is not a string or array","assert compile throws TypeError when argument contains invalid IP address or out-of-range CIDR mask","assert compile with empty array returns trust function that evaluates all addresses to false","assert compile with single IP or CIDR returns trust function matching exact address and subnet range","assert compile with built-in range names expands loopback linklocal and uniquelocal subnets","assert compile with netmask notation parses subnet mask into valid CIDR trust evaluator","assert compiled trust function correctly handles IPv4-mapped IPv6 address comparisons and invalid IP queries","assert compile with array of mixed CIDR subnets and built-in names evaluates multi-subnet trust correctly"],"goal":"verify proxy-addr.compile in pkg:npm/proxy-addr@2.0.7","kind":"HOW","packages":["pkg:npm/proxy-addr@2.0.7"],"schemaVersion":1,"symbols":["proxy-addr.compile"]},"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/proxy-addr@2.0.7"],"schemaVersion":1,"subject":"pkg:npm/proxy-addr@2.0.7","symbols":["proxy-addr.compile"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "csx-sample-proxy-addr",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "csx-sample-proxy-addr",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "proxy-addr": "2.0.7"
      }
    },
    "node_modules/forwarded": {
      "version": "0.2.0",
      "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
      "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.6"
      }
    },
    "node_modules/ipaddr.js": {
      "version": "1.9.1",
      "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
      "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.10"
      }
    },
    "node_modules/proxy-addr": {
      "version": "2.0.7",
      "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
      "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
      "license": "MIT",
      "dependencies": {
        "forwarded": "0.2.0",
        "ipaddr.js": "1.9.1"
      },
      "engines": {
        "node": ">= 0.10"
      }
    }
  }
}
package.json
{
  "name": "csx-sample-proxy-addr",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for proxy-addr.compile",
  "main": "test/contract.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "proxy-addr": "2.0.7"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify proxy-addr.compile in pkg:npm/proxy-addr@2.0.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/proxy-addr@2.0.7"
  ],
  "symbols": [
    "proxy-addr.compile"
  ]
}
test/contract.js
const assert = require('assert');
const proxyaddr = require('proxy-addr');

async function runTests() {
  const compile = proxyaddr.compile;

  // Test 1: compile throws TypeError when argument is missing or falsy
  assert.throws(() => {
    compile();
  }, {
    name: 'TypeError',
    message: 'argument is required'
  }, 'compile() with undefined must throw argument is required');

  assert.throws(() => {
    compile(null);
  }, {
    name: 'TypeError',
    message: 'argument is required'
  }, 'compile(null) must throw argument is required');

  assert.throws(() => {
    compile('');
  }, {
    name: 'TypeError',
    message: 'argument is required'
  }, 'compile("") must throw argument is required');

  // Test 2: compile throws TypeError when argument is not a string or array
  assert.throws(() => {
    compile(123);
  }, {
    name: 'TypeError',
    message: 'unsupported trust argument'
  }, 'compile(number) must throw unsupported trust argument');

  assert.throws(() => {
    compile({});
  }, {
    name: 'TypeError',
    message: 'unsupported trust argument'
  }, 'compile(object) must throw unsupported trust argument');

  assert.throws(() => {
    compile(true);
  }, {
    name: 'TypeError',
    message: 'unsupported trust argument'
  }, 'compile(boolean) must throw unsupported trust argument');

  // Test 3: compile throws TypeError when argument contains invalid IP address or out-of-range CIDR mask
  assert.throws(() => {
    compile('invalid-ip-string');
  }, {
    name: 'TypeError',
    message: 'invalid IP address: invalid-ip-string'
  }, 'compile with invalid IP must throw invalid IP address');

  assert.throws(() => {
    compile('127.0.0.1/33');
  }, {
    name: 'TypeError',
    message: 'invalid range on address: 127.0.0.1/33'
  }, 'compile with IPv4 range > 32 must throw invalid range');

  assert.throws(() => {
    compile('127.0.0.1/0');
  }, {
    name: 'TypeError',
    message: 'invalid range on address: 127.0.0.1/0'
  }, 'compile with range 0 must throw invalid range');

  assert.throws(() => {
    compile('::1/129');
  }, {
    name: 'TypeError',
    message: 'invalid range on address: ::1/129'
  }, 'compile with IPv6 range > 128 must throw invalid range');

  // Test 4: compile with empty array returns trust function that evaluates all addresses to false
  const trustNone = compile([]);
  assert.strictEqual(typeof trustNone, 'function');
  assert.strictEqual(trustNone('127.0.0.1'), false);
  assert.strictEqual(trustNone('10.0.0.1'), false);
  assert.strictEqual(trustNone('::1'), false);

  // Test 5: compile with single IP or CIDR returns trust function matching exact address and subnet range
  const trustSingleIp = compile('192.168.1.50');
  assert.strictEqual(trustSingleIp('192.168.1.50'), true);
  assert.strictEqual(trustSingleIp('192.168.1.51'), false);

  const trustCidr = compile('10.0.0.0/16');
  assert.strictEqual(trustCidr('10.0.0.1'), true);
  assert.strictEqual(trustCidr('10.0.254.254'), true);
  assert.strictEqual(trustCidr('10.1.0.1'), false);

  const trustIpv6 = compile('2001:db8::/32');
  assert.strictEqual(trustIpv6('2001:db8::1'), true);
  assert.strictEqual(trustIpv6('2001:db8:ffff::1'), true);
  assert.strictEqual(trustIpv6('2001:db9::1'), false);

  // Test 6: compile with built-in range names expands loopback linklocal and uniquelocal subnets
  const trustLoopback = compile('loopback');
  assert.strictEqual(trustLoopback('127.0.0.1'), true);
  assert.strictEqual(trustLoopback('127.0.10.5'), true);
  assert.strictEqual(trustLoopback('::1'), true);
  assert.strictEqual(trustLoopback('10.0.0.1'), false);

  const trustLinkLocal = compile('linklocal');
  assert.strictEqual(trustLinkLocal('169.254.1.1'), true);
  assert.strictEqual(trustLinkLocal('fe80::1'), true);
  assert.strictEqual(trustLinkLocal('127.0.0.1'), false);

  const trustUniqueLocal = compile('uniquelocal');
  assert.strictEqual(trustUniqueLocal('10.0.0.1'), true);
  assert.strictEqual(trustUniqueLocal('172.16.5.2'), true);
  assert.strictEqual(trustUniqueLocal('192.168.1.1'), true);
  assert.strictEqual(trustUniqueLocal('fc00::1'), true);
  assert.strictEqual(trustUniqueLocal('fd12::1'), true);
  assert.strictEqual(trustUniqueLocal('8.8.8.8'), false);

  // Test 7: compile with netmask notation parses subnet mask into valid CIDR trust evaluator
  const trustNetmask = compile('192.168.0.0/255.255.0.0');
  assert.strictEqual(trustNetmask('192.168.10.20'), true);
  assert.strictEqual(trustNetmask('192.169.10.20'), false);

  // Test 8: compiled trust function correctly handles IPv4-mapped IPv6 address comparisons and invalid IP queries
  const trustIpv4Mapped = compile('127.0.0.1/8');
  assert.strictEqual(trustIpv4Mapped('::ffff:127.0.0.1'), true);
  assert.strictEqual(trustIpv4Mapped('::ffff:192.168.1.1'), false);

  const trustIpv6MappedSubnet = compile('::ffff:127.0.0.1');
  assert.strictEqual(trustIpv6MappedSubnet('127.0.0.1'), true);
  assert.strictEqual(trustIpv6MappedSubnet('::ffff:127.0.0.1'), true);

  // Non-IP addresses or malformed strings return false safely without throwing
  assert.strictEqual(trustLoopback('not-an-ip'), false);
  assert.strictEqual(trustLoopback(''), false);
  assert.strictEqual(trustLoopback(null), false);
  assert.strictEqual(trustLoopback(undefined), false);

  // Test 9: compile with array of mixed CIDR subnets and built-in names evaluates multi-subnet trust correctly
  const trustMulti = compile(['loopback', '10.0.0.0/8', '2001:db8::/32']);
  assert.strictEqual(trustMulti('127.0.0.1'), true);
  assert.strictEqual(trustMulti('::1'), true);
  assert.strictEqual(trustMulti('10.250.1.1'), true);
  assert.strictEqual(trustMulti('2001:db8::abcd'), true);
  assert.strictEqual(trustMulti('192.168.1.1'), false);
  assert.strictEqual(trustMulti('2001:db9::1'), false);

  console.log('All proxy-addr.compile contract assertions passed successfully.');
}

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

오리진 시더

익명