dtrack

package
v0.0.0-...-ace901d Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicyViolationLicense     = "LICENSE"
	PolicyViolationOperational = "OPERATIONAL"
	PolicyViolationSecurity    = "SECURITY"
)
View Source
const (
	SeverityCritical   = "CRITICAL"
	SeverityHigh       = "HIGH"
	SeverityMedium     = "MEDIUM"
	SeverityLow        = "LOW"
	SeverityInfo       = "INFO"
	SeverityUnassigned = "UNASSIGNED"
)

Variables

View Source
var (
	ErrConflict            = errors.New("conflict")
	ErrForbidden           = errors.New("forbidden")
	ErrNotFound            = errors.New("not found")
	ErrUnauthorized        = errors.New("unauthorized")
	ErrInternalServerError = errors.New("internal server error")
	ErrInvalidResponseType = errors.New("invalid response type")

	ErrMissingTotalCountHeader = errors.New("response does not contain " + headerTotalCount + " header")
)

Functions

This section is empty.

Types

type About

type About struct {
	UUID        string         `json:"uuid"`
	SystemUUID  string         `json:"systemUuid"`
	Application string         `json:"application"`
	Version     string         `json:"version"`
	Timestamp   string         `json:"timestamp"`
	Framework   AboutFramework `json:"framework"`
}

type AboutFramework

type AboutFramework struct {
	UUID      string `json:"uuid"`
	Name      string `json:"name"`
	Version   string `json:"version"`
	Timestamp string `json:"timestamp"`
}

type AboutService

type AboutService interface {
	Get(ctx context.Context) (*About, error)
}

type Analysis

type Analysis struct {
	Comments   []AnalysisComment `json:"comments"`
	State      string            `json:"state"`
	Suppressed bool              `json:"isSuppressed"`
}

type AnalysisComment

type AnalysisComment struct {
	Comment   string `json:"comment"`
	Commenter string `json:"commenter"`
	Timestamp string `json:"timestamp"`
}

type AnalysisRequest

type AnalysisRequest struct {
	ComponentUUID     string `json:"component"`
	ProjectUUID       string `json:"project"`
	VulnerabilityUUID string `json:"vulnerability"`
	Comment           string `json:"comment,omitempty"`
	State             string `json:"analysisState,omitempty"`
	Suppressed        bool   `json:"isSuppressed"`
}

type AnalysisService

type AnalysisService interface {
	Create(ctx context.Context, req AnalysisRequest) (*Analysis, error)
	Get(ctx context.Context, cUUID, pUUID, vUUID string) (*Analysis, error)
}

type BOMService

type BOMService interface {
	ExportProjectAsCycloneDX(ctx context.Context, projectUUID string) (string, error)
	IsBeingProcessed(ctx context.Context, uploadToken string) (bool, error)
	Upload(ctx context.Context, req BOMUploadRequest) (string, error)
}

type BOMUploadRequest

type BOMUploadRequest struct {
	ProjectUUID    string `json:"project,omitempty"`
	ProjectName    string `json:"projectName,omitempty"`
	ProjectVersion string `json:"projectVersion,omitempty"`
	AutoCreate     bool   `json:"autoCreate"`
	BOM            string `json:"bom"`
}

type Client

type Client struct {
	About                   AboutService
	Analysis                AnalysisService
	BOM                     BOMService
	Component               ComponentService
	Finding                 FindingService
	License                 LicenseService
	LicenseGroup            LicenseGroupService
	PolicyViolation         PolicyViolationService
	PolicyViolationAnalysis PolicyViolationAnalysisService
	Project                 ProjectService
	ProjectMetrics          ProjectMetricsService
	Repository              RepositoryService
	Vulnerability           VulnerabilityService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL, apiKey string) (*Client, error)

func (Client) GuessVulnerabilitySource

func (c Client) GuessVulnerabilitySource(vulnID string) VulnerabilitySource

FIXME: Move this to internal package

type Component

type Component struct {
	Author          string  `json:"author"`
	Blake2b_256     string  `json:"blake2b_256"`
	Blake2b_384     string  `json:"blake2b_384"`
	Blake2b_512     string  `json:"blake2b_512"`
	Blake3          string  `json:"blake3"`
	Classifier      string  `json:"classifier"`
	Copyright       string  `json:"copyright"`
	CPE             string  `json:"cpe"`
	Extension       string  `json:"extension"`
	Filename        string  `json:"filename"`
	Group           string  `json:"group"`
	Internal        bool    `json:"isInternal"`
	License         string  `json:"license"`
	MD5             string  `json:"md5"`
	Name            string  `json:"name"`
	PackageURL      string  `json:"purl"`
	Publisher       string  `json:"publisher"`
	ResolvedLicense License `json:"resolvedLicense"`
	SHA1            string  `json:"sha1"`
	SHA256          string  `json:"sha256"`
	SHA384          string  `json:"sha384"`
	SHA512          string  `json:"sha512"`
	SHA3_256        string  `json:"sha3_256"`
	SHA3_384        string  `json:"sha3_384"`
	SHA3_512        string  `json:"sha3_512"`
	SWIDTagID       string  `json:"swidTagId"`
	UUID            string  `json:"uuid"`
	Version         string  `json:"version"`
}

