Exemple
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99: profile.ParseProcMaps
Échantillon vérifié pour golang github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99: profile.ParseProcMaps. Le contrat s'est exécuté sur go 1.26 …
sha256:8a6722365c7cc2dbfe871559563279808392cdbdad01a2278f250cccd653b31d
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 x64 go
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-21 |
Cas
HOW- Objectif
- verify github.com/google/pprof/profile.ParseProcMaps in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
- Symboles
-
- github.com/google/pprof/profile.ParseProcMaps
- Créé
- 2026-09-21T03:08:50Z
Contrat
- ParseProcMaps parses standard Linux /proc/self/maps lines with executable permissions into Mapping objects with Start, Limit, Offset, and File
- ParseProcMaps filters out non-executable mappings that lack execute permission flag
- ParseProcMaps supports brief map syntax containing memory range, file path, offset annotation, and build ID
- ParseProcMaps strips glog-style logging prefixes before parsing memory map entries
- ParseProcMaps substitutes attribute variables defined on preceding lines using key=value syntax into subsequent mapping entries
- ParseProcMaps returns an empty slice without error for empty input or input with no valid executable mappings
Fichiers
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.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/google/pprof/profile.ParseProcMaps in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99
Demonstrate these symbols/APIs:
- github.com/google/pprof/profile.ParseProcMaps
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:94d0985a26213c2759f91be27a09543509265a4cdc0d2eba48e31b56c17378c0","contract":["ParseProcMaps parses standard Linux /proc/self/maps lines with executable permissions into Mapping objects with Start, Limit, Offset, and File","ParseProcMaps filters out non-executable mappings that lack execute permission flag","ParseProcMaps supports brief map syntax containing memory range, file path, offset annotation, and build ID","ParseProcMaps strips glog-style logging prefixes before parsing memory map entries","ParseProcMaps substitutes attribute variables defined on preceding lines using key=value syntax into subsequent mapping entries","ParseProcMaps returns an empty slice without error for empty input or input with no valid executable mappings"],"goal":"verify github.com/google/pprof/profile.ParseProcMaps in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99","kind":"HOW","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99"],"schemaVersion":1,"symbols":["github.com/google/pprof/profile.ParseProcMaps"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99"],"schemaVersion":1,"subject":"pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99","symbols":["github.com/google/pprof/profile.ParseProcMaps"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99 h1:Ak8CrdlwwXwAZxzS66vgPt4U8yUZX7JwLvVR58FN5jM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
package main
import (
"fmt"
"strings"
"github.com/google/pprof/profile"
)
func main() {
sampleMaps := "7f7472710000-7f7472722000 r-xp 00000000 fc:00 790190 /usr/lib/libsample.so\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(sampleMaps))
if err != nil {
fmt.Printf("ParseProcMaps error: %v\n", err)
return
}
for _, m := range mappings {
fmt.Printf("Mapping: %s [0x%x-0x%x]\n", m.File, m.Start, m.Limit)
}
}
{
"schemaVersion": 1,
"goal": "verify github.com/google/pprof/profile.ParseProcMaps in pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/google/pprof@v0.0.0-20200708004538-1a94d8640e99"
],
"symbols": [
"github.com/google/pprof/profile.ParseProcMaps"
]
}
package main
import (
"bytes"
"fmt"
"os"
"strings"
"github.com/google/pprof/profile"
)
func main() {
if err := runTests(); err != nil {
fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
os.Exit(1)
}
fmt.Println("PASS: all ParseProcMaps contract assertions passed")
}
func runTests() error {
// Assertion 1: ParseProcMaps parses standard Linux /proc/self/maps lines with executable permissions into Mapping objects with Start, Limit, Offset, and File
{
input := "7f7472710000-7f7472722000 r-xp 00001000 fc:00 790190 /usr/lib/libexample.so\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(input))
if err != nil {
return fmt.Errorf("assertion 1 failed: unexpected error: %w", err)
}
if len(mappings) != 1 {
return fmt.Errorf("assertion 1 failed: expected 1 mapping, got %d", len(mappings))
}
m := mappings[0]
if m.Start != 0x7f7472710000 {
return fmt.Errorf("assertion 1 failed: expected Start 0x7f7472710000, got 0x%x", m.Start)
}
if m.Limit != 0x7f7472722000 {
return fmt.Errorf("assertion 1 failed: expected Limit 0x7f7472722000, got 0x%x", m.Limit)
}
if m.Offset != 0x1000 {
return fmt.Errorf("assertion 1 failed: expected Offset 0x1000, got 0x%x", m.Offset)
}
if m.File != "/usr/lib/libexample.so" {
return fmt.Errorf("assertion 1 failed: expected File /usr/lib/libexample.so, got %q", m.File)
}
}
// Assertion 2: ParseProcMaps filters out non-executable mappings that lack execute permission flag
{
input := "7f5e5435e000-7f5e5455e000 rw-p 00002000 00:00 1531 /usr/lib/data.bin\n" +
"7f5e5455e000-7f5e5475e000 ---p 00004000 00:00 1532 /usr/lib/guard.bin\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(input))
if err != nil {
return fmt.Errorf("assertion 2 failed: unexpected error: %w", err)
}
if len(mappings) != 0 {
return fmt.Errorf("assertion 2 failed: expected 0 executable mappings, got %d", len(mappings))
}
}
// Assertion 3: ParseProcMaps supports brief map syntax containing memory range, file path, offset annotation, and build ID
{
input := "0x40000-0x80000 /path/to/binary (@FF00) abc123456\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(input))
if err != nil {
return fmt.Errorf("assertion 3 failed: unexpected error: %w", err)
}
if len(mappings) != 1 {
return fmt.Errorf("assertion 3 failed: expected 1 mapping, got %d", len(mappings))
}
m := mappings[0]
if m.Start != 0x40000 || m.Limit != 0x80000 {
return fmt.Errorf("assertion 3 failed: expected range [0x40000-0x80000], got [0x%x-0x%x]", m.Start, m.Limit)
}
if m.Offset != 0xFF00 {
return fmt.Errorf("assertion 3 failed: expected Offset 0xFF00, got 0x%x", m.Offset)
}
if m.File != "/path/to/binary" {
return fmt.Errorf("assertion 3 failed: expected File /path/to/binary, got %q", m.File)
}
if m.BuildID != "abc123456" {
return fmt.Errorf("assertion 3 failed: expected BuildID abc123456, got %q", m.BuildID)
}
}
// Assertion 4: ParseProcMaps strips glog-style logging prefixes before parsing memory map entries
{
input := "W1220 15:07:15.201776 8272 logger.cc:12033] 0x40000-0x80000 /path/to/binary (@FF00) abc123456\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(input))
if err != nil {
return fmt.Errorf("assertion 4 failed: unexpected error: %w", err)
}
if len(mappings) != 1 {
return fmt.Errorf("assertion 4 failed: expected 1 mapping, got %d", len(mappings))
}
m := mappings[0]
if m.Start != 0x40000 || m.Limit != 0x80000 || m.File != "/path/to/binary" || m.BuildID != "abc123456" {
return fmt.Errorf("assertion 4 failed: unexpected mapping content: %+v", m)
}
}
// Assertion 5: ParseProcMaps substitutes attribute variables defined on preceding lines using key=value syntax into subsequent mapping entries
{
input := "buildid=deadbeef1234\n" +
"0x40000-0x80000 /path/to/binary (@FF00) $buildid\n"
mappings, err := profile.ParseProcMaps(strings.NewReader(input))
if err != nil {
return fmt.Errorf("assertion 5 failed: unexpected error: %w", err)
}
if len(mappings) != 1 {
return fmt.Errorf("assertion 5 failed: expected 1 mapping, got %d", len(mappings))
}
m := mappings[0]
if m.BuildID != "deadbeef1234" {
return fmt.Errorf("assertion 5 failed: expected BuildID 'deadbeef1234', got %q", m.BuildID)
}
}
// Assertion 6: ParseProcMaps returns an empty slice without error for empty input or input with no valid executable mappings
{
mappings, err := profile.ParseProcMaps(bytes.NewReader(nil))
if err != nil {
return fmt.Errorf("assertion 6 failed: unexpected error on empty input: %w", err)
}
if len(mappings) != 0 {
return fmt.Errorf("assertion 6 failed: expected 0 mappings, got %d", len(mappings))
}
}
return nil
}
Seeder d'origine
anonyme