샘플
github.com/quic-go/go-ossfuzz-seeds v0.1.0: Helper.Add
검증된 샘플 — golang github.com/quic-go/go-ossfuzz-seeds v0.1.0: Helper.Add. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:8f53ba8af150715939606787b9f4213de514fabd0ced280a1d07d97c1fc7a2a7
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go 1.26 go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-05 |
케이스
HOW- 목표
- verify github.com/quic-go/go-ossfuzz-seeds.Helper.Add in pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0
- 심벌
-
- github.com/quic-go/go-ossfuzz-seeds.Helper.Add
- 환경
- go 1.26.6
- 생성일
- 2026-09-05T13:34:19Z
컨트랙트
- Helper.Add forwards seed arguments to testing.F without creating files when FUZZ_CORPUS_DIR is unset
- Helper.Add creates a corpus entry file in FUZZ_CORPUS_DIR when enabled
- Helper.Add uses the first 8 bytes of SHA-256 hash in hex as the corpus filename
- Helper.Add writes corpus files with 0644 permissions
- Helper.Add writes binary content matching OSS-Fuzz corpus entry serialization for mixed arguments
- Helper.Add skips file creation when dynamic argument lengths exceed encoding capacity
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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/quic-go/go-ossfuzz-seeds.Helper.Add in pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0
Demonstrate these symbols/APIs:
- github.com/quic-go/go-ossfuzz-seeds.Helper.Add
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:1d68b5b58c1004764d70d108a506377ac5326cb3c172cf5bc6a3b0be7fd72305","contract":["Helper.Add forwards seed arguments to testing.F without creating files when FUZZ_CORPUS_DIR is unset","Helper.Add creates a corpus entry file in FUZZ_CORPUS_DIR when enabled","Helper.Add uses the first 8 bytes of SHA-256 hash in hex as the corpus filename","Helper.Add writes corpus files with 0644 permissions","Helper.Add writes binary content matching OSS-Fuzz corpus entry serialization for mixed arguments","Helper.Add skips file creation when dynamic argument lengths exceed encoding capacity"],"goal":"verify github.com/quic-go/go-ossfuzz-seeds.Helper.Add in pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0","kind":"HOW","packages":["pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0"],"schemaVersion":1,"symbols":["github.com/quic-go/go-ossfuzz-seeds.Helper.Add"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","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","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0","symbols":["github.com/quic-go/go-ossfuzz-seeds.Helper.Add"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require github.com/quic-go/go-ossfuzz-seeds v0.1.0
github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0=
github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk=
package main
import (
"fmt"
"os"
"testing"
ossfuzzseeds "github.com/quic-go/go-ossfuzz-seeds"
)
func main() {
testing.Init()
corpusDir := os.Getenv("FUZZ_CORPUS_DIR")
if corpusDir == "" {
corpusDir = "./corpus"
os.Setenv("FUZZ_CORPUS_DIR", corpusDir)
defer os.RemoveAll(corpusDir)
}
f := &testing.F{}
h := ossfuzzseeds.New(f)
// Demonstrate Helper.Add with both fixed-size and dynamic-size seed values
h.Add(uint16(42), "example-seed", []byte("fuzz-payload"))
fmt.Printf("Seed added to corpus directory %s\n", corpusDir)
}
{
"schemaVersion": 1,
"goal": "verify github.com/quic-go/go-ossfuzz-seeds.Helper.Add in pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/quic-go/go-ossfuzz-seeds@v0.1.0"
],
"symbols": [
"github.com/quic-go/go-ossfuzz-seeds.Helper.Add"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"os"
"path/filepath"
"testing"
ossfuzzseeds "github.com/quic-go/go-ossfuzz-seeds"
)
func main() {
testing.Init()
if err := runContract(); err != nil {
fmt.Fprintf(os.Stderr, "Contract failed: %v\n", err)
os.Exit(1)
}
fmt.Println("All contract assertions passed.")
}
func runContract() error {
// Assertion 1: Helper.Add forwards seed arguments to testing.F without creating files when FUZZ_CORPUS_DIR is unset
{
os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
if h == nil {
return errors.New("assertion 1 failed: New returned nil")
}
h.Add(uint8(42), "seed-no-corpus")
}
tmpDir, err := os.MkdirTemp("", "csx-add-contract-*")
if err != nil {
return fmt.Errorf("failed to create temp dir: %w", err)
}
defer os.RemoveAll(tmpDir)
// Assertion 2: Helper.Add creates a corpus entry file in FUZZ_CORPUS_DIR when enabled
corpusDir2 := filepath.Join(tmpDir, "corpus2")
{
os.Setenv("FUZZ_CORPUS_DIR", corpusDir2)
defer os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
h.Add(int32(100), "sample-seed")
entries, err := os.ReadDir(corpusDir2)
if err != nil {
return fmt.Errorf("assertion 2 failed: ReadDir failed: %w", err)
}
if len(entries) != 1 {
return fmt.Errorf("assertion 2 failed: expected 1 file, found %d", len(entries))
}
}
// Assertion 3: Helper.Add uses the first 8 bytes of SHA-256 hash in hex as the corpus filename
corpusDir3 := filepath.Join(tmpDir, "corpus3")
{
os.Setenv("FUZZ_CORPUS_DIR", corpusDir3)
defer os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
args := []any{uint64(999), "hash-filename-test"}
h.Add(args...)
expectedBytes, err := ossfuzzseeds.CorpusEntry(args...)
if err != nil {
return fmt.Errorf("assertion 3 failed: CorpusEntry serialization error: %w", err)
}
hash := sha256.Sum256(expectedBytes)
expectedFilename := hex.EncodeToString(hash[:8])
entries, err := os.ReadDir(corpusDir3)
if err != nil || len(entries) != 1 {
return fmt.Errorf("assertion 3 failed: expected 1 entry, got %v: %w", entries, err)
}
if entries[0].Name() != expectedFilename {
return fmt.Errorf("assertion 3 failed: filename mismatch, got %s, want %s", entries[0].Name(), expectedFilename)
}
if len(entries[0].Name()) != 16 {
return fmt.Errorf("assertion 3 failed: filename length should be 16, got %d", len(entries[0].Name()))
}
}
// Assertion 4: Helper.Add writes corpus files with 0644 permissions
corpusDir4 := filepath.Join(tmpDir, "corpus4")
{
os.Setenv("FUZZ_CORPUS_DIR", corpusDir4)
defer os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
h.Add(true, uint16(55))
entries, err := os.ReadDir(corpusDir4)
if err != nil || len(entries) != 1 {
return fmt.Errorf("assertion 4 failed: expected 1 entry in %s: %w", corpusDir4, err)
}
info, err := entries[0].Info()
if err != nil {
return fmt.Errorf("assertion 4 failed: stat error: %w", err)
}
if info.Mode().Perm() != 0o644 {
return fmt.Errorf("assertion 4 failed: expected mode 0644, got %v", info.Mode().Perm())
}
}
// Assertion 5: Helper.Add writes binary content matching OSS-Fuzz corpus entry serialization for mixed arguments
corpusDir5 := filepath.Join(tmpDir, "corpus5")
{
os.Setenv("FUZZ_CORPUS_DIR", corpusDir5)
defer os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
args := []any{uint8(3), int64(1000), "prefix", []byte{0xde, 0xad, 0xbe, 0xef}}
h.Add(args...)
expectedBytes, err := ossfuzzseeds.CorpusEntry(args...)
if err != nil {
return fmt.Errorf("assertion 5 failed: CorpusEntry serialization error: %w", err)
}
entries, err := os.ReadDir(corpusDir5)
if err != nil || len(entries) != 1 {
return fmt.Errorf("assertion 5 failed: expected 1 file, found %v: %w", entries, err)
}
content, err := os.ReadFile(filepath.Join(corpusDir5, entries[0].Name()))
if err != nil {
return fmt.Errorf("assertion 5 failed: ReadFile failed: %w", err)
}
if !bytes.Equal(content, expectedBytes) {
return fmt.Errorf("assertion 5 failed: content mismatch, got %x, want %x", content, expectedBytes)
}
}
// Assertion 6: Helper.Add skips file creation when dynamic argument lengths exceed encoding capacity
corpusDir6 := filepath.Join(tmpDir, "corpus6")
{
os.Setenv("FUZZ_CORPUS_DIR", corpusDir6)
defer os.Unsetenv("FUZZ_CORPUS_DIR")
f := &testing.F{}
h := ossfuzzseeds.New(f)
// dynamicSizeWeights fails on lengths {1, 1, 100000}
h.Add(make([]byte, 1), make([]byte, 1), make([]byte, 100000))
entries, err := os.ReadDir(corpusDir6)
if err != nil {
return fmt.Errorf("assertion 6 failed: ReadDir failed: %w", err)
}
if len(entries) != 0 {
return fmt.Errorf("assertion 6 failed: expected 0 files on unencodable dynamic lengths, found %d", len(entries))
}
}
return nil
}
오리진 시더
익명