type ComponentService

type ComponentService interface {
	GetAllForProject(ctx context.Context, projectUUID string) ([]Component, error)
	GetByUUID(ctx context.Context, uuid string) (*Component, error)
	GetByHash(ctx context.Context, hash string) (*Component, error)
}

type Finding

type Finding struct {
	Attribution   *FindingAttribution `json:"attribution"`
	Analysis      *Analysis           `json:"analysis"`
	Component     Component           `json:"component"`
	Matrix        string              `json:"matrix"`
	Vulnerability Vulnerability       `json:"vulnerability"`
}

type FindingAttribution

type FindingAttribution struct {
	AlternateIdentifier string `json:"alternateIdentifier"`
	AnalyzerIdentity    string `json:"analyzerIdentity"`
	AttributedOn        int    `json:"attributedOn"`
	ReferenceURL        string `json:"referenceUrl"`
	UUID                string `json:"uuid"`
}

type FindingService

type FindingService interface {
	GetForProject(ctx context.Context, projectUUID string, includeSuppressed bool) ([]Finding, error)
	ExportForProject(ctx context.Context, projectUUID string) (string, error)
}

type License

type License struct {
	Comment             string         `json:"comment"`
	DeprecatedLicenseID bool           `json:"deprecatedLicenseId"`
	FSFLibre            bool           `json:"fsfLibre"`
	Groups              []LicenseGroup `json:"licenseGroups"`
	Header              string         `json:"header"`
	LicenseID           string         `json:"licenseId"`
	Name                string         `json:"name"`
	OSIApproved         bool           `json:"isOsiApproved"`
	SeeAlso             []string       `json:"seeAlso"`
	Text                string         `json:"licenseText"`
	UUID                string         `json:"uuid"`
}

type LicenseGroup

type LicenseGroup struct {
	Name       string `json:"name"`
	RiskWeight int    `json:"riskWeight"`
	UUID       string `json:"uuid"`
}

type LicenseGroupService

type LicenseGroupService interface {
	GetAll(ctx context.Context) ([]LicenseGroup, error)
}

type LicenseService

type LicenseService interface {
	GetAll(ctx context.Context) ([]License, error)
	GetByID(ctx context.Context, id string) (*License, error)
}

type PolicyViolation

type PolicyViolation struct {
	Component *Component `json:"component"`
	Project   *Project   `json:"project"`
	Text      string     `json:"text"`
	Timestamp int64      `json:"timestamp"`
	Type      string     `json:"type"`
	UUID      string     `json:"uuid"`
}

type PolicyViolationAnalysis

type PolicyViolationAnalysis struct {
	Comments   []PolicyViolationAnalysisComment `json:"analysisComments"`
	State      string                           `json:"analysisState"`
	Suppressed bool                             `json:"isSuppressed"`
}

type PolicyViolationAnalysisComment

type PolicyViolationAnalysisComment struct {
	Comment   string `json:"comment"`
	Commenter string `json:"commenter"`
	Timestamp string `json:"timestamp"`
}

type PolicyViolationAnalysisRequest

type PolicyViolationAnalysisRequest struct {
	Comment       string `json:"comment,omitempty"`
	ComponentUUID string `json:"component"`
	ViolationUUID string `json:"policyViolation"`
	State         string `json:"analysisState,omitempty"`
	Suppressed    bool   `json:"isSuppressed"`
}

type PolicyViolationAnalysisService

type PolicyViolationAnalysisService interface {
	Create(ctx context.Context, req PolicyViolationAnalysisRequest) (*PolicyViolationAnalysis, error)
	Get(ctx context.Context, componentUUID, violationUUID string) (*PolicyViolationAnalysis, error)
}

type PolicyViolationService

type PolicyViolationService interface {
	GetForComponent(ctx context.Context, componentUUID string) ([]PolicyViolation, error)
	GetForProject(ctx context.Context, projectUUID string) ([]PolicyViolation, error)
}

type Project

