CodeSampleX

Exemple

github.com/mholt/acmez/v3 v3.1.2: acme.StatusValid

Échantillon vérifié pour golang github.com/mholt/acmez/v3 v3.1.2: acme.StatusValid. Le contrat s'est exécuté sur go 1.26 · linux alpine/x64 · docker et a…

sha256:36b49c2598e25c89f2471dfe725659fc153ab39d4a0acb41f9a26360ab0f8cfa

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré go linux 24 · ubuntu · glibc 2.39 x64 go go go

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-28

Cas

HOW
Objectif
verify github.com/mholt/acmez/v3/acme.StatusValid in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Paquets
Symboles
  • github.com/mholt/acmez/v3/acme.StatusValid
Environnement
go
Créé
2026-08-28T01:46:01Z

Contrat

  1. acme.StatusValid is equal to the string constant "valid".
  2. acme.Account preserves Status equal to acme.StatusValid across JSON serialization and deserialization.
  3. acme.Order in state acme.StatusValid retains valid authorizations, expiration, and certificate URL.
  4. acme.Authorization with Status equal to acme.StatusValid contains valid challenges and expiration.
  5. acme.Challenge with Status equal to acme.StatusValid computes correct HTTP-01 challenge resource path.

Fichiers

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract_test.go

Télécharger l’artefact source (tar.gz)

Code source

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 github.com/mholt/acmez/v3/acme.StatusValid in pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/mholt/acmez/v3@v3.1.2
Demonstrate these symbols/APIs:
  - github.com/mholt/acmez/v3/acme.StatusValid
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:9f9fd9128c7791ded93b6cbe89b1fb3f632f5aaf7e4a54a8c33ea06bc975499a","contract":["acme.StatusValid is equal to the string constant \"valid\".","acme.Account preserves Status equal to acme.StatusValid across JSON serialization and deserialization.","acme.Order in state acme.StatusValid retains valid authorizations, expiration, and certificate URL.","acme.Authorization with Status equal to acme.StatusValid contains valid challenges and expiration.","acme.Challenge with Status equal to acme.StatusValid computes correct HTTP-01 challenge resource path."],"goal":"verify github.com/mholt/acmez/v3/acme.StatusValid in pkg:golang/github.com/mholt/acmez/v3@v3.1.2","kind":"HOW","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"symbols":["github.com/mholt/acmez/v3/acme.StatusValid"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","executionContext":"go","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/mholt/acmez/v3@v3.1.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/mholt/acmez/v3@v3.1.2","symbols":["github.com/mholt/acmez/v3/acme.StatusValid"],"verifierAdapter":"golang@1"}
go.mod
module example.com/acmevalid

go 1.26.6

require (
	github.com/mholt/acmez/v3 v3.1.2
	golang.org/x/crypto v0.27.0 // indirect
	golang.org/x/net v0.29.0 // indirect
	golang.org/x/text v0.18.0 // indirect
)
go.sum
github.com/mholt/acmez/v3 v3.1.2 h1:auob8J/0FhmdClQicvJvuDavgd5ezwLBfKuYmynhYzc=
github.com/mholt/acmez/v3 v3.1.2/go.mod h1:L1wOU06KKvq7tswuMDwKdcHeKpFFgkppZy/y0DFxagQ=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
main.go
package main

import (
	"encoding/json"
	"fmt"
	"time"

	"github.com/mholt/acmez/v3/acme"
)

