CodeSampleX

サンプル

certifi 2026.2.25: __main__

検証済みサンプル — pypi certifi 2026.2.25: __main__. python 3.12 · linux alpine/x64 · docker で contract を実行し、成功しました: certifi.__main__ executed without arguments…

sha256:2e355a96fecb9f03cf85f79d5b7908d3ad86fd27d21dd6ba3a7ec833b0003465

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
1
宣言された環境 python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24

検証実行環境

環境 コントラクト ステージ 実行日
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-20
python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104…
2026-09-08

ケース

HOW
ゴール
verify pkg:pypi/certifi@2026.2.25
パッケージ
シンボル
  • certifi.__main__
環境
python 3.12
作成日
2026-08-20T11:22:07Z

コントラクト

  1. certifi.__main__ executed without arguments prints the CA bundle path and exits 0
  2. certifi.__main__ executed with -c flag prints the certificate bundle contents
  3. certifi.__main__ executed with --contents flag prints the identical certificate bundle contents
  4. certifi.__main__ executed with --help flag displays usage options and exits 0
  5. certifi.__main__ executed with unrecognized arguments exits with non-zero status code

ファイル

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • src/__init__.py
  • src/sample.py
  • test/contract.py

ソースアーティファクトをダウンロード (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:pypi/certifi@2026.2.25
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/certifi@2026.2.25
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.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:d33f1aec1abd36f99b4fb682c047881971b5c181cb6bd7297de2f26c717000d9","contract":["certifi.__main__ executed without arguments prints the CA bundle path and exits 0","certifi.__main__ executed with -c flag prints the certificate bundle contents","certifi.__main__ executed with --contents flag prints the identical certificate bundle contents","certifi.__main__ executed with --help flag displays usage options and exits 0","certifi.__main__ executed with unrecognized arguments exits with non-zero status code"],"goal":"verify pkg:pypi/certifi@2026.2.25","kind":"HOW","packages":["pkg:pypi/certifi@2026.2.25"],"schemaVersion":1,"symbols":["certifi.__main__"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/certifi@2026.2.25"],"schemaVersion":1,"symbols":["certifi.__main__"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "certifi-cli-sample"
version = "0.1.0"
description = "Clean-room verification sample for certifi CLI module"
requires-python = ">=3.9"
dependencies = [
    "certifi==2026.2.25"
]
requirements.txt
certifi==2026.2.25
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/certifi@2026.2.25",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/certifi@2026.2.25"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/__init__.py
from .sample import (
    run_cli_default,
    run_cli_short_contents,
    run_cli_long_contents,
    run_cli_help,
    run_cli_invalid,
)

__all__ = [
    "run_cli_default",
    "run_cli_short_contents",
    "run_cli_long_contents",
    "run_cli_help",
    "run_cli_invalid",
]
src/sample.py
"""Sample demonstrating command-line interface execution of the certifi package."""

import subprocess
import sys
from typing import Tuple


def run_cli_default() -> Tuple[int, str]:
    """Execute certifi CLI without arguments, returning exit code and trimmed stdout."""
    result = subprocess.run(
        [sys.executable, "-m", "certifi"],
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout.strip()


def run_cli_short_contents() -> Tuple[int, str]:
    """Execute certifi CLI with -c flag, returning exit code and stdout."""
    result = subprocess.run(
        [sys.executable, "-m", "certifi", "-c"],
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout


def run_cli_long_contents() -> Tuple[int, str]:
    """Execute certifi CLI with --contents flag, returning exit code and stdout."""
    result = subprocess.run(
        [sys.executable, "-m", "certifi", "--contents"],
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout


def run_cli_help() -> Tuple[int, str]:
    """Execute certifi CLI with --help flag, returning exit code and stdout."""
    result = subprocess.run(
        [sys.executable, "-m", "certifi", "--help"],
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout


def run_cli_invalid() -> Tuple[int, str, str]:
    """Execute certifi CLI with an invalid flag, returning exit code, stdout, and stderr."""
    result = subprocess.run(
        [sys.executable, "-m", "certifi", "--unrecognized-argument-test"],
        capture_output=True,
        text=True,
    )
    return result.returncode, result.stdout, result.stderr
test/contract.py
"""Contract verification tests for certifi.__main__ command-line interface."""

import os
import sys
from pathlib import Path

src_dir = Path(__file__).resolve().parent.parent / "src"
if str(src_dir) not in sys.path:
    sys.path.insert(0, str(src_dir))

import certifi
from sample import (
    run_cli_default,
    run_cli_short_contents,
    run_cli_long_contents,
    run_cli_help,
    run_cli_invalid,
)


def test_contract_1_default_execution():
    """Assertion 1: certifi.__main__ executed without arguments prints the CA bundle path and exits 0."""
    code, output = run_cli_default()
    assert code == 0, f"Expected exit code 0, got {code}"
    expected_path = certifi.where()
    assert output == expected_path, f"CLI output '{output}' must match certifi.where() '{expected_path}'"
    assert os.path.exists(output), f"Output path '{output}' must exist on disk"


def test_contract_2_short_contents_flag():
    """Assertion 2: certifi.__main__ executed with -c flag prints the certificate bundle contents."""
    code, output = run_cli_short_contents()
    assert code == 0, f"Expected exit code 0, got {code}"
    assert len(output) > 0, "Output must be non-empty"
    assert "-----BEGIN CERTIFICATE-----" in output, "Output must contain PEM certificate header"
    assert "-----END CERTIFICATE-----" in output, "Output must contain PEM certificate footer"
    expected_contents = certifi.contents()
    assert output.strip() == expected_contents.strip(), "CLI output must match certifi.contents()"


def test_contract_3_long_contents_flag():
    """Assertion 3: certifi.__main__ executed with --contents flag prints the identical certificate bundle contents."""
    code_short, output_short = run_cli_short_contents()
    code_long, output_long = run_cli_long_contents()
    assert code_long == 0, f"Expected exit code 0, got {code_long}"
    assert output_long == output_short, "--contents output must match -c output exactly"


def test_contract_4_help_flag():
    """Assertion 4: certifi.__main__ executed with --help flag displays usage options and exits 0."""
    code, output = run_cli_help()
    assert code == 0, f"Expected exit code 0, got {code}"
    assert "usage:" in output, "Help output must contain usage string"
    assert "-c" in output or "--contents" in output, "Help output must describe contents option"


def test_contract_5_invalid_argument():
    """Assertion 5: certifi.__main__ executed with unrecognized arguments exits with non-zero status code."""
    code, stdout, stderr = run_cli_invalid()
    assert code != 0, f"Expected non-zero exit code for invalid args, got {code}"
    assert "error:" in stderr or "usage:" in stderr or "unrecognized" in stderr, "Error output expected on stderr"


def main():
    print("Running contract verification for certifi.__main__ CLI...")
    test_contract_1_default_execution()
    test_contract_2_short_contents_flag()
    test_contract_3_long_contents_flag()
    test_contract_4_help_flag()
    test_contract_5_invalid_argument()
    print("All contract assertions passed successfully.")


if __name__ == "__main__":
    main()

オリジンシーダー

匿名