commandsummary

package
v2.56.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// The name of the directory where all the commands summaries will be stored.
	// Inside this directory, each command will have its own directory.
	OutputDirName = "jfrog-command-summary"

	// Filenames formats
	SarifFileFormat   = "*.sarif"
	DataFileFormat    = "*-data"
	NoneScannedResult = "default"
)
View Source
const (
	NonScannedResult = "non-scanned"
)

Variables

View Source
var StaticMarkdownConfig = MarkdownConfig{}

Functions

func GenerateArtifactUrl

func GenerateArtifactUrl(pathInRt string) string

func InitMarkdownGenerationValues

func InitMarkdownGenerationValues(serverUrl string, platformMajorVersion int) (err error)

Initializes the command summary values that effect Markdown generation

func ShouldRecordSummary

func ShouldRecordSummary() bool

If the output dir path is not defined, the command summary should not be recorded.

func UnmarshalFromFilePath

func UnmarshalFromFilePath(dataFile string, target any) (err error)

Helper function to unmarshal data from a file path into the target object.

func WrapCollapsableMarkdown

func WrapCollapsableMarkdown(title, markdown string, headerSize int) string

Types

type BuildInfoSummary

type BuildInfoSummary struct {
	CommandSummary
}

func (*BuildInfoSummary) GenerateMarkdownFromFiles

func (bis *BuildInfoSummary) GenerateMarkdownFromFiles(dataFilePaths []string) (finalMarkdown string, err error)

func (*BuildInfoSummary) GetSummaryTitle

func (bis *BuildInfoSummary) GetSummaryTitle() string

type CommandSummary

type CommandSummary struct {
	CommandSummaryInterface
	// contains filtered or unexported fields
}

func New

func New(userImplementation CommandSummaryInterface, commandsName string) (cs *CommandSummary, err error)

Create a new instance of CommandSummary. Notice to check if the command should record the summary before calling this function. You can do this by calling the helper function ShouldRecordSummary.

func NewBuildInfoSummary

func NewBuildInfoSummary() (*CommandSummary, error)

func NewUploadSummary

func NewUploadSummary() (*CommandSummary, error)

func (*CommandSummary) GenerateMarkdown

func (cs *CommandSummary) GenerateMarkdown() error

Loads all the relevant data files and invoke the implementation to generate the Markdown.

func (*CommandSummary) GetDataFilesPaths

func (cs *CommandSummary) GetDataFilesPaths() ([]string, error)

func (*CommandSummary) Record

func (cs *CommandSummary) Record(data any) (err error)

This function stores the current data on the file system.

func (*CommandSummary) RecordWithIndex

func (cs *CommandSummary) RecordWithIndex(data any, summaryIndex Index, args ...string) (err error)

The RecordWithIndex function saves data into an indexed folder within the command summary directory. This allows you to associate specific indexed data with other recorded data using a key-value mapping. For example, when you have uploaded artifact and want to combine it with its scan results recorded at a different time, recording the scan results as an index helps merge the information later on.

Data: The data to be recorded. SummaryIndex: The name of the index under which the data will be stored. Args: Additional arguments used to determine the file name.

type CommandSummaryInterface

type CommandSummaryInterface interface {
	GenerateMarkdownFromFiles(dataFilePaths []string) (finalMarkdown string, err error)
}

To create a new command summary, the user must implement this interface. The GenerateMarkdownFromFiles function should be implemented to generate Markdown from the provided data file paths. This involves loading data from the files and converting it into a Markdown string.

type Index

type Index string

These optional index determine where files are saved, making them easier to locate. Each category corresponds to a nested folder within the current command summary structure.

For example, if the command summary is for the build-info command and the category is "DockerScan," the file will be saved in the following path: outputDirPath/jfrog-command-summary/build-info/Docker-Scan

const (
	BinariesScan Index = "binaries-scans"
	BuildScan    Index = "build-scans"
	DockerScan   Index = "docker-scans"
	SarifReport  Index = "sarif-reports"
)

type IndexedFilesMap

type IndexedFilesMap map[Index]map[string]string

Map containing indexed data recorded to the file system. The key is the index and the value is a map of file names as SHA1 to their full path.

func GetIndexedDataFilesPaths added in v2.55.7

func GetIndexedDataFilesPaths() (indexedFilePathsMap IndexedFilesMap, err error)

Retrieve all the indexed data files in the current command directory.

type MarkdownConfig

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

Static struct to hold the Markdown configuration values

func (*MarkdownConfig) GetExtendedSummaryLangPage

func (mg *MarkdownConfig) GetExtendedSummaryLangPage() string

func (*MarkdownConfig) GetPlatformMajorVersion

func (mg *MarkdownConfig) GetPlatformMajorVersion() int

func (*MarkdownConfig) GetPlatformUrl

func (mg *MarkdownConfig) GetPlatformUrl() string

func (*MarkdownConfig) IsExtendedSummary

func (mg *MarkdownConfig) IsExtendedSummary() bool

func (*MarkdownConfig) SetScanResultsMapping

func (mg *MarkdownConfig) SetScanResultsMapping(resultsMap map[string]ScanResult)

type ResultsWrapper

type ResultsWrapper struct {
	Results []UploadResult `json:"results"`
}

type ScanResult

type ScanResult interface {
	GetViolations() string
	GetVulnerabilities() string
}

Each scan result object can be used to generate violations or vulnerabilities.

type ScanResultMarkdownInterface

type ScanResultMarkdownInterface interface {
	BuildScan(filePaths []string) (result ScanResult)
	DockerScan(filePaths []string) (result ScanResult)
	BinaryScan(filePaths []string) (result ScanResult)
	// Default non scanned component view
	GetNonScanned() (nonScanned ScanResult)
}

This interface is used to accumulate scan results from different sources and generate a Markdown summary

type UploadResult

type UploadResult struct {
	SourcePath string `json:"sourcePath"`
	TargetPath string `json:"targetPath"`
	RtUrl      string `json:"rtUrl"`
}

type UploadSummary

type UploadSummary struct {
	CommandSummary
	// contains filtered or unexported fields
}

func (*UploadSummary) GenerateMarkdownFromFiles

func (us *UploadSummary) GenerateMarkdownFromFiles(dataFilePaths []string) (markdown string, err error)

func (*UploadSummary) GetSummaryTitle

func (us *UploadSummary) GetSummaryTitle() string

Jump to

Keyboard shortcuts

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