func main() {
	now := time.Now().UTC().Truncate(time.Second)

	account := acme.Account{
		Status:  acme.StatusValid,
		Contact: []string{"mailto:admin@example.com"},
		Orders:  "https://example.com/acme/acct/1/orders",
	}

	order := acme.Order{
		Status:         acme.StatusValid,
		Expires:        now.Add(24 * time.Hour),
		Identifiers:    []acme.Identifier{{Type: "dns", Value: "example.com"}},
		Authorizations: []string{"https://example.com/acme/authz/1"},
		Finalize:       "https://example.com/acme/order/1/finalize",
		Certificate:    "https://example.com/acme/cert/1",
	}

	authz := acme.Authorization{
		Identifier: acme.Identifier{Type: "dns", Value: "example.com"},
		Status:     acme.StatusValid,
		Expires:    now.Add(24 * time.Hour),
		Challenges: []acme.Challenge{
			{
				Type:      "http-01",
				URL:       "https://example.com/acme/chall/1",
				Status:    acme.StatusValid,
				Validated: "2026-08-28T00:00:00Z",
				Token:     "test-token",
			},
		},
	}

	accJSON, _ := json.Marshal(account)
	orderJSON, _ := json.Marshal(order)
	authzJSON, _ := json.Marshal(authz)

	fmt.Printf("ACME StatusValid constant: %s\n", acme.StatusValid)
	fmt.Printf("Account JSON: %s\n", string(accJSON))
	fmt.Printf("Order JSON: %s\n", string(orderJSON))
	fmt.Printf("Authz JSON: %s\n", string(authzJSON))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/mholt/acmez/v3/acme.StatusValid in pkg:golang/github.com/mholt/acmez/v3@v3.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/mholt/acmez/v3@v3.1.2"
  ],
  "symbols": [
    "github.com/mholt/acmez/v3/acme.StatusValid"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract_test.go
package test

import (
	"encoding/json"
	"testing"
	"time"

	"github.com/mholt/acmez/v3/acme"
)

func TestStatusValidConstant(t *testing.T) {
	if acme.StatusValid != "valid" {
		t.Fatalf("acme.StatusValid = %q, want 'valid'", acme.StatusValid)
	}
}

func TestAccountStatusValid(t *testing.T) {
	acc := acme.Account{
		Status:  acme.StatusValid,
		Contact: []string{"mailto:admin@example.com"},
		Orders:  "https://example.com/acme/acct/1/orders",
	}

	data, err := json.Marshal(acc)
	if err != nil {
		t.Fatalf("json.Marshal failed: %v", err)
	}

	var parsed acme.Account
	if err := json.Unmarshal(data, &parsed); err != nil {
		t.Fatalf("json.Unmarshal failed: %v", err)
	}

	if parsed.Status != acme.StatusValid {
		t.Errorf("parsed.Status = %q, want %q", parsed.Status, acme.StatusValid)
	}
}

func TestOrderStatusValid(t *testing.T) {
	now := time.Now().UTC().Truncate(time.Second)
	order := acme.Order{
		Status:         acme.StatusValid,
		Expires:        now.Add(24 * time.Hour),
		Identifiers:    []acme.Identifier{{Type: "dns", Value: "example.com"}},
		Authorizations: []string{"https://example.com/acme/authz/1"},
		Finalize:       "https://example.com/acme/order/1/finalize",
		Certificate:    "https://example.com/acme/cert/1",
	}

	data, err := json.Marshal(order)
	if err != nil {
		t.Fatalf("json.Marshal failed: %v", err)
	}

	var parsed acme.Order
	if err := json.Unmarshal(data, &parsed); err != nil {
		t.Fatalf("json.Unmarshal failed: %v", err)
	}

	if parsed.Status != acme.StatusValid {
		t.Errorf("parsed.Status = %q, want %q", parsed.Status, acme.StatusValid)
	}
	if parsed.Certificate != "https://example.com/acme/cert/1" {
		t.Errorf("parsed.Certificate = %q, want https://example.com/acme/cert/1", parsed.Certificate)
	}
}

func TestAuthorizationStatusValid(t *testing.T) {
	exp := time.Now().Add(24 * time.Hour).UTC().Truncate(time.Second)
	authz := acme.Authorization{
		Identifier: acme.Identifier{Type: "dns", Value: "example.com"},
		Status:     acme.StatusValid,
		Expires:    exp,
		Challenges: []acme.Challenge{
			{
				Type:      "http-01",
				URL:       "https://example.com/acme/chall/1",
				Status:    acme.StatusValid,
				Validated: "2026-08-28T00:00:00Z",
				Token:     "testToken123",
			},
		},
	}

	data, err := json.Marshal(authz)
	if err != nil {
		t.Fatalf("json.Marshal failed: %v", err)
	}

	var parsed acme.Authorization
	if err := json.Unmarshal(data, &parsed); err != nil {
		t.Fatalf("json.Unmarshal failed: %v", err)
	}

	if parsed.Status != acme.StatusValid {
		t.Errorf("parsed.Status = %q, want %q", parsed.Status, acme.StatusValid)
	}
	if len(parsed.Challenges) != 1 || parsed.Challenges[0].Status != acme.StatusValid {
		t.Errorf("parsed challenge status = %q, want %q", parsed.Challenges[0].Status, acme.StatusValid)
	}
	if parsed.IdentifierValue() != "example.com" {
		t.Errorf("parsed.IdentifierValue() = %q, want example.com", parsed.IdentifierValue())
	}
}

func TestChallengeStatusValid(t *testing.T) {
	chall := acme.Challenge{
		Type:      "http-01",
		URL:       "https://example.com/acme/chall/1",
		Status:    acme.StatusValid,
		Validated: "2026-08-28T00:00:00Z",
		Token:     "token-abc",
	}

	if chall.Status != acme.StatusValid {
		t.Errorf("chall.Status = %q, want %q", chall.Status, acme.StatusValid)
	}
	if chall.HTTP01ResourcePath() != "/.well-known/acme-challenge/token-abc" {
		t.Errorf("chall.HTTP01ResourcePath() = %q, want /.well-known/acme-challenge/token-abc", chall.HTTP01ResourcePath())
	}
}

Seeder d'origine

anonyme