evidence

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package evidence preserves finding evidence independently of disposable traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	DB      *db.DB
	Traffic *traffic.Traffic
	Dir     string
}

func New

func New(pg *db.DB, tr *traffic.Traffic, dir string) *Store

func (*Store) Bind

func (s *Store) Bind(ctx context.Context, findingID int64, refs []db.TrafficRef) (out *db.FindingTraffic, err error)

func (*Store) Binding

func (s *Store) Binding(ctx context.Context, findingID, bindingID int64) (db.FindingTrafficBinding, error)

Binding resolves one binding's metadata under the evidence lock and releases the lock before returning. Callers that then stream a body to a client must use this instead of WithBinding: verifyFile+io.Copy is O(body size), so a large download (or a slow client) holding WithEvidenceTx would block every evidence write process-wide. Reading the blob afterwards is safe — blobs are content-addressed and GC only reaps unreferenced files after a 24h grace period, and an already-open fd survives an unlink regardless.

func (*Store) Collect

func (s *Store) Collect(ctx context.Context, now time.Time) error

func (*Store) CopySnapshots

func (s *Store) CopySnapshots(ctx context.Context, snapshots []db.TrafficEvidenceSnapshot, dest string) error

CopySnapshots is used by both report downloads and portable task archives. The destination owns real copies, never links into either disposable store.

func (*Store) InstallSnapshots

func (s *Store) InstallSnapshots(ctx context.Context, snapshots []db.TrafficEvidenceSnapshot, source string) error

func (*Store) OpenBody

func (s *Store) OpenBody(snapshot db.TrafficEvidenceSnapshot, side string) (*os.File, int64, error)

OpenBody may be called without holding the evidence lock; see Binding.

func (*Store) Record

func (s *Store) Record(ctx context.Context, in db.RecordFindingInput, refs []db.TrafficRef) (out *db.RecordedFinding, err error)

func (*Store) RunGC

func (s *Store) RunGC(ctx context.Context)

func (*Store) StageFindingsExport

func (s *Store) StageFindingsExport(ctx context.Context, findings []*db.DBFinding, dest string, copyBodies bool) error

StageFindingsExport freezes bindings/report versions and makes private body copies before the HTTP response is started. The caller owns and removes dest.

func (*Store) WithBinding

func (s *Store) WithBinding(ctx context.Context, findingID, bindingID int64, fn func(db.FindingTrafficBinding) error) error

func (*Store) WithInstalledSnapshots

func (s *Store) WithInstalledSnapshots(ctx context.Context, snapshots []db.TrafficEvidenceSnapshot, source string, restore func() error) error

WithInstalledSnapshots pins installed bodies until the metadata restore finishes. The callback must not acquire another evidence advisory lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL