Help us shape the future of Go! Take the 2026 Go Developer Survey

discovery

package
v0.2.32 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WaitingForTarget = "Waiting for the default branch to pass CI"
	WaitingForRebase = "Waiting for the bot to rebase"
)

Variables

View Source
var DefaultBots = map[string]string{"dependabot[bot]\x0049699333": "dependabot", "renovate[bot]\x0029139614": "renovate"}
View Source
var ErrBlocked = errors.New("finding requires reviewed ownership or complete evidence")
View Source
var ErrDuplicate = errors.New("overlapping maintenance work exists; review existing change")
View Source
var ErrStale = errors.New("discovery evidence changed or expired; refresh discovery")

Functions

func BindRepairTx

func BindRepairTx(ctx context.Context, tx pgx.Tx, f Finding, taskID string) error

func BotUpdateJob

func BotUpdateJob(name string) bool

func CheckRepairOverlapTx

func CheckRepairOverlapTx(ctx context.Context, tx pgx.Tx, f Finding) error

func Fingerprint

func Fingerprint(org string, in Observation) string

func Overlap

func Overlap(a, b []detectors.Dependency) bool

func RepairConflict

func RepairConflict(change forge.Change) bool

Types

type AdvisoryInput

type AdvisoryInput struct {
	RepositoryID  string `json:"repository_id"`
	AdvisoryID    string `json:"advisory_id"`
	Title         string `json:"title"`
	Severity      string `json:"severity"`
	ReferenceURL  string `json:"reference_url"`
	Path          string `json:"path"`
	Package       string `json:"package"`
	Ecosystem     string `json:"ecosystem"`
	AffectedRange string `json:"affected_range"`
	CommitSHA     string `json:"commit_sha"`
}

type BotIdentity

type BotIdentity struct {
	Kind    string `json:"kind"`
	ActorID string `json:"actor_id"`
}

type Config

type Config struct {
	RepositoryID   string        `json:"repository_id"`
	TrustedBots    []BotIdentity `json:"trusted_bots"`
	MergeAuthority string        `json:"merge_authority"`
	Version        int64         `json:"version"`
}

type Evidence

type Evidence struct {
	Provenance        string                 `json:"provenance"`
	ConnectionID      string                 `json:"connection_id"`
	ConnectionVersion int64                  `json:"connection_version"`
	ConfigVersion     int64                  `json:"config_version"`
	HeadSHA           string                 `json:"head_sha"`
	TargetSHA         string                 `json:"target_sha"`
	TargetBranch      string                 `json:"target_branch"`
	Change            *forge.Change          `json:"change,omitempty"`
	Checks            []forge.Check          `json:"checks"`
	Dependencies      []detectors.Dependency `json:"dependencies"`
	Bot               string                 `json:"bot"`
	Behind            int                    `json:"behind,omitempty"`
	Ownership         string                 `json:"ownership"`
	HeadOwnership     string                 `json:"head_ownership"`
	MergeBlockers     []string               `json:"merge_blockers"`
	BotConfig         detectors.BotConfig    `json:"bot_config"`
	Complete          bool                   `json:"complete"`
	Blockers          []string               `json:"blockers"`
	AdvisoryID        string                 `json:"advisory_id,omitempty"`
	ReferenceURL      string                 `json:"reference_url,omitempty"`
	TrackedFiles      []forge.SourceEntry    `json:"tracked_files,omitempty"`
	Review            *ReviewEvidence        `json:"review,omitempty"`
	Deployment        string                 `json:"deployment,omitempty"`
	ActionURL         string                 `json:"action_url,omitempty"`
	ActionLabel       string                 `json:"action_label,omitempty"`
}

type Filter

type Filter struct{ RepositoryID, State, Category, Severity, Query string }

type Finding

type Finding struct {
	ID    string `json:"id"`
	OrgID string `json:"org_id"`
	Observation
	Fingerprint    string     `json:"fingerprint"`
	EvidenceDigest string     `json:"evidence_digest"`
	State          string     `json:"state"`
	Reason         string     `json:"reason"`
	AssignedTo     string     `json:"assigned_to,omitempty"`
	SnoozeUntil    *time.Time `json:"snooze_until,omitempty"`
	SupersededBy   string     `json:"superseded_by,omitempty"`
	Version        int64      `json:"version"`
	FirstSeen      time.Time  `json:"first_seen"`
	LastSeen       time.Time  `json:"last_seen"`
}

func ObserveTx

func ObserveTx(ctx context.Context, tx pgx.Tx, org string, in Observation, actor, request string) (Finding, error)

func PrepareRepairTx

func PrepareRepairTx(ctx context.Context, tx pgx.Tx, org, id string, expected int64) (Finding, error)

type Observation

type Observation struct {
	RepositoryID string   `json:"repository_id"`
	Source       string   `json:"source"`
	SourceID     string   `json:"source_id"`
	Category     string   `json:"category"`
	Severity     string   `json:"severity"`
	Title        string   `json:"title"`
	Evidence     Evidence `json:"evidence"`
}

type ReviewEvidence

type ReviewEvidence struct {
	Path       string `json:"path,omitempty"`
	Line       int    `json:"line,omitempty"`
	Confidence string `json:"confidence"`
	Objective  string `json:"objective"`
	Detail     string `json:"detail"`
}

type Scan

type Scan struct {
	RepositoryID string     `json:"repository_id"`
	State        string     `json:"state"`
	Reason       string     `json:"reason"`
	Version      int64      `json:"version"`
	ObservedAt   *time.Time `json:"observed_at,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(db *store.Store, identity *auth.Service, reader Reader) *Service

func (*Service) Get

func (s *Service) Get(ctx context.Context, session auth.Session, org, id string) (Finding, error)

func (*Service) GetConfig

func (s *Service) GetConfig(ctx context.Context, session auth.Session, org, repo string) (Config, error)

func (*Service) ImportAdvisory

func (s *Service) ImportAdvisory(ctx context.Context, session auth.Session, org string, in AdvisoryInput, request string) (Finding, error)

func (*Service) List

func (s *Service) List(ctx context.Context, session auth.Session, org string, limit int, cursor string, filter Filter) (domain.Page[Finding], error)

func (*Service) PutConfig

func (s *Service) PutConfig(ctx context.Context, session auth.Session, org, repo string, in Config, expected int64, request string) (Config, error)

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

func (*Service) RunOnce

func (s *Service) RunOnce(ctx context.Context) (bool, error)

func (*Service) RunOrganisationOnce

func (s *Service) RunOrganisationOnce(ctx context.Context, org string) (bool, error)

func (*Service) ScanStatus

func (s *Service) ScanStatus(ctx context.Context, session auth.Session, org, repo string) (Scan, error)

func (*Service) StartScan

func (s *Service) StartScan(ctx context.Context, session auth.Session, org, repo, request string) (Scan, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, session auth.Session, org, id string, in Update, expected int64, request string) (Finding, error)

type Update

type Update struct {
	Action      string     `json:"action"`
	Reason      string     `json:"reason"`
	AssignedTo  string     `json:"assigned_to"`
	SnoozeUntil *time.Time `json:"snooze_until"`
}

Jump to

Keyboard shortcuts

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