Exemple
github.com/miekg/dns v1.1.63: Msg
Échantillon vérifié pour golang github.com/miekg/dns v1.1.63: Msg. Le contrat s'est exécuté sur go 1.26 · linux debian/x64 · docker et a réussi.
sha256:422ebc8320634ba7669b8b0b47b274c2c70066d88e271a386ba133b8c6bafbdf
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é
linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-04 |
Cas
HOW- Objectif
- verify github.com/miekg/dns.Msg in pkg:golang/github.com/miekg/dns@v1.1.63
- Paquets
- Symboles
-
- github.com/miekg/dns.Msg
- Créé
- 2026-09-04T09:24:47Z
Contrat
- dns.Msg.SetQuestion initializes a query question while resetting message ID and clearing recursion desired flag
- dns.Msg.SetReply creates matching response template preserving question, id, and opcode while setting response and authoritative flags
- dns.Msg.Copy produces deep copy of message preventing cross-mutation of headers and section records
- dns.Msg.SetEdns0 attaches an OPT resource record configuring extended UDP buffer size and DNSSEC OK flags
- dns.Msg.Pack and Unpack perform RFC 1035 wire format encoding and decoding with byte length consistency
Fichiers
- PROMPT.md
- csx.json
- dns_msg.go
- go.mod
- go.sum
- spec.json
- test/contract_test.go
Code source
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/miekg/dns.Msg in pkg:golang/github.com/miekg/dns@v1.1.63
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/miekg/dns@v1.1.63
Demonstrate these symbols/APIs:
- github.com/miekg/dns.Msg
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:5a0f1197ce46b77e2f30a90efbf86438fc6ff33013fe5eb55f9c078ee735e4cd","contract":["dns.Msg.SetQuestion initializes a query question while resetting message ID and clearing recursion desired flag","dns.Msg.SetReply creates matching response template preserving question, id, and opcode while setting response and authoritative flags","dns.Msg.Copy produces deep copy of message preventing cross-mutation of headers and section records","dns.Msg.SetEdns0 attaches an OPT resource record configuring extended UDP buffer size and DNSSEC OK flags","dns.Msg.Pack and Unpack perform RFC 1035 wire format encoding and decoding with byte length consistency"],"goal":"verify github.com/miekg/dns.Msg in pkg:golang/github.com/miekg/dns@v1.1.63","kind":"HOW","packages":["pkg:golang/github.com/miekg/dns@v1.1.63"],"schemaVersion":1,"symbols":["github.com/miekg/dns.Msg"]},"contractCommand":["go","test","-v","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/miekg/dns@v1.1.63"],"schemaVersion":1,"subject":"pkg:golang/github.com/miekg/dns@v1.1.63","symbols":["github.com/miekg/dns.Msg"],"verifierAdapter":"golang@1"}
package dnsmsg
import (
"fmt"
"net"
"github.com/miekg/dns"
)
// BuildQuery creates a DNS query message with a question and recursion desired flag.
// SetQuestion is called first because it re-initializes Id and clears RecursionDesired.
func BuildQuery(domain string, qtype uint16, id uint16) *dns.Msg {
m := new(dns.Msg)
m.SetQuestion(dns.Fqdn(domain), qtype)
m.Id = id
m.RecursionDesired = true
return m
}
// BuildReply creates an authoritative response message matching the provided query,
// appending an A record answer if ip is provided.
func BuildReply(query *dns.Msg, ip net.IP, ttl uint32) (*dns.Msg, error) {
resp := new(dns.Msg)
resp.SetReply(query)
resp.Authoritative = true
if ip != nil && len(query.Question) > 0 {
rr := &dns.A{
Hdr: dns.RR_Header{
Name: query.Question[0].Name,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: ttl,
},
A: ip.To4(),
}
resp.Answer = append(resp.Answer, rr)
}
return resp, nil
}
// ConfigureEDNS0 attaches an OPT record to the message extra section with the specified UDP buffer size and DO flag,
// returning the configured OPT resource record.
func ConfigureEDNS0(msg *dns.Msg, udpSize uint16, dnssecOk bool) *dns.OPT {
msg.SetEdns0(udpSize, dnssecOk)
return msg.IsEdns0()
}
// CloneMessage creates a deep copy of a DNS message.
func CloneMessage(msg *dns.Msg) *dns.Msg {
return msg.Copy()
}
// RoundTripWire serializes a DNS message to RFC 1035 wire format and deserializes it back into a new Msg.
func RoundTripWire(msg *dns.Msg) (*dns.Msg, []byte, error) {
wire, err := msg.Pack()
if err != nil {
return nil, nil, fmt.Errorf("pack error: %w", err)
}
unpacked := new(dns.Msg)
if err := unpacked.Unpack(wire); err != nil {
return nil, nil, fmt.Errorf("unpack error: %w", err)
}
return unpacked, wire, nil
}
module example.com/dnsmsg
go 1.26.6
require (
github.com/miekg/dns v1.1.63
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/tools v0.22.0 // indirect
)
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=
github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
{
"schemaVersion": 1,
"goal": "verify github.com/miekg/dns.Msg in pkg:golang/github.com/miekg/dns@v1.1.63",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/miekg/dns@v1.1.63"
],
"symbols": [
"github.com/miekg/dns.Msg"
]
}
package test
import (
"net"
"testing"
"example.com/dnsmsg"
"github.com/miekg/dns"
)
func TestMsgQueryInitialization(t *testing.T) {
msg := dnsmsg.BuildQuery("example.com", dns.TypeA, 0x1234)
if msg.Id != 0x1234 {
t.Fatalf("expected Id 0x1234, got %d", msg.Id)
}
if !msg.RecursionDesired {
t.Fatalf("expected RecursionDesired true")
}
if msg.Response {
t.Fatalf("expected Response false for query")
}
if len(msg.Question) != 1 {
t.Fatalf("expected 1 question, got %d", len(msg.Question))
}
if msg.Question[0].Name != "example.com." {
t.Errorf("expected FQDN 'example.com.', got %q", msg.Question[0].Name)
}
if msg.Question[0].Qtype != dns.TypeA {
t.Errorf("expected Qtype TypeA, got %d", msg.Question[0].Qtype)
}
if msg.Question[0].Qclass != dns.ClassINET {
t.Errorf("expected Qclass ClassINET, got %d", msg.Question[0].Qclass)
}
}
func TestMsgSetReplyResponseTemplate(t *testing.T) {
query := dnsmsg.BuildQuery("example.com", dns.TypeA, 0x4321)
ip := net.ParseIP("93.184.216.34")
resp, err := dnsmsg.BuildReply(query, ip, 300)
if err != nil {
t.Fatalf("BuildReply failed: %v", err)
}
if !resp.Response {
t.Fatalf("expected Response true on reply")
}
if resp.Id != query.Id {
t.Fatalf("expected reply Id %d matching query Id %d", resp.Id, query.Id)
}
if !resp.Authoritative {
t.Fatalf("expected Authoritative true")
}
if len(resp.Question) != len(query.Question) || resp.Question[0].Name != query.Question[0].Name {
t.Fatalf("question not preserved in reply")
}
if len(resp.Answer) != 1 {
t.Fatalf("expected 1 answer record, got %d", len(resp.Answer))
}
aRecord, ok := resp.Answer[0].(*dns.A)
if !ok {
t.Fatalf("expected *dns.A in answer, got %T", resp.Answer[0])
}
if !aRecord.A.Equal(ip) {
t.Errorf("expected IP %s, got %s", ip, aRecord.A)
}
if aRecord.Hdr.Ttl != 300 {
t.Errorf("expected TTL 300, got %d", aRecord.Hdr.Ttl)
}
}
func TestMsgDeepCopyIsolation(t *testing.T) {
query := dnsmsg.BuildQuery("example.com", dns.TypeA, 0x5555)
ip := net.ParseIP("192.0.2.1")
resp, err := dnsmsg.BuildReply(query, ip, 60)
if err != nil {
t.Fatalf("BuildReply failed: %v", err)
}
cloned := dnsmsg.CloneMessage(resp)
if cloned == nil {
t.Fatalf("CloneMessage returned nil")
}
if cloned.Id != resp.Id {
t.Fatalf("cloned Id mismatch")
}
// Mutate clone and ensure original is unaffected
cloned.Id = 0x9999
cloned.Question[0].Name = "mutated.example.com."
cloned.Answer[0].(*dns.A).A = net.ParseIP("192.0.2.2").To4()
if resp.Id == 0x9999 {
t.Errorf("original Id mutated after clone mutation")
}
if resp.Question[0].Name == "mutated.example.com." {
t.Errorf("original Question mutated after clone mutation")
}
origIP := resp.Answer[0].(*dns.A).A
if origIP.String() != "192.0.2.1" {
t.Errorf("original Answer record mutated after clone mutation")
}
}
func TestMsgEDNS0Configuration(t *testing.T) {
msg := dnsmsg.BuildQuery("example.com", dns.TypeA, 0x7777)
if opt := msg.IsEdns0(); opt != nil {
t.Fatalf("expected no initial EDNS0 record")
}
opt := dnsmsg.ConfigureEDNS0(msg, 4096, true)
if opt == nil {
t.Fatalf("ConfigureEDNS0 returned nil")
}
if opt.UDPSize() != 4096 {
t.Errorf("expected UDPSize 4096, got %d", opt.UDPSize())
}
if !opt.Do() {
t.Errorf("expected DO flag true")
}
retrievedOpt := msg.IsEdns0()
if retrievedOpt == nil {
t.Fatalf("IsEdns0 returned nil after SetEdns0")
}
if retrievedOpt.UDPSize() != 4096 || !retrievedOpt.Do() {
t.Errorf("IsEdns0 did not reflect configured parameters")
}
}
func TestMsgWireSerializationAndRoundTrip(t *testing.T) {
query := dnsmsg.BuildQuery("example.com", dns.TypeAAAA, 0x8888)
dnsmsg.ConfigureEDNS0(query, 2048, false)
unpacked, wire, err := dnsmsg.RoundTripWire(query)
if err != nil {
t.Fatalf("RoundTripWire failed: %v", err)
}
if len(wire) == 0 {
t.Fatalf("wire slice is empty")
}
if query.Len() != len(wire) {
t.Errorf("expected wire length %d to match msg.Len() %d", len(wire), query.Len())
}
if unpacked.Id != query.Id {
t.Errorf("unpacked Id %d != original %d", unpacked.Id, query.Id)
}
if len(unpacked.Question) != 1 || unpacked.Question[0].Name != "example.com." {
t.Errorf("unpacked Question mismatch")
}
if unpacked.Question[0].Qtype != dns.TypeAAAA {
t.Errorf("unpacked Qtype mismatch")
}
unpackedOpt := unpacked.IsEdns0()
if unpackedOpt == nil {
t.Fatalf("unpacked EDNS0 record missing")
}
if unpackedOpt.UDPSize() != 2048 {
t.Errorf("expected unpacked UDPSize 2048, got %d", unpackedOpt.UDPSize())
}
if unpackedOpt.Do() {
t.Errorf("expected DO flag false in unpacked OPT")
}
}
Seeder d'origine
anonyme