client

package
v0.0.0-...-9d00ea5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AccessManagementPermission        = Permission("ACCESS_MANAGEMENT")
	PolicyManagementPermission        = Permission("POLICY_MANAGEMENT")
	PolicyViolationAnalysisPermission = Permission("POLICY_VIOLATION_ANALYSIS")
	SystemConfigurationPermission     = Permission("SYSTEM_CONFIGURATION")
	ViewPolicyViolationPermission     = Permission("VIEW_POLICY_VIOLATION")
	ViewPortfolioPermission           = Permission("VIEW_PORTFOLIO")
	ViewVulnerabilityPermission       = Permission("VIEW_VULNERABILITY")
)
View Source
const EmailPostfix = "@nais.io"

Variables

This section is empty.

Functions

func IsConflict

func IsConflict(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsNotModified

func IsNotModified(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

Types

type AdminUser

type AdminUser struct {
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

type AdminUsers

type AdminUsers struct {
	Users []AdminUser `json:"users,omitempty" yaml:"users,omitempty"`
}

type Alias

type Alias struct {
	CveId  string `json:"cveId"`
	GhsaId string `json:"ghsaId"`
}

type ApiKey

type ApiKey struct {
	Key string `json:"key,omitempty"`
}

type BomSubmitRequest

type BomSubmitRequest struct {
	ProjectName    string `json:"projectName"`
	ProjectVersion string `json:"projectVersion"`
	ParentUuid     string `json:"parentUUID,omitempty"`
	AutoCreate     bool   `json:"autoCreate"`
	Bom            string `json:"bom"`
}

type Client

type Client interface {
	Version(ctx context.Context) (string, error)
	AddToTeam(ctx context.Context, username, uuid string) error
	ChangeAdminPassword(ctx context.Context, oldPassword, newPassword string) error
	CreateAdminUsers(ctx context.Context, users *AdminUsers, teamUuid string) error
	CreateManagedUser(ctx context.Context, username, password string) error
	CreateOidcUser(ctx context.Context, email string) error
	CreateProject(ctx context.Context, name, version, group string, tags []string) (*Project, error)
	UpdateProject(ctx context.Context, uuid, name, version, group string, tags []string) (*Project, error)
	CreateChildProject(ctx context.Context, project *Project, name, version, group, classifier string, tags []string) (*Project, error)
	CreateTeam(ctx context.Context, teamName string, permissions []Permission) (*Team, error)
	DeleteManagedUser(ctx context.Context, username string) error
	DeleteOidcUser(ctx context.Context, username string) error
	DeleteProject(ctx context.Context, uuid string) error
	DeleteProjects(ctx context.Context, name string) error
	DeleteTeam(ctx context.Context, uuid string) error
	DeleteUserMembership(ctx context.Context, uuid, username string) error
	GenerateApiKey(ctx context.Context, uuid string) (string, error)
	GetOidcUsers(ctx context.Context) ([]User, error)
	GetProjects(ctx context.Context) ([]*Project, error)
	GetProject(ctx context.Context, name, version string) (*Project, error)
	GetProjectsByTag(ctx context.Context, tag string) ([]*Project, error)
	GetTeam(ctx context.Context, team string) (*Team, error)
	GetTeams(ctx context.Context) ([]Team, error)
	PortfolioRefresh(ctx context.Context) error
	RemoveAdminUsers(ctx context.Context, users *AdminUsers) error
	UpdateProjectInfo(ctx context.Context, uuid, version, group string, tags []string) error
	UploadProject(ctx context.Context, name, version, parentUuid string, autoCreate bool, bom []byte) error
	ConfigPropertyAggregate(ctx context.Context, properties []ConfigProperty) ([]ConfigProperty, error)
	GetConfigProperties(ctx context.Context) ([]ConfigProperty, error)
	GetEcosystems(ctx context.Context) ([]string, error)
	GetFindings(ctx context.Context, projectUuid string) ([]*Finding, error)
	TriggerAnalysis(ctx context.Context, projectUuid string) error
	GetCurrentProjectMetric(ctx context.Context, projectUuid string) (*ProjectMetric, error)
	GetProjectMetricsByDate(ctx context.Context, projectUuid, date string) ([]*ProjectMetric, error)
	auth.Auth
}

func New

func New(baseUrl, username, password string, opts ...Option) Client

type Component

type Component struct {
	UUID    string `json:"uuid"`
	PURL    string `json:"purl"`
	Project string `json:"project"`
	Name    string `json:"name"`
}

type ConfigProperty

type ConfigProperty struct {
	GroupName     string `json:"groupName"`
	PropertyName  string `json:"propertyName"`
	PropertyValue string `json:"propertyValue"`
	PropertyType  string `json:"propertyType"`
	Description   string `json:"description"`
}

type Finding

type Finding struct {
	Component     Component     `json:"component"`
	Vulnerability Vulnerability `json:"vulnerability"`
}

type NewUser

type NewUser struct {
	Username            string `json:"username,omitempty"`
	Email               string `json:"email,omitempty"`
	NewPassword         string `json:"newPassword,omitempty"`
	ConfirmPassword     string `json:"confirmPassword,omitempty"`
	Fullname            string `json:"fullname,omitempty"`
	Suspended           bool   `json:"suspended,omitempty"`
	ForcePasswordChange bool   `json:"forcePasswordChange,omitempty"`
	NonExpiryPassword   bool   `json:"nonExpiryPassword,omitempty"`
}

type Option

type Option = func(c *Options)

func WithApiKeySource

func WithApiKeySource(team string) Option

func WithAuthSource

func WithAuthSource(authSource auth.Auth) Option

func WithHttpClient

func WithHttpClient(client *http.Client) Option

func WithLogger

func WithLogger(log *log.Entry) Option

func WithResponseCallback

func WithResponseCallback(callback func(res *http.Response, err error)) Option

type Options

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

type Permission

type Permission string

type Project

type Project struct {
	Active                 bool           `json:"active"`
	Author                 string         `json:"author"`
	Classifier             string         `json:"classifier"`
	Group                  string         `json:"group"`
	Name                   string         `json:"name"`
	LastBomImportFormat    string         `json:"lastBomImportFormat,omitempty"`
	LastBomImport          int64          `json:"lastBomImport,omitempty"`
	LastInheritedRiskScore float64        `json:"lastInheritedRiskScore,omitempty"`
	Publisher              string         `json:"publisher"`
	Tags                   []Tag          `json:"tags"`
	Uuid                   string         `json:"uuid"`
	Version                string         `json:"version"`
	Parent                 *Project       `json:"parent"`
	Metrics                *ProjectMetric `json:"metrics,omitempty"`
}

type ProjectMetric

type ProjectMetric struct {
	Critical             int     `json:"critical"`
	High                 int     `json:"high"`
	Medium               int     `json:"medium"`
	Low                  int     `json:"low"`
	Unassigned           int     `json:"unassigned"`
	Vulnerabilities      int     `json:"vulnerabilities"`
	VulnerableComponents int     `json:"vulnerableComponents"`
	Components           int     `json:"components"`
	Suppressed           int     `json:"suppressed"`
	FindingsTotal        int     `json:"findingsTotal"`
	FindingsAudited      int     `json:"findingsAudited"`
	FindingsUnaudited    int     `json:"findingsUnaudited"`
	InheritedRiskScore   float64 `json:"inheritedRiskScore"`
	FirstOccurrence      int64   `json:"firstOccurrence"`
	LastOccurrence       int64   `json:"lastOccurrence"`
}

type Tag

type Tag struct {
	Name string `json:"name"`
}

type Tags

type Tags struct {
	Tags []Tag `json:"tags"`
}

type Team

type Team struct {
	Uuid      string   `json:"uuid,omitempty"`
	Name      string   `json:"name,omitempty"`
	OidcUsers []User   `json:"oidcUsers,omitempty"`
	ApiKeys   []ApiKey `json:"apiKeys,omitempty"`
}

type User

type User struct {
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
}

type Vulnerability

type Vulnerability struct {
	VulnId       string  `json:"vulnId"`
	Severity     string  `json:"severity"`
	SeverityRank int     `json:"severityRank"`
	Source       string  `json:"source"`
	Aliases      []Alias `json:"aliases"`
	Title        string  `json:"title"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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