CodeSampleX

샘플

robots-parser 3.0.1: isAllowed

검증된 샘플 — npm robots-parser 3.0.1: isAllowed. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: isAllowed returns true for paths matching an Allow…

sha256:c1e28b275235f9d6e8c0c8ae55da65afa99406bb02d148660ddf944cef1c9989

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

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-13

케이스

HOW
목표
verify isAllowed in pkg:npm/robots-parser@3.0.1
패키지
심벌
  • isAllowed
생성일
2026-09-13T18:40:45Z

컨트랙트

  1. isAllowed returns true for paths matching an Allow directive and false for paths matching a Disallow directive
  2. isAllowed returns true by default when no matching rule is specified for a path
  3. isAllowed respects user-agent specific rules over wildcard rules
  4. isAllowed applies the longest matching rule when multiple rules match a path
  5. isAllowed prefers Allow directive over Disallow directive when rule patterns have equal length
  6. isAllowed supports wildcard (*) and end-of-line ($) pattern matching
  7. isAllowed returns undefined when the queried URL protocol, hostname, or port does not match the robots.txt base URL

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (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 isAllowed in pkg:npm/robots-parser@3.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/robots-parser@3.0.1
Demonstrate these symbols/APIs:
  - isAllowed

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:5193029bf557b99d4126ad9ad55ec5e22fb83a9a788aa165c3d3130d40243530","contract":["isAllowed returns true for paths matching an Allow directive and false for paths matching a Disallow directive","isAllowed returns true by default when no matching rule is specified for a path","isAllowed respects user-agent specific rules over wildcard rules","isAllowed applies the longest matching rule when multiple rules match a path","isAllowed prefers Allow directive over Disallow directive when rule patterns have equal length","isAllowed supports wildcard (*) and end-of-line ($) pattern matching","isAllowed returns undefined when the queried URL protocol, hostname, or port does not match the robots.txt base URL"],"goal":"verify isAllowed in pkg:npm/robots-parser@3.0.1","kind":"HOW","packages":["pkg:npm/robots-parser@3.0.1"],"schemaVersion":1,"symbols":["isAllowed"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/robots-parser@3.0.1"],"schemaVersion":1,"subject":"pkg:npm/robots-parser@3.0.1","symbols":["isAllowed"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "robots-parser-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "robots-parser-sample",
      "version": "1.0.0",
      "dependencies": {
        "robots-parser": "3.0.1"
      }
    },
    "node_modules/robots-parser": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/robots-parser/-/robots-parser-3.0.1.tgz",
      "integrity": "sha512-s+pyvQeIKIZ0dx5iJiQk1tPLJAWln39+MI5jtM8wnyws+G5azk+dMnMX0qfbqNetKKNgcWWOdi0sfm+FbQbgdQ==",
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      }
    }
  }
}
package.json
{
  "name": "robots-parser-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for robots-parser",
  "dependencies": {
    "robots-parser": "3.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify isAllowed in pkg:npm/robots-parser@3.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/robots-parser@3.0.1"
  ],
  "symbols": [
    "isAllowed"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import robotsParser from 'robots-parser';

// 1. isAllowed returns true for paths matching an Allow directive and false for paths matching a Disallow directive
const robots1 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /admin/',
  'Allow: /public/'
].join('\n'));
assert.strictEqual(robots1.isAllowed('https://example.com/admin/dashboard'), false);
assert.strictEqual(robots1.isAllowed('https://example.com/public/about'), true);

// 2. isAllowed returns true by default when no matching rule is specified for a path
const robots2 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /private/'
].join('\n'));
assert.strictEqual(robots2.isAllowed('https://example.com/unrestricted/page.html'), true);

// 3. isAllowed respects user-agent specific rules over wildcard rules
const robots3 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /data/',
  'User-agent: TestBot',
  'Allow: /data/'
].join('\n'));
assert.strictEqual(robots3.isAllowed('https://example.com/data/report', 'TestBot/2.0'), true);
assert.strictEqual(robots3.isAllowed('https://example.com/data/report', 'OtherBot'), false);

// 4. isAllowed applies the longest matching rule when multiple rules match a path
const robots4 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /media/',
  'Allow: /media/public/'
].join('\n'));
assert.strictEqual(robots4.isAllowed('https://example.com/media/public/image.png'), true);
assert.strictEqual(robots4.isAllowed('https://example.com/media/private/image.png'), false);

// 5. isAllowed prefers Allow directive over Disallow directive when rule patterns have equal length
const robots5 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /shared',
  'Allow: /shared'
].join('\n'));
assert.strictEqual(robots5.isAllowed('https://example.com/shared'), true);

// 6. isAllowed supports wildcard (*) and end-of-line ($) pattern matching
const robots6 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /*.secret$',
  'Disallow: /temp/*/cache'
].join('\n'));
assert.strictEqual(robots6.isAllowed('https://example.com/file.secret'), false);
assert.strictEqual(robots6.isAllowed('https://example.com/file.secret.html'), true);
assert.strictEqual(robots6.isAllowed('https://example.com/temp/user123/cache'), false);
assert.strictEqual(robots6.isAllowed('https://example.com/temp/user123/other'), true);

// 7. isAllowed returns undefined when the queried URL protocol, hostname, or port does not match the robots.txt base URL
const robots7 = robotsParser('https://example.com/robots.txt', [
  'User-agent: *',
  'Disallow: /admin/'
].join('\n'));
assert.strictEqual(robots7.isAllowed('http://example.com/admin/'), undefined);
assert.strictEqual(robots7.isAllowed('https://different.example.com/admin/'), undefined);
assert.strictEqual(robots7.isAllowed('https://example.com:8080/admin/'), undefined);

console.log('Contract passed');

오리진 시더

익명