reporter

package
v1.12.21 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 62 Imported by: 1

Documentation

Overview

Package reporter provides a contract for implementing reporting modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoldText added in v1.12.7

func BoldText(s string) string

BoldText returns text with bold styling

func CriticalBgText added in v1.12.7

func CriticalBgText(s string) string

CriticalBgText returns text with critical severity background

func CriticalText added in v1.12.7

func CriticalText(s string) string

CriticalText returns text with critical severity foreground

func FaintText added in v1.12.7

func FaintText(s string) string

FaintText returns text with faint/dim styling

func HighBgText added in v1.12.7

func HighBgText(s string) string

HighBgText returns text with high severity background

func InfoBgText added in v1.12.7

func InfoBgText(s string) string

InfoBgText returns text with info background

func InfoText added in v1.12.7

func InfoText(s string) string

InfoText returns text with info foreground

func LowBgText added in v1.12.7

func LowBgText(s string) string

LowBgText returns text with low severity background

func MagentaBgText added in v1.12.7

func MagentaBgText(s string) string

MagentaBgText returns text with magenta background

func MediumBgText added in v1.12.7

func MediumBgText(s string) string

MediumBgText returns text with medium severity background

func NewGitLabReporter added in v1.9.9

func NewGitLabReporter(config GitLabReporterConfig) (*gitLabReporter, error)

func NewSkillReporter added in v1.12.17

func NewSkillReporter(config SkillReporterConfig) *skillReporter

NewSkillReporter creates a new skill reporter

func NewSyncReporter added in v1.1.0

func NewSyncReporter(config SyncReporterConfig, envResolver SyncReporterEnvResolver, callbacks SyncReporterCallbacks) (*syncReporter, error)

NewSyncReporter creates a new sync reporter.

func SuccessBgText added in v1.12.7

func SuccessBgText(s string) string

SuccessBgText returns text with success background

func WarningBgText added in v1.12.7

func WarningBgText(s string) string

WarningBgText returns text with warning background

func WarningText added in v1.12.7

func WarningText(s string) string

WarningText returns text with warning color

func WhiteBgText added in v1.12.7

func WhiteBgText(s string) string

WhiteBgText returns text with white background

func WriteTemplToFile added in v1.12.3

func WriteTemplToFile(component interface {
	Render(ctx context.Context, w io.Writer) error
}, path string,
) error

WriteTemplToFile renders a templ component to a file

Types

type ColorConfig added in v1.12.7

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

ColorConfig holds the terminal color configuration

func GetColorConfig added in v1.12.7

func GetColorConfig() *ColorConfig

GetColorConfig returns the global color configuration

func (*ColorConfig) BoldText added in v1.12.7

func (c *ColorConfig) BoldText(s string) string

BoldText returns text with bold styling

func (*ColorConfig) CriticalBgText added in v1.12.7

func (c *ColorConfig) CriticalBgText(s string) string

CriticalBgText returns text with critical severity background

func (*ColorConfig) CriticalText added in v1.12.7

func (c *ColorConfig) CriticalText(s string) string

CriticalText returns text with critical severity foreground

func (*ColorConfig) FaintText added in v1.12.7

func (c *ColorConfig) FaintText(s string) string

FaintText returns text with faint/dim styling

func (*ColorConfig) HighBgText added in v1.12.7

func (c *ColorConfig) HighBgText(s string) string

HighBgText returns text with high severity background

func (*ColorConfig) InfoBgText added in v1.12.7

func (c *ColorConfig) InfoBgText(s string) string

