reporting

package
v0.0.0-...-40d4f7c Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Green = iota + 1
	Yellow
	Red
	Grey
	Black
)

enum for style types

View Source
const StepReportDirectory = ".pipeline/stepReports"

StepReportDirectory specifies the default directory for markdown reports which can later be collected by step pipelineCreateSummary

Variables

This section is empty.

Functions

func RapidScanResult

func RapidScanResult(dir string) (string, error)

RapidScanResult reads result of Rapid scan from generated file

Types

type ColumnStyle

type ColumnStyle int

ColumnStyle defines style for a specific column

func (ColumnStyle) String

func (c ColumnStyle) String() string

type Component

type Component struct {
	ComponentName                  string                         `json:"componentName"`
	ComponentVersion               string                         `json:"versionName"`
	ComponentIdentifier            string                         `json:"componentIdentifier"`
	ViolatingPolicyNames           []string                       `json:"violatingPolicyNames"`
	PolicyViolationVulnerabilities []PolicyViolationVulnerability `json:"policyViolationVulnerabilities"`
	PolicyViolationLicenses        []PolicyViolationLicense       `json:"policyViolationLicenses"`
	WarningMessage                 string                         `json:"warningMessage"`
	ErrorMessage                   string                         `json:"errorMessage"`
}

type Components

type Components []Component

Components - for parsing from file

type Files

type Files []os.DirEntry

type GitHub

type GitHub struct {
	Owner         *string
	Repository    *string
	Assignees     *[]string
	IssueService  githubIssueService
	SearchService githubSearchService
}

GitHub contains metadata for reporting towards GitHub

func (*GitHub) UploadMultipleReports

func (g *GitHub) UploadMultipleReports(ctx context.Context, scanReports *[]IssueDetail) error

UploadMultipleReports uploads a number of reports to GitHub, one per IssueDetail to create transparency

func (*GitHub) UploadSingleReport

func (g *GitHub) UploadSingleReport(ctx context.Context, scanReport IssueDetail) error

UploadSingleReport uploads a single report to GitHub

type IssueDetail

type IssueDetail interface {
	Title() string
	ToMarkdown() ([]byte, error)
	ToTxt() string
}

IssueDetail represents any content that can be transformed into the body of a GitHub issue

type License

type License struct {
	LicenseName   string
	ComponentName string
	LicenseHref   string
}

type Licenses

type Licenses struct {
	PolicyViolationName string
	Values              []License
}

type Meta

type Meta struct {
	Href string `json:"href"`
}

type OtherViolation

type OtherViolation struct {
	ComponentName string
}

type OtherViolations

type OtherViolations struct {
	PolicyViolationName string
	Values              []OtherViolation
}

type OverviewRow

type OverviewRow struct {
	Description string      `json:"description"`
	Details     string      `json:"details,omitempty"`
	Style       ColumnStyle `json:"style,omitempty"`
}

OverviewRow defines a row in the report's overview section it can consist of a description and some details where the details can have a style attached

type PolicyViolationLicense

type PolicyViolationLicense struct {
	LicenseName          string   `json:"licenseName"`
	ViolatingPolicyNames []string `json:"violatingPolicyNames"`
	Meta                 Meta     `json:"_meta"`
}

type PolicyViolationReport

type PolicyViolationReport struct {
	ArtifactID       string
	Branch           string
	CommitID         string
	Description      string
	DirectDependency string
	Footer           string
	Group            string
	PackageURL       string
	PipelineName     string
	PipelineLink     string
	Version          string
}

func (*PolicyViolationReport) ToMarkdown

func (p *PolicyViolationReport) ToMarkdown() ([]byte, error)

type PolicyViolationVulnerability

type PolicyViolationVulnerability struct {
	Name                 string   `json:"name"`
	ViolatingPolicyNames []string `json:"ViolatingPolicyNames"`
	WarningMessage       string   `json:"warningMessage"`
	ErrorMessage         string   `json:"errorMessage"`
	Meta                 Meta     `json:"_meta"`
}

