| 1 | package checks |
| 2 | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "context" |
| 6 | "database/sql" |
| 7 | "fmt" |
| 8 | "io" |
| 9 | "os" |
| 10 | "path/filepath" |
| 11 | "slices" |
| 12 | "sync" |
| 13 | "time" |
| 14 | |
| 15 | "amadan.net/oficina/equipo/internal/equipo/team" |
| 16 | "amadan.net/oficina/equipo/internal/runner/provider" |
| 17 | "amadan.net/oficina/equipo/internal/runnerproto" |
| 18 | ) |
| 19 | |
| 20 | type CommandSandbox interface { |
| 21 | Run(context.Context, Command, string, provider.ReadPolicy, io.Writer, io.Writer) (int, error) |
| 22 | } |
| 23 | type Config struct { |
| 24 | RenderRecipeHash string |
| 25 | ResolveCandidate func(context.Context, string) (team.GitCandidate, error) |
| 26 | Reproduction func(context.Context, string) (Reproduction, error) |
| 27 | ScratchRoot string |
| 28 | Scope team.Scope |
| 29 | Handle team.Handle |
| 30 | Deadline time.Time |
| 31 | Policy provider.ReadPolicy |
| 32 | DefinitionHash, ReproductionHash string |
| 33 | Export func(context.Context, string, string) error |
| 34 | Isolation func(context.Context) (team.IsolationSnapshot, error) |
| 35 | } |
| 36 | type AttestationStore interface { |
| 37 | SaveAttestation(context.Context, string, team.Provenance) error |
| 38 | LoadAttestation(context.Context, string) (team.Provenance, error) |
| 39 | } |
| 40 | |
| 41 | func AttestationKey(scope team.Scope, h team.Handle, spec team.ArtifactSpec) string { |
| 42 | return runnerproto.EventHash([]any{scope, h.Attempt, h.Fence, h.Runner, spec.Role, Digest(spec.Payload)}) |
| 43 | } |
| 44 | func (e *Executor) SetAttestationStore(store AttestationStore) { |
| 45 | e.mu.Lock() |
| 46 | defer e.mu.Unlock() |
| 47 | e.store = store |
| 48 | } |
| 49 | |
| 50 | type Executor struct { |
| 51 | store AttestationStore |
| 52 | exposure team.IsolationSnapshot |
| 53 | logs map[string][]byte |
| 54 | cfg Config |
| 55 | sandbox CommandSandbox |
| 56 | mu sync.Mutex |
| 57 | binary, version string |
| 58 | } |
| 59 | |
| 60 | func New(cfg Config, sandbox *CodexSandbox) (*Executor, error) { |
| 61 | if sandbox == nil || !filepath.IsAbs(sandbox.binary) || sandbox.version != CodexVersion || !filepath.IsAbs(sandbox.goBinary) || !filepath.IsAbs(sandbox.goRoot) || sandbox.goVersion != GoVersion || len(sandbox.protected) < 9 { |
| 62 | return nil, provider.ErrContract |
| 63 | } |
| 64 | e, err := newExecutor(cfg, sandbox) |
| 65 | if err == nil { |
| 66 | e.binary = sandbox.binary |
| 67 | e.version = sandbox.version |
| 68 | } |
| 69 | return e, err |
| 70 | } |
| 71 | func newExecutor(cfg Config, sandbox CommandSandbox) (*Executor, error) { |
| 72 | if sandbox == nil || cfg.Export == nil || cfg.ResolveCandidate == nil || cfg.Reproduction == nil || cfg.Isolation == nil || !filepath.IsAbs(cfg.ScratchRoot) || cfg.Policy.ConfigHash == "" || len(cfg.Policy.DeniedPaths) == 0 || cfg.Deadline.IsZero() { |
| 73 | return nil, provider.ErrContract |
| 74 | } |
| 75 | return &Executor{cfg: cfg, sandbox: sandbox, logs: map[string][]byte{}}, nil |
| 76 | } |
| 77 | func (e *Executor) scratch(ctx context.Context, commit string) (string, func(), error) { |
| 78 | root, err := os.MkdirTemp(e.cfg.ScratchRoot, "checks-") |
| 79 | if err != nil { |
| 80 | return "", nil, err |
| 81 | } |
| 82 | work := filepath.Join(root, "work") |
| 83 | cleanup := func() { |
| 84 | if sandbox, ok := e.sandbox.(interface{ Contained(string) bool }); ok && !sandbox.Contained(work) { |
| 85 | return |
| 86 | } |
| 87 | _ = os.RemoveAll(root) |
| 88 | } |
| 89 | if err = e.cfg.Export(ctx, commit, work); err != nil { |
| 90 | cleanup() |
| 91 | return "", nil, err |
| 92 | } |
| 93 | // Reject symlinks anywhere in an immutable export, before installing any trusted bytes. |
| 94 | err = filepath.WalkDir(work, func(_ string, d os.DirEntry, err error) error { |
| 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | if d.Type()&os.ModeSymlink != 0 || !d.IsDir() && !d.Type().IsRegular() { |
| 99 | return provider.ErrPolicy |
| 100 | } |
| 101 | return nil |
| 102 | }) |
| 103 | if err != nil { |
| 104 | cleanup() |
| 105 | return "", nil, err |
| 106 | } |
| 107 | return work, cleanup, nil |
| 108 | } |
| 109 | func (e *Executor) definition(ctx context.Context, d Definition, pinned bool) error { |
| 110 | parsed, err := ParseDefinition(ctx, encode(d), d.Repository, d.Base) |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | if pinned && (Digest(encode(parsed)) != e.cfg.DefinitionHash || d.Baseline.Hash != setHash(d.Baseline.Names) || len(d.Baseline.Names) == 0) { |
| 115 | return provider.ErrIdentity |
| 116 | } |
| 117 | return nil |
| 118 | } |
| 119 | func (e *Executor) material(d Definition, work string) error { |
| 120 | for _, p := range d.TestFiles { |
| 121 | if err := safePath(work, p, false); err != nil { |
| 122 | return err |
| 123 | } |
| 124 | st, err := os.Stat(filepath.Join(work, p)) |
| 125 | if err != nil || !st.Mode().IsRegular() { |
| 126 | return provider.ErrIdentity |
| 127 | } |
| 128 | } |
| 129 | for _, path := range materialPaths(d) { |
| 130 | if err := safePath(work, path, true); err != nil { |
| 131 | return err |
| 132 | } |
| 133 | if err := os.RemoveAll(filepath.Join(work, path)); err != nil { |
| 134 | return err |
| 135 | } |
| 136 | } |
| 137 | for _, f := range d.Files { |
| 138 | if err := safePath(work, f.Path, true); err != nil { |
| 139 | return err |
| 140 | } |
| 141 | p := filepath.Join(work, f.Path) |
| 142 | if err := os.MkdirAll(filepath.Dir(p), 0700); err != nil { |
| 143 | return err |
| 144 | } |
| 145 | if err := os.WriteFile(p, f.Bytes, 0700); err != nil { |
| 146 | return err |
| 147 | } |
| 148 | } |
| 149 | return nil |
| 150 | } |
| 151 | func (e *Executor) overlay(ctx context.Context, d Definition, r Reproduction, work string) error { |
| 152 | if len(r.Files) == 0 || len(r.TestNames) == 0 || len(r.ExpectedSymptom) == 0 || len(r.ExpectedSymptom) > 4096 || len(encode(r)) > team.MaxArtifactBytes || Digest(encode(r)) != e.cfg.ReproductionHash { |
| 153 | return provider.ErrIdentity |
| 154 | } |
| 155 | if err := filesValid(r.Files, true); err != nil { |
| 156 | return err |
| 157 | } |
| 158 | base, cleanup, err := e.scratch(ctx, d.Base) |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | defer cleanup() |
| 163 | for _, f := range r.Files { |
| 164 | if err := safePath(work, f.Path, true); err != nil { |
| 165 | return err |
| 166 | } |
| 167 | if err := safePath(base, f.Path, true); err != nil { |
| 168 | return err |
| 169 | } |
| 170 | p := filepath.Join(work, f.Path) |
| 171 | current, err := os.ReadFile(p) |
| 172 | if err == nil && !bytes.Equal(current, f.Bytes) { |
| 173 | original, err := os.ReadFile(filepath.Join(base, f.Path)) |
| 174 | if err != nil || !bytes.Equal(original, current) { |
| 175 | return provider.ErrIdentity |
| 176 | } |
| 177 | } else if err != nil && !os.IsNotExist(err) { |
| 178 | return err |
| 179 | } |
| 180 | if err := os.MkdirAll(filepath.Dir(p), 0700); err != nil { |
| 181 | return err |
| 182 | } |
| 183 | if err := os.WriteFile(p, f.Bytes, 0600); err != nil { |
| 184 | return err |
| 185 | } |
| 186 | } |
| 187 | return nil |
| 188 | } |
| 189 | func (e *Executor) run(ctx context.Context, c Command, work, symptom string) (*goResults, int, string, error) { |
| 190 | end := time.Now().Add(time.Duration(c.TimeoutSeconds) * time.Second) |
| 191 | if e.cfg.Deadline.Before(end) { |
| 192 | end = e.cfg.Deadline |
| 193 | } |
| 194 | ctx, cancel := context.WithDeadline(ctx, end) |
| 195 | defer cancel() |
| 196 | if err := safeDir(work, c.Dir); err != nil { |
| 197 | return nil, 0, "", err |
| 198 | } |
| 199 | result := newGoResults() |
| 200 | result.symptom = symptom |
| 201 | var out, stderr boundedLog |
| 202 | var writer io.Writer = &out |
| 203 | if c.Parser == "go-test-json" { |
| 204 | writer = io.MultiWriter(result, &out) |
| 205 | } |
| 206 | code, err := e.sandbox.Run(ctx, c, work, e.cfg.Policy, writer, &stderr) |
| 207 | if ctx.Err() != nil { |
| 208 | err = ctx.Err() |
| 209 | } |
| 210 | logHash := e.saveLog(encode(struct { |
| 211 | Stdout, Stderr []byte |
| 212 | StdoutHash, StderrHash string |
| 213 | }{out.Bytes(), stderr.Bytes(), out.digest(), stderr.digest()})) |
| 214 | if c.Parser == "go-test-json" { |
| 215 | err = result.finish(code, err) |
| 216 | } else if err == nil && code != 0 { |
| 217 | err = provider.ErrContract |
| 218 | } |
| 219 | if err != nil { |
| 220 | err = fmt.Errorf("%w: check %q (exit %d), stderr: %s", err, c.Argv, code, stderr.String()) |
| 221 | } |
| 222 | return result, code, logHash, err |
| 223 | } |
| 224 | func safeDir(root, rel string) error { |
| 225 | if rel == "." { |
| 226 | return nil |
| 227 | } |
| 228 | if err := safePath(root, rel, false); err != nil { |
| 229 | return err |
| 230 | } |
| 231 | st, err := os.Stat(filepath.Join(root, rel)) |
| 232 | if err != nil || !st.IsDir() { |
| 233 | return provider.ErrPolicy |
| 234 | } |
| 235 | return nil |
| 236 | } |
| 237 | func (e *Executor) CaptureBaseline(ctx context.Context, d Definition) (TestBaseline, error) { |
| 238 | if err := e.definition(ctx, d, false); err != nil { |
| 239 | return TestBaseline{}, err |
| 240 | } |
| 241 | var names []TestIdentity |
| 242 | for _, c := range d.Commands { |
| 243 | r, _, _, err := e.freshRun(ctx, d, nil, d.Base, c) |
| 244 | if err != nil { |
| 245 | return TestBaseline{}, err |
| 246 | } |
| 247 | if c.Parser == "go-test-json" { |
| 248 | names = append(names, r.names...) |
| 249 | for p, status := range r.packages { |
| 250 | if status == "no-tests" { |
| 251 | continue |
| 252 | } |
| 253 | names = append(names, TestIdentity{Package: p}) |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | if len(names) == 0 { |
| 258 | return TestBaseline{}, provider.ErrContract |
| 259 | } |
| 260 | names = namesSorted(names) |
| 261 | return TestBaseline{Names: names, Hash: setHash(names)}, nil |
| 262 | } |
| 263 | func (e *Executor) isolation(ctx context.Context) (team.IsolationSnapshot, error) { |
| 264 | iso, err := e.cfg.Isolation(ctx) |
| 265 | if err != nil { |
| 266 | return iso, err |
| 267 | } |
| 268 | if iso.Status != "confined" && iso.Status != "unconfined" || len(iso.ObservedTuples) == 0 { |
| 269 | return iso, provider.ErrIdentity |
| 270 | } |
| 271 | iso = canonicalIsolation(iso) |
| 272 | e.mu.Lock() |
| 273 | defer e.mu.Unlock() |
| 274 | iso.RunnerTainted = iso.RunnerTainted || e.exposure.RunnerTainted |
| 275 | if e.exposure.Status == "unconfined" { |
| 276 | iso.Status = "unconfined" |
| 277 | } |
| 278 | for _, id := range e.exposure.AcknowledgementIDs { |
| 279 | if !slices.Contains(iso.AcknowledgementIDs, id) { |
| 280 | iso.AcknowledgementIDs = append(iso.AcknowledgementIDs, id) |
| 281 | } |
| 282 | } |
| 283 | for _, tuple := range e.exposure.ObservedTuples { |
| 284 | if !slices.Contains(iso.ObservedTuples, tuple) { |
| 285 | iso.ObservedTuples = append(iso.ObservedTuples, tuple) |
| 286 | } |
| 287 | } |
| 288 | if iso.RunnerTainted { |
| 289 | iso.Status = "unconfined" |
| 290 | } |
| 291 | if iso.Status == "unconfined" && len(iso.AcknowledgementIDs) == 0 { |
| 292 | return iso, provider.ErrIdentity |
| 293 | } |
| 294 | iso = canonicalIsolation(iso) |
| 295 | e.exposure = canonicalIsolation(iso) |
| 296 | return iso, nil |
| 297 | } |
| 298 | func canonicalIsolation(iso team.IsolationSnapshot) team.IsolationSnapshot { |
| 299 | iso.AcknowledgementIDs = slices.Clone(iso.AcknowledgementIDs) |
| 300 | iso.ObservedTuples = slices.Clone(iso.ObservedTuples) |
| 301 | slices.Sort(iso.AcknowledgementIDs) |
| 302 | iso.AcknowledgementIDs = slices.Compact(iso.AcknowledgementIDs) |
| 303 | slices.SortFunc(iso.ObservedTuples, func(a, b team.IsolationTuple) int { return bytes.Compare(encode(a), encode(b)) }) |
| 304 | iso.ObservedTuples = slices.Compact(iso.ObservedTuples) |
| 305 | return iso |
| 306 | } |
| 307 | func (e *Executor) attest(ctx context.Context, role team.Role, value any, iso team.IsolationSnapshot) error { |
| 308 | e.mu.Lock() |
| 309 | defer e.mu.Unlock() |
| 310 | p := team.Provenance{Producer: "equipo-checks", Provider: "executor", Context: string(e.cfg.Handle.Runner), Isolation: iso} |
| 311 | if e.store != nil { |
| 312 | return e.store.SaveAttestation(ctx, AttestationKey(e.cfg.Scope, e.cfg.Handle, team.ArtifactSpec{Role: role, Payload: encode(value)}), p) |
| 313 | } |
| 314 | return provider.ErrContract |
| 315 | } |
| 316 | func (e *Executor) ValidateEvidence(ctx context.Context, _ *sql.Tx, scope team.Scope, h team.Handle, spec team.ArtifactSpec) (team.Provenance, error) { |
| 317 | current, err := e.isolation(ctx) |
| 318 | if err != nil { |
| 319 | return team.Provenance{}, err |
| 320 | } |
| 321 | e.mu.Lock() |
| 322 | defer e.mu.Unlock() |
| 323 | if ctx.Err() != nil { |
| 324 | return team.Provenance{}, ctx.Err() |
| 325 | } |
| 326 | if scope.Account == "" || scope.Job <= 0 || h.Attempt <= 0 || h.Fence <= 0 || scope != e.cfg.Scope || h.Attempt != e.cfg.Handle.Attempt || h.Fence != e.cfg.Handle.Fence || h.Runner != e.cfg.Handle.Runner { |
| 327 | return team.Provenance{}, provider.ErrIdentity |
| 328 | } |
| 329 | if e.store == nil { |
| 330 | return team.Provenance{}, provider.ErrContract |
| 331 | } |
| 332 | p, err := e.store.LoadAttestation(ctx, AttestationKey(scope, h, spec)) |
| 333 | if err != nil || p.Producer != "equipo-checks" || p.Provider != "executor" || p.Context != h.Runner || !bytes.Equal(encode(p.Isolation), encode(current)) { |
| 334 | return p, provider.ErrIdentity |
| 335 | } |
| 336 | return p, nil |
| 337 | } |
| 338 | func (e *Executor) Reproduce(ctx context.Context, d Definition, r Reproduction, subjectCommit, candidateHash string) (team.CheckResult, error) { |
| 339 | result := team.CheckResult{} |
| 340 | if err := e.definition(ctx, d, true); err != nil { |
| 341 | return result, err |
| 342 | } |
| 343 | if candidateHash != "" { |
| 344 | candidate, err := e.cfg.ResolveCandidate(ctx, candidateHash) |
| 345 | if err != nil || candidate.Repository != d.Repository || candidate.BaseCommit != d.Base || candidate.Commit != subjectCommit || !objectID(candidate.Tree) || CandidateHash(candidate) != candidateHash { |
| 346 | return result, provider.ErrIdentity |
| 347 | } |
| 348 | } |
| 349 | if !objectID(subjectCommit) || (candidateHash == "" && subjectCommit != d.Base) || (candidateHash != "" && !hexID(candidateHash, 64)) { |
| 350 | return result, provider.ErrIdentity |
| 351 | } |
| 352 | work, cleanup, err := e.scratch(ctx, subjectCommit) |
| 353 | if err != nil { |
| 354 | return result, err |
| 355 | } |
| 356 | defer cleanup() |
| 357 | if err = e.material(d, work); err != nil { |
| 358 | return result, err |
| 359 | } |
| 360 | if err = e.overlay(ctx, d, r, work); err != nil { |
| 361 | return result, err |
| 362 | } |
| 363 | run, code, logHash, err := e.run(ctx, d.Reproduction, work, r.ExpectedSymptom) |
| 364 | if err != nil { |
| 365 | return result, err |
| 366 | } |
| 367 | if !superset(run.names, r.TestNames) { |
| 368 | return result, provider.ErrIdentity |
| 369 | } |
| 370 | outcome := team.CheckPass |
| 371 | subject := candidateHash |
| 372 | role := team.RoleCandidateResult |
| 373 | if candidateHash == "" { |
| 374 | subject = d.Base |
| 375 | role = team.RoleBaseResult |
| 376 | outcome = team.CheckFail |
| 377 | matched := false |
| 378 | for _, id := range namesSorted(r.TestNames) { |
| 379 | state := run.tests[id] |
| 380 | if state == nil || !state.done || !state.failed { |
| 381 | return result, provider.ErrIdentity |
| 382 | } |
| 383 | matched = matched || state.matched |
| 384 | } |
| 385 | if !matched { |
| 386 | return result, provider.ErrIdentity |
| 387 | } |
| 388 | } else if run.failed != 0 { |
| 389 | return result, provider.ErrIdentity |
| 390 | } |
| 391 | testsRun, testsFailed := run.run, run.failed |
| 392 | if candidateHash == "" { |
| 393 | testsRun = len(namesSorted(r.TestNames)) |
| 394 | testsFailed = testsRun |
| 395 | } |
| 396 | iso, err := e.isolation(ctx) |
| 397 | if err != nil { |
| 398 | return result, err |
| 399 | } |
| 400 | result = team.CheckResult{ExitCode: code, LogHash: logHash, ReproductionHash: e.cfg.ReproductionHash, SubjectHash: subject, CheckDefinitionHash: e.cfg.DefinitionHash, Outcome: outcome, TestsRun: testsRun, TestsFailed: testsFailed, SubjectCommit: subjectCommit, OverlayHash: Digest(encode(r.Files)), CollisionChecked: true, ObservedNames: namesSorted(run.names), Isolation: iso, ExecutorBinary: e.binary, ExecutorVersion: e.version} |
| 401 | if outcome == team.CheckFail { |
| 402 | result.FailureMessage = r.ExpectedSymptom |
| 403 | } |
| 404 | return result, e.attest(ctx, role, result, iso) |
| 405 | } |
| 406 | func (e *Executor) RepositoryChecks(ctx context.Context, d Definition, candidate team.GitCandidate, candidateHash string) (team.RepositoryCheckResult, error) { |
| 407 | result := team.RepositoryCheckResult{} |
| 408 | r, err := e.cfg.Reproduction(ctx, e.cfg.ReproductionHash) |
| 409 | if err != nil { |
| 410 | return result, err |
| 411 | } |
| 412 | verified, err := e.cfg.ResolveCandidate(ctx, candidateHash) |
| 413 | if err != nil || verified != candidate { |
| 414 | return result, provider.ErrIdentity |
| 415 | } |
| 416 | if err := e.definition(ctx, d, true); err != nil { |
| 417 | return result, err |
| 418 | } |
| 419 | if candidate.Repository != d.Repository || candidate.BaseCommit != d.Base || !objectID(candidate.Commit) || !objectID(candidate.Tree) || !hexID(candidateHash, 64) || CandidateHash(candidate) != candidateHash { |
| 420 | return result, provider.ErrIdentity |
| 421 | } |
| 422 | var names []TestIdentity |
| 423 | var logs []string |
| 424 | count := 0 |
| 425 | for _, c := range d.Commands { |
| 426 | run, code, log, err := e.freshRun(ctx, d, &r, candidate.Commit, c) |
| 427 | if err != nil { |
| 428 | return result, err |
| 429 | } |
| 430 | if code != 0 || run.failed != 0 { |
| 431 | return result, provider.ErrIdentity |
| 432 | } |
| 433 | logs = append(logs, log) |
| 434 | count += run.run |
| 435 | names = append(names, run.names...) |
| 436 | for p, status := range run.packages { |
| 437 | if status == "no-tests" { |
| 438 | continue |
| 439 | } |
| 440 | names = append(names, TestIdentity{Package: p}) |
| 441 | } |
| 442 | } |
| 443 | if count == 0 || !superset(names, d.Baseline.Names) || !superset(names, r.TestNames) { |
| 444 | return result, provider.ErrIdentity |
| 445 | } |
| 446 | iso, err := e.isolation(ctx) |
| 447 | if err != nil { |
| 448 | return result, err |
| 449 | } |
| 450 | result = team.RepositoryCheckResult{CandidateHash: candidateHash, Commit: candidate.Commit, CheckDefinitionHash: e.cfg.DefinitionHash, BaselineTestSetHash: d.Baseline.Hash, ObservedTestSetHash: setHash(names), Outcome: team.CheckPass, TestsRun: count, LogHash: e.saveLog(encode(logs)), ObservedNames: namesSorted(names), Isolation: iso, ExecutorBinary: e.binary, ExecutorVersion: e.version} |
| 451 | return result, e.attest(ctx, team.RoleRepositoryChecks, result, iso) |
| 452 | } |
| 453 | |
| 454 | func (e *Executor) freshRun(ctx context.Context, d Definition, r *Reproduction, commit string, c Command) (*goResults, int, string, error) { |
| 455 | work, cleanup, err := e.scratch(ctx, commit) |
| 456 | if err != nil { |
| 457 | return nil, 0, "", err |
| 458 | } |
| 459 | defer cleanup() |
| 460 | if err = e.material(d, work); err != nil { |
| 461 | return nil, 0, "", err |
| 462 | } |
| 463 | if r != nil { |
| 464 | if err = e.overlay(ctx, d, *r, work); err != nil { |
| 465 | return nil, 0, "", err |
| 466 | } |
| 467 | } |
| 468 | return e.run(ctx, c, work, "") |
| 469 | } |
| 470 | func (e *Executor) saveLog(b []byte) string { |
| 471 | e.mu.Lock() |
| 472 | defer e.mu.Unlock() |
| 473 | hash := Digest(b) |
| 474 | e.logs[hash] = append([]byte(nil), b...) |
| 475 | return hash |
| 476 | } |
| 477 | func (e *Executor) Log(ctx context.Context, hash string) ([]byte, error) { |
| 478 | e.mu.Lock() |
| 479 | defer e.mu.Unlock() |
| 480 | if ctx.Err() != nil { |
| 481 | return nil, ctx.Err() |
| 482 | } |
| 483 | b, ok := e.logs[hash] |
| 484 | if !ok || Digest(b) != hash { |
| 485 | return nil, provider.ErrIdentity |
| 486 | } |
| 487 | return append([]byte(nil), b...), nil |
| 488 | } |
| 489 | |