Sample
github.com/miekg/dns v1.1.63
Verified sample for golang github.com/miekg/dns v1.1.63. The contract ran on go 1.26 · linux alpine/x64 · docker and passed: dns.Msg.SetQuestion constructs…
sha256:87155f93cfe91ba4949994767053ea25ce7c66b5ca50abebdd2cf48ee2bfb84e
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-23 |
Case
HOW- Goal
- verify pkg:golang/github.com/miekg/dns@v1.1.63
- Packages
- Created
- 2026-08-23T17:11:07Z
Contract
- dns.Msg.SetQuestion constructs standard DNS query question with FQDN and query type
- dns.Msg.Pack encodes DNS message into RFC 1035 binary wire format
- dns.Msg.Unpack decodes RFC 1035 binary wire format back into DNS message structure
- dns.NewRR parses zone file format resource records into typed RR structures including A, TXT, and MX
Files
- PROMPT.md
- csx.json
- dns_sample.go
- go.mod
- go.sum
- spec.json
- test/contract_test.go
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 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
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.
{"case":{"caseId":"case:sha256:0b2a014d4a07de7ee422aef5457b11a1dfb275083d3a043d19d9d8d9183a07de","contract":["dns.Msg.SetQuestion constructs standard DNS query question with FQDN and query type","dns.Msg.Pack encodes DNS message into RFC 1035 binary wire format","dns.Msg.Unpack decodes RFC 1035 binary wire format back into DNS message structure","dns.NewRR parses zone file format resource records into typed RR structures including A, TXT, and MX"],"goal":"verify pkg:golang/github.com/miekg/dns@v1.1.63","kind":"HOW","packages":["pkg:golang/github.com/miekg/dns@v1.1.63"],"schemaVersion":1,"symbols":["dns.Msg.SetQuestion","dns.Msg.Pack","dns.Msg.Unpack","dns.NewRR"]},"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","verifierAdapter":"golang@1"}
package dnssample
import (
"fmt"
"net"
"github.com/miekg/dns"
)
// BuildQuery creates a DNS query message for the specified domain and record type.
func BuildQuery(domain string, qtype uint16, recursionDesired bool) *dns.Msg {
m := new(dns.Msg)
m.SetQuestion(dns.Fqdn(domain), qtype)
m.RecursionDesired = recursionDesired
return m
}
// PackAndUnpack serializes a DNS message to wire format and deserializes it back.
func PackAndUnpack(msg *dns.Msg) (*dns.Msg, []byte, error) {
wire, err := msg.Pack()
if err != nil {
return nil, nil, fmt.Errorf("pack failed: %w", err)
}
unpacked := new(dns.Msg)
if err := unpacked.Unpack(wire); err != nil {
return nil, nil, fmt.Errorf("unpack failed: %w", err)
}
return unpacked, wire, nil
}
// BuildResponse creates a response message answering an A query for domain with given IP and TTL.
func BuildResponse(query *dns.Msg, ip string, ttl uint32) (*dns.Msg, error) {
resp := new(dns.Msg)
resp.SetReply(query)
resp.Authoritative = true
qName := query.Question[0].Name
rrStr := fmt.Sprintf("%s %d IN A %s", qName, ttl, ip)
rr, err := dns.NewRR(rrStr)
if err != nil {
return nil, fmt.Errorf("failed to parse A record: %w", err)
}
resp.Answer = append(resp.Answer, rr)
return resp, nil
}
// ParseResourceRecord parses an RFC 1035 zone file formatted RR string.
func ParseResourceRecord(recordStr string) (dns.RR, error) {
rr, err := dns.NewRR(recordStr)
if err != nil {
return nil, fmt.Errorf("failed to parse RR: %w", err)
}
return rr, nil
}
// ParseIPv4Extract returns the net.IP from an A resource record.
func ParseIPv4Extract(rr dns.RR) (net.IP, error) {
aRecord, ok := rr.(*dns.A)
if !ok {
return nil, fmt.Errorf("record is not an A record: %T", rr)
}
return aRecord.A, nil
}
module example.com/dnssample
go 1.26.6
require (
github.com/miekg/dns v1.1.63 // indirect
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 pkg:golang/github.com/miekg/dns@v1.1.63",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/miekg/dns@v1.1.63"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"testing"
"example.com/dnssample"
"github.com/miekg/dns"
)
func TestDNSQueryBuildAndWireSerialization(t *testing.T) {
domain := "example.com"
query := dnssample.BuildQuery(domain, dns.TypeA, true)
if len(query.Question) != 1 {
t.Fatalf("expected 1 question, got %d", len(query.Question))
}
if query.Question[0].Name != "example.com." {
t.Fatalf("expected FQDN 'example.com.', got '%s'", query.Question[0].Name)
}
if query.Question[0].Qtype != dns.TypeA {
t.Fatalf("expected Qtype TypeA, got %d", query.Question[0].Qtype)
}
if query.Question[0].Qclass != dns.ClassINET {
t.Fatalf("expected Qclass ClassINET, got %d", query.Question[0].Qclass)
}
if !query.RecursionDesired {
t.Fatalf("expected RecursionDesired to be true")
}
unpacked, wire, err := dnssample.PackAndUnpack(query)
if err != nil {
t.Fatalf("PackAndUnpack failed: %v", err)
}
if len(wire) == 0 {
t.Fatalf("expected non-empty wire bytes")
}
if unpacked.Id != query.Id {
t.Fatalf("unpacked Id %d does not match original %d", unpacked.Id, query.Id)
}
if unpacked.Question[0].Name != "example.com." {
t.Fatalf("unpacked question name mismatch: %s", unpacked.Question[0].Name)
}
if unpacked.Question[0].Qtype != dns.TypeA {
t.Fatalf("unpacked question type mismatch: %d", unpacked.Question[0].Qtype)
}
}
func TestDNSResponseAndResourceRecordParsing(t *testing.T) {
query := dnssample.BuildQuery("example.com", dns.TypeA, true)
expectedIP := "93.184.216.34"
var expectedTTL uint32 = 300
resp, err := dnssample.BuildResponse(query, expectedIP, expectedTTL)
if err != nil {
t.Fatalf("BuildResponse failed: %v", err)
}
if !resp.Response {
t.Fatalf("expected Response flag to be true")
}
if !resp.Authoritative {
t.Fatalf("expected Authoritative flag to be true")
}
if len(resp.Answer) != 1 {
t.Fatalf("expected 1 answer RR, got %d", len(resp.Answer))
}
ip, err := dnssample.ParseIPv4Extract(resp.Answer[0])
if err != nil {
t.Fatalf("ParseIPv4Extract failed: %v", err)
}
if ip.String() != expectedIP {
t.Fatalf("expected IP %s, got %s", expectedIP, ip.String())
}
unpackedResp, _, err := dnssample.PackAndUnpack(resp)
if err != nil {
t.Fatalf("PackAndUnpack response failed: %v", err)
}
if len(unpackedResp.Answer) != 1 {
t.Fatalf("expected 1 answer in unpacked response, got %d", len(unpackedResp.Answer))
}
unpackedIP, err := dnssample.ParseIPv4Extract(unpackedResp.Answer[0])
if err != nil {
t.Fatalf("failed extracting IP from unpacked answer: %v", err)
}
if unpackedIP.String() != expectedIP {
t.Fatalf("expected unpacked IP %s, got %s", expectedIP, unpackedIP.String())
}
}
func TestParseMultipleResourceRecordTypes(t *testing.T) {
txtStr := "example.com. 3600 IN TXT \"v=spf1 include:_spf.example.com ~all\""
rrTxt, err := dnssample.ParseResourceRecord(txtStr)
if err != nil {
t.Fatalf("failed parsing TXT record: %v", err)
}
txtRecord, ok := rrTxt.(*dns.TXT)
if !ok {
t.Fatalf("expected *dns.TXT, got %T", rrTxt)
}
if len(txtRecord.Txt) != 1 || txtRecord.Txt[0] != "v=spf1 include:_spf.example.com ~all" {
t.Fatalf("unexpected TXT content: %v", txtRecord.Txt)
}
mxStr := "example.com. 3600 IN MX 10 mail.example.com."
rrMx, err := dnssample.ParseResourceRecord(mxStr)
if err != nil {
t.Fatalf("failed parsing MX record: %v", err)
}
mxRecord, ok := rrMx.(*dns.MX)
if !ok {
t.Fatalf("expected *dns.MX, got %T", rrMx)
}
if mxRecord.Preference != 10 || mxRecord.Mx != "mail.example.com." {
t.Fatalf("unexpected MX values: pref=%d mx=%s", mxRecord.Preference, mxRecord.Mx)
}
invalidStr := "not-a-valid-dns-rr-format"
_, err = dnssample.ParseResourceRecord(invalidStr)
if err == nil {
t.Fatalf("expected error parsing invalid RR string, got nil")
}
}
Origin Seeder
anonymous