InfoBgText returns text with info background Note: Uses cyan instead of blue for ANSI256/TrueColor to improve visibility on dark terminals. Blue backgrounds have poor contrast on dark terminal themes (see issue #537).

func (*ColorConfig) InfoText added in v1.12.7

func (c *ColorConfig) InfoText(s string) string

InfoText returns text with info foreground Note: Uses cyan instead of blue for ANSI256/TrueColor to improve visibility on dark terminals. Blue text has poor contrast on dark terminal themes (see issue #537).

func (*ColorConfig) LowBgText added in v1.12.7

func (c *ColorConfig) LowBgText(s string) string

LowBgText returns text with low severity background Note: Uses cyan instead of blue for ANSI256/TrueColor to improve visibility on dark terminals. Blue backgrounds have poor contrast on dark terminal themes (see issue #537).

func (*ColorConfig) MagentaBgText added in v1.12.7

func (c *ColorConfig) MagentaBgText(s string) string

MagentaBgText returns text with tag background Note: Uses cyan instead of magenta for ANSI256/TrueColor to improve visibility on dark terminals. Magenta/pink backgrounds have poor contrast on dark terminal themes (see issue #537).

func (*ColorConfig) MediumBgText added in v1.12.7

func (c *ColorConfig) MediumBgText(s string) string

MediumBgText returns text with medium severity background

func (*ColorConfig) SuccessBgText added in v1.12.7

func (c *ColorConfig) SuccessBgText(s string) string

SuccessBgText returns text with success background

func (*ColorConfig) WarningBgText added in v1.12.7

func (c *ColorConfig) WarningBgText(s string) string

WarningBgText returns text with warning background

func (*ColorConfig) WarningText added in v1.12.7

func (c *ColorConfig) WarningText(s string) string

WarningText returns text with warning color

func (*ColorConfig) WhiteBgText added in v1.12.7

func (c *ColorConfig) WhiteBgText(s string) string

WhiteBgText returns text with white background

type CsvReportingConfig added in v1.0.0

type CsvReportingConfig struct {
	Path string
}

type CycloneDXReporterConfig added in v1.10.0

type CycloneDXReporterConfig struct {
	Tool ToolMetadata

	// Path defines the output file path
	Path string

	// Application component name, this is the top-level component in the BOM
	ApplicationComponentName string

	// Unique identifier for this BOM confirming to UUID RFC 4122 standard
	// If empty, a new UUID will be generated
	SerialNumber string
}

CycloneDXReporterConfig contains configuration parameters for the CycloneDX reporter

type DefectDojoProduct added in v1.9.7

type DefectDojoProduct struct {
	ID            int       `json:"id"`
	FindingsCount int       `json:"findings_count"`
	FindingsList  []int     `json:"findings_list"`
	Tags          []string  `json:"tags"`
	Name          string    `json:"name"`
	Description   string    `json:"description"`
	Created       time.Time `json:"created"`
}

type DefectDojoReporterConfig added in v1.9.7

type DefectDojoReporterConfig struct {
	Tool               ToolMetadata
	IncludeVulns       bool
	IncludeMalware     bool
	ProductID          int
	EngagementName     string
	DefectDojoHostUrl  string
	DefectDojoApiV2Key string
}

type GitLabReporterConfig added in v1.9.9

type GitLabReporterConfig struct {
	Path string // Report path, value of --report-gitlab
	Tool ToolMetadata
}

type HtmlReportingConfig added in v1.12.3

type HtmlReportingConfig struct {
	Path string // Output path for HTML file
}

type JsonReportingConfig added in v1.2.0

type JsonReportingConfig struct {
	Path string
	Tool ToolMetadata
}

type MarkdownReportingConfig

type MarkdownReportingConfig struct {
	Path string
}

type MarkdownSummaryReporterConfig added in v1.5.7

type MarkdownSummaryReporterConfig struct {
	Tool                   ToolMetadata
	Path                   string
	ReportTitle            string
	IncludeMalwareAnalysis bool
	ActiveMalwareAnalysis  bool
}

type Reporter

type Reporter interface {
	Name() string

	// Feed collected data to reporting module
	AddManifest(manifest *models.PackageManifest)
	AddAnalyzerEvent(event *analyzer.AnalyzerEvent)
	AddPolicyEvent(event *policy.PolicyEvent)

	// Inform reporting module to finalise (e.g. write report to file)
	Finish() error
}

func NewConsoleReporter

func NewConsoleReporter() (Reporter, error)

func NewCsvReporter added in v1.0.0

func NewCsvReporter(config CsvReportingConfig) (Reporter, error)

func NewCycloneDXReporter added in v1.10.0

func NewCycloneDXReporter(config CycloneDXReporterConfig) (Reporter, error)

func NewDefectDojoReporter added in v1.9.7

func NewDefectDojoReporter(config DefectDojoReporterConfig) (Reporter, error)

func NewDotGraphReporter added in v1.5.6

func NewDotGraphReporter(directory string) (Reporter, error)

func NewHtmlReporter added in v1.12.3

func NewHtmlReporter(config HtmlReportingConfig) (Reporter, error)

func NewJsonReportGenerator added in v1.2.0

func NewJsonReportGenerator(config JsonReportingConfig) (Reporter, error)

func NewMarkdownReportGenerator

func NewMarkdownReportGenerator(config MarkdownReportingConfig) (Reporter, error)

func NewMarkdownSummaryReporter added in v1.5.7

func NewMarkdownSummaryReporter(config MarkdownSummaryReporterConfig) (Reporter, error)

NewMarkdownSummaryReporter creates a new markdown summary reporter. This reporter is suitable for generating markdown reports intended for PR comments.

func NewSarifReporter added in v1.6.0

func NewSarifReporter(config SarifReporterConfig) (Reporter, error)

func NewSqlite3Reporter added in v1.12.0

func NewSqlite3Reporter(config Sqlite3ReporterConfig) (Reporter, error)

func NewSummaryReporter

func NewSummaryReporter(config SummaryReporterConfig) (Reporter, error)

type SarifReporterConfig added in v1.6.0

type SarifReporterConfig struct {
	Tool           ToolMetadata
	IncludeVulns   bool
	IncludeMalware bool
	Path           string
}

type Severity added in v1.9.9

type Severity string

Severity represents severity of a vulnerability or malware

const (
	SeverityUnknown  Severity = "Unknown"
	SeverityCritical Severity = "Critical"
	SeverityHigh     Severity = "High"
	SeverityMedium   Severity = "Medium"
	SeverityLow      Severity = "Low"
	SeverityInfo     Severity = "Info"
)

type SkillReporterConfig added in v1.12.17

type SkillReporterConfig struct {
	// Whether to show detailed evidence in output
	ShowEvidence bool
}

SkillReporterConfig configures the skill reporter

func DefaultSkillReporterConfig added in v1.12.17

func DefaultSkillReporterConfig() SkillReporterConfig

DefaultSkillReporterConfig returns the default configuration

type Sqlite3ReporterConfig added in v1.12.0

type Sqlite3ReporterConfig struct {
	Path      string
	Tool      ToolMetadata
	Overwrite bool
	Append    bool
}

type SummaryReporterConfig added in v1.3.0

type SummaryReporterConfig struct {
	MaxAdvice               int
	GroupByDirectDependency bool

	// This requires code analysis to be enabled with dependency
	// usage evidences to be available
	ShowOnlyPackagesWithEvidence bool
}

type SyncReporterCallbacks added in v1.9.7

type SyncReporterCallbacks struct {
	OnSyncStart       func()
	OnSyncFinish      func()
	OnPackageSync     func(pkg *models.Package)
	OnPackageSyncDone func(pkg *models.Package)
	OnEventSync       func(event *analyzer.AnalyzerEvent)
	OnEventSyncDone   func(event *analyzer.AnalyzerEvent)
}

SyncReporterCallbacks are effects trigger during Cloud Sync Report Process This is primarily used to show progress bar on the terminal

type SyncReporterConfig added in v1.1.0

type SyncReporterConfig struct {
	// gRPC connection for ControlTower
	ClientConnection *grpc.ClientConn

	// Enable multi-project syncing
	// In this case, a new project is created per package manifest
	EnableMultiProjectSync bool

	// Required when scanning a single project
	ProjectName    string
	ProjectVersion string

	// Performance
	WorkerCount int

	// Tool details
	Tool ToolMetadata
}

SyncReporterConfig defines the configuration for the sync reporter.

type SyncReporterEnvResolver added in v1.11.0

type SyncReporterEnvResolver interface {
	// The resolved source of the runtime environment (e.g. GitHub)
	GetProjectSource() controltowerv1pb.Project_Source

	// The resolved URL of the runtime environment (e.g. GitHub repository URL)
	GetProjectURL() string

	// The trigger of the runtime environment (e.g. CI/CD pipeline)
	Trigger() controltowerv1.ToolTrigger

	// The Git reference of the runtime environment (e.g. branch, tag, commit)
	GitRef() string

	// The Git SHA of the runtime environment (e.g. commit hash)
	GitSha() string
}

SyncReporterEnvResolver defines the contract for implementing environment resolver for the sync reporter. Here we decouple the actual implementation of the resolver to the client that uses the reporter plugin. The resolver is used to provide environment awareness to the reporter. For example, when running in GitHub or on a Git repository, the resolver can provide the project source, project and other information that is required to create a tool session.

func DefaultSyncReporterEnvResolver added in v1.11.0

func DefaultSyncReporterEnvResolver() SyncReporterEnvResolver

DefaultSyncReporterEnvResolver returns the default environment resolver for the sync reporter. This is used when no environment resolver is provided.

func GithubActionsSyncReporterResolver added in v1.12.0

func GithubActionsSyncReporterResolver() SyncReporterEnvResolver

func NewSyncReporterEnvironmentResolver added in v1.12.0

func NewSyncReporterEnvironmentResolver() SyncReporterEnvResolver

type ToolMetadata added in v1.10.0

type ToolMetadata struct {
	Name                 string
	Version              string
	Purl                 string
	InformationURI       string
	VendorName           string
	VendorInformationURI string
}

Directories

Path Synopsis
templ: version: v0.3.924
templ: version: v0.3.924

Jump to

Keyboard shortcuts

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