campaigns

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package campaigns reads Vulnetix remediation campaigns from the console's site API (GET /api/site/v1/campaigns), the source of the GitHub security campaigns that `vulnesis gha publish campaigns` creates.

The routes are Pro. A caller who is not entitled gets HTTP 200 with a marker body ({"planLocked": true, ...}) instead of an error so the console can show an upgrade prompt; that is surfaced here as ErrNotEntitled. The caller authenticates as for the config engine (an owner or admin credential).

Index

Constants

View Source
const (
	StatusActive    = "ACTIVE"
	StatusCompleted = "COMPLETED"
	StatusArchived  = "ARCHIVED"
)

Status values of a campaign.

Variables

View Source
var ErrNotEntitled = errors.New("campaigns need a Pro plan (the organization is not entitled)")

ErrNotEntitled is returned when the organization is not on a plan with campaigns.

Functions

This section is empty.

Types

type Campaign

type Campaign struct {
	UUID        string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"description"`
	TargetKind  string `json:"targetKind"`
	Status      string `json:"status"`
	// DeadlineAt is epoch milliseconds, absent when the campaign has none.
	DeadlineAt  *int64          `json:"deadlineAt"`
	CohortSize  int             `json:"cohortSize"`
	ClosedCount int             `json:"closedCount"`
	Scope       json.RawMessage `json:"scope"`
	CompletedAt *int64          `json:"completedAt"`
	ArchivedAt  *int64          `json:"archivedAt"`
}

Campaign is a Vulnetix remediation campaign.

func (Campaign) Closed

func (c Campaign) Closed() bool

Closed reports whether the campaign is over: completed or archived.

func (Campaign) Deadline

func (c Campaign) Deadline() (time.Time, bool)

Deadline returns the deadline, and false when the campaign has none.

type Client

type Client struct {
	Site Getter
	// PerPage is the items page size (the API caps it at 200).
	PerPage int
}

Client reads campaigns.

func New

func New(site Getter) *Client

New returns a client over site.

func (*Client) Items

func (c *Client) Items(ctx context.Context, id, state string) ([]Item, error)

Items returns the campaign's cohort items in the given state ("open", "done", or "" for all), following pagination.

func (*Client) List

func (c *Client) List(ctx context.Context, includeArchived bool) ([]Campaign, error)

List returns the organization's campaigns, newest first. Archived ones are included when includeArchived is set, so a GitHub campaign can be closed for a Vulnetix campaign that has since been archived.

type Getter

type Getter interface {
	Get(ctx context.Context, path string, query url.Values) ([]byte, error)
}

Getter fetches a path under the site API and returns the body. The CLI's siteClient implements it, so credentials and the base URL stay in one place.

type Item

type Item struct {
	UUID             string `json:"uuid"`
	ItemKey          string `json:"itemKey"`
	Kind             string `json:"kind"` // finding or dependency
	RepoName         string `json:"repoName"`
	FindingID        string `json:"findingId"`
	Category         string `json:"category"`
	PackageName      string `json:"packageName"`
	PackageVersion   string `json:"packageVersion"`
	PackageEcosystem string `json:"packageEcosystem"`
	DependencyKey    string `json:"dependencyKey"`
	Severity         string `json:"severity"`
	State            string `json:"state"` // open or done
}

Item is one member of a campaign's frozen cohort.

Jump to

Keyboard shortcuts

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