type Project struct {
	Author                 string            `json:"author"`
	Classifier             string            `json:"classifier"`
	CPE                    string            `json:"cpe"`
	Description            string            `json:"description"`
	Group                  string            `json:"group"`
	LastBOMImport          int64             `json:"lastBomImport"`
	LastBOMImportFormat    string            `json:"lastBomImportFormat"`
	LastInheritedRiskScore float32           `json:"lastInheritedRiskScore"`
	Metrics                *ProjectMetrics   `json:"metrics"`
	Name                   string            `json:"name"`
	PackageURL             string            `json:"purl"`
	Properties             []ProjectProperty `json:"properties"`
	Publisher              string            `json:"publisher"`
	SWIDTagID              string            `json:"swidTagId"`
	Tags                   []ProjectTag      `json:"tags"`
	UUID                   string            `json:"uuid"`
	Version                string            `json:"version"`
}

type ProjectCloneRequest

type ProjectCloneRequest struct {
	ProjectUUID         string `json:"project"`
	Version             string `json:"version"`
	IncludeAuditHistory bool   `json:"includeAuditHistory"`
	IncludeComponents   bool   `json:"includeComponents"`
	IncludeProperties   bool   `json:"includeProperties"`
	IncludeServices     bool   `json:"includeServices"`
	IncludeTags         bool   `json:"includeTags"`
}

type ProjectMetrics

type ProjectMetrics struct {
	Components                       int     `json:"components"`
	Critical                         int     `json:"critical"`
	FindingsAudited                  int     `json:"findingsAudited"`
	FindingsTotal                    int     `json:"findingsTotal"`
	FindingsUnaudited                int     `json:"findingsUnaudited"`
	High                             int     `json:"high"`
	InheritedRiskScore               float32 `json:"inheritedRiskScore"`
	Low                              int     `json:"low"`
	Medium                           int     `json:"medium"`
	PolicyViolationsFail             int     `json:"policyViolationsFail"`
	PolicyViolationsInfo             int     `json:"policyViolationsInfo"`
	PolicyViolationsLicenseTotal     int     `json:"policyViolationsLicenseTotal"`
	PolicyViolationsOperationalTotal int     `json:"policyViolationsOperationalTotal"`
	PolicyViolationsSecurityTotal    int     `json:"policyViolationsSecurityTotal"`
	PolicyViolationsTotal            int     `json:"policyViolationsTotal"`
	PolicyViolationsWarn             int     `json:"policyViolationsWarn"`
	Suppressed                       int     `json:"suppressed"`
	Unassigned                       int     `json:"unassigned"`
	VulnerableComponents             int     `json:"vulnerableComponents"`
}

func (ProjectMetrics) GetSeverityCount

func (pm ProjectMetrics) GetSeverityCount(severity string) (count int, err error)

func (ProjectMetrics) GetViolationCount

func (pm ProjectMetrics) GetViolationCount(violationType string) (count int, err error)

type ProjectMetricsService

type ProjectMetricsService interface {
	GetCurrent(ctx context.Context, projectUUID string) (*ProjectMetrics, error)
	GetForDays(ctx context.Context, projectUUID string, days int) (*ProjectMetrics, error)
	GetSince(ctx context.Context, projectUUID string, date time.Time) (*ProjectMetrics, error)
}

type ProjectProperty

type ProjectProperty struct {
	Group string `json:"groupName"`
	Name  string `json:"propertyName"`
	Type  string `json:"propertyType"`
	Value string `json:"propertyValue"`
}

type ProjectService

type ProjectService interface {
	Clone(ctx context.Context, req ProjectCloneRequest) error
	GetAll(ctx context.Context) ([]Project, error)
	GetByUUID(ctx context.Context, uuid string) (*Project, error)
	Lookup(ctx context.Context, name, version string) (*Project, error)
	Resolve(ctx context.Context, uuid, name, version string) (*Project, error)
}

type ProjectTag

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

type RepositoryMetaComponent

type RepositoryMetaComponent struct {
	LatestVersion string `json:"latestVersion"`
}

type RepositoryService

type RepositoryService interface {
	GetMetaComponent(ctx context.Context, purl string) (*RepositoryMetaComponent, error)
}

type Vulnerability

type Vulnerability struct {
	UUID     string `json:"uuid"`
	VulnID   string `json:"vulnId"`
	Severity string `json:"severity"`
}

type VulnerabilityService

type VulnerabilityService interface {
	GetAll(ctx context.Context) ([]Vulnerability, error)
	GetAllForProject(ctx context.Context, projectUUID string) ([]Vulnerability, error)
	GetByUUID(ctx context.Context, uuid string) (*Vulnerability, error)
	GetByVulnID(ctx context.Context, vulnID string, source VulnerabilitySource) (*Vulnerability, error)
}

type VulnerabilitySource

type VulnerabilitySource string
const (
	NVD           VulnerabilitySource = "NVD"
	OSSIndex      VulnerabilitySource = "OSSIndex"
	UnknownSource VulnerabilitySource = ""
)

Jump to

Keyboard shortcuts

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