type RapidScanReport

type RapidScanReport struct {
	Success bool

	ExecutedTime string

	MainTableHeaders []string
	MainTableValues  [][]string

	VulnerabilitiesTable []Vulnerabilities
	LicensesTable        []Licenses
	OtherViolationsTable []OtherViolations
}

RapidScanReport - for commenting to pull requests

type ScanCell

type ScanCell struct {
	Content string      `json:"content"`
	Style   ColumnStyle `json:"style"`
}

ScanCell defines one column of a scan result table

type ScanDetailTable

type ScanDetailTable struct {
	Headers       []string  `json:"headers"`
	Rows          []ScanRow `json:"rows"`
	WithCounter   bool      `json:"withCounter"`
	CounterHeader string    `json:"counterHeader"`
	NoRowsMessage string    `json:"noRowsMessage"`
}

ScanDetailTable defines a table containing scan result details

type ScanReport

type ScanReport struct {
	StepName       string          `json:"stepName"`
	ReportTitle    string          `json:"title"`
	Subheaders     []Subheader     `json:"subheaders"`
	Overview       []OverviewRow   `json:"overview"`
	FurtherInfo    string          `json:"furtherInfo"`
	ReportTime     time.Time       `json:"reportTime"`
	DetailTable    ScanDetailTable `json:"detailTable"`
	SuccessfulScan bool            `json:"successfulScan"`
}

ScanReport defines the elements of a scan report used by various scan steps

func (*ScanReport) AddSubHeader

func (s *ScanReport) AddSubHeader(header, details string)

AddSubHeader adds a sub header to the report containing of a text/title plus optional details

func (ScanReport) Title

func (s ScanReport) Title() string

Title returns the title of the report

func (*ScanReport) ToHTML

func (s *ScanReport) ToHTML() ([]byte, error)

ToHTML creates a HTML version of the report

func (*ScanReport) ToJSON

func (s *ScanReport) ToJSON() ([]byte, error)

ToJSON returns the report in JSON format

func (ScanReport) ToMarkdown

func (s ScanReport) ToMarkdown() ([]byte, error)

ToMarkdown creates a markdown version of the report content

func (ScanReport) ToTxt

func (s ScanReport) ToTxt() string

ToTxt up to now returns the report in JSON format

type ScanRow

type ScanRow struct {
	Columns []ScanCell `json:"columns"`
}

ScanRow defines one row of a scan result table

func (*ScanRow) AddColumn

func (s *ScanRow) AddColumn(content interface{}, style ColumnStyle)

AddColumn adds a column to a dedicated ScanRow

type Subheader

type Subheader struct {
	Description string `json:"text"`
	Details     string `json:"details,omitempty"`
}

Subheader defines a dedicated sub header in a report

type Vulnerabilities

type Vulnerabilities struct {
	PolicyViolationName string
	Values              []Vulnerability
}

type Vulnerability

type Vulnerability struct {
	VulnerabilityID    string
	VulnerabilityScore string
	ComponentName      string
	VulnerabilityHref  string
}

type VulnerabilityReport

type VulnerabilityReport struct {
	ProjectName          string
	ProjectVersion       string
	BlackDuckProjectLink string
	ArtifactID           string
	Branch               string
	CommitID             string
	Description          string
	DependencyType       string
	Footer               string
	Group                string
	PackageURL           string
	PipelineName         string
	PipelineLink         string
	PublishDate          string
	Resolution           string
	Score                float64
	Severity             string
	Version              string
	VulnerabilityLink    string
	VulnerabilityName    string
	Origin               string
}

VulnerabilityReport represents metadata for a report on a vulnerability

func (*VulnerabilityReport) ToMarkdown

func (v *VulnerabilityReport) ToMarkdown() ([]byte, error)

ToMarkdown creates a vulnerability in markdown format which can be used in GitHub issues

Jump to

Keyboard shortcuts

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