Documentation
¶
Index ¶
- Constants
- Variables
- func ArtifactPurl(scanner string, assetName string) string
- func BeautifyPURL(pURL string) (string, error)
- func ConvertRPMtoSemVer(rpm string) (string, error)
- func ConvertToSemver(originalVersion string) string
- func DeepSort(el any) any
- func FixFixedVersion(purl string, fixedVersion *string) *string
- func MapCDXToEventType(a *cdx.VulnerabilityAnalysis) string
- func MapCDXToVulnStatus(a *cdx.VulnerabilityAnalysis) string
- func PackageToPurl(ecosystem, packageName string) string
- func Purl(component cdx.Component) string
- func PurlToEcosystem(purlType string) string
- func Purlify(artifactName string, assetVersionName string) string
- func RemoveOriginTypePrefixIfExists(origin string) (nodeType, string)
- func SemverFix(version string) (string, error)
- func SemverSort(versions []string)
- func SortStringsSlice(slice []string) []string
- func StructuralCompareCdxBoms(a, b *cdx.BOM) error
- type CdxBom
- func (bom *CdxBom) AddChild(parent *TreeNode[cdxBomNode], child *TreeNode[cdxBomNode])
- func (bom *CdxBom) AddDirectChildWhichInheritsChildren(parent cdxBomNode, child cdxBomNode)
- func (bom *CdxBom) AddSourceChildrenToTarget(source *TreeNode[cdxBomNode], target *TreeNode[cdxBomNode])
- func (bom *CdxBom) CalculateDepth() map[string]int
- func (bom *CdxBom) CountParentTypes() map[string]map[nodeType]int
- func (bom *CdxBom) EjectMinimalDependencyTree() *minimalTreeNode
- func (bom *CdxBom) EjectSBOM(assetID *uuid.UUID) *cdx.BOM
- func (bom *CdxBom) EjectVex(assetID *uuid.UUID) *cdx.BOM
- func (bom *CdxBom) GetAllParentNodes(nodeID string) []string
- func (bom *CdxBom) GetComponents() *[]cdx.Component
- func (bom *CdxBom) GetComponentsIncludingFakeNodes() *[]cdx.Component
- func (bom *CdxBom) GetCsafRootPurls() []string
- func (bom *CdxBom) GetDependencies() *[]cdx.Dependency
- func (bom *CdxBom) GetDependenciesIncludingFakeNodes() *[]cdx.Dependency
- func (bom *CdxBom) GetDependenciesOfComponent(componentRef string) *cdx.Dependency
- func (bom *CdxBom) GetDirectDependencies() *[]cdx.Dependency
- func (bom *CdxBom) GetInformationSourceNodes() []*TreeNode[cdxBomNode]
- func (bom *CdxBom) GetInformationSources() []string
- func (bom *CdxBom) GetMetadata() *cdx.Metadata
- func (bom *CdxBom) GetTransitiveDependencies() *[]cdx.Dependency
- func (bom *CdxBom) GetVulnerabilities() *[]cdx.Vulnerability
- func (bom *CdxBom) InformationFromVexOrMultipleSBOMs() []string
- func (bom *CdxBom) ReplaceOrAddInformationSourceNode(subTree *TreeNode[cdxBomNode])
- func (bom *CdxBom) ReplaceRoot(newRoot cdxBomNode)
- type Node
- type Tree
- func (tree *Tree[Element]) AddChild(parent *TreeNode[Element], child *TreeNode[Element])
- func (tree *Tree[Element]) AddDirectChildWhichInheritsChildren(parent Element, child Element)
- func (tree *Tree[Element]) AddSourceChildrenToTarget(source *TreeNode[Element], target *TreeNode[Element])
- func (tree *Tree[Data]) Reachable(id string) bool
- func (tree *Tree[Data]) RenderToMermaid() string
- func (tree *Tree[Element]) ReplaceNode(old *TreeNode[Element], new *TreeNode[Element])
- func (tree *Tree[Element]) ReplaceRoot(node Element)
- func (tree *Tree[Element]) ReplaceSubtree(other *TreeNode[Element])
- func (tree *Tree[Element]) Visitable() ([]string, []string)
- type TreeNode
Constants ¶
View Source
const ( NodeTypeComponent nodeType = "component" NodeTypeSbomInformationSource nodeType = "sbom" NodeTypeVexInformationSource nodeType = "vex" NodeTypeCSAFInformationSource nodeType = "csaf" NodeTypeUnknown nodeType = "unknown" )
Variables ¶
View Source
var (
ErrInvalidVersion = fmt.Errorf("invalid version")
)
View Source
var PURLEcosystems = map[string]string{
"Alpine": "apk",
"crates.io": "cargo",
"Debian": "deb",
"Go": "golang",
"Hackage": "hackage",
"Hex": "hex",
"Maven": "maven",
"npm": "npm",
"NuGet": "nuget",
"OSS-Fuzz": "generic",
"Packagist": "composer",
"Pub": "pub",
"PyPI": "pypi",
"RubyGems": "gem",
}
View Source
var ValidSemverRegex = regexp.MustCompile(`^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`)
Regex for validating a correct semver.
Functions ¶
func ArtifactPurl ¶
func BeautifyPURL ¶
function to make purl look more visually appealing
func ConvertRPMtoSemVer ¶
func ConvertToSemver ¶
ConvertToSemver converts any versioning scheme to a semver-like versioning scheme
func DeepSort ¶
this is a deep sort function that sorts all maps and slices recursively it is REALLY expensive, so use it wisely! it treats any arrays as sets and sorts them by their canonical JSON representation
func FixFixedVersion ¶
func MapCDXToEventType ¶
func MapCDXToEventType(a *cdx.VulnerabilityAnalysis) string
func MapCDXToVulnStatus ¶
func MapCDXToVulnStatus(a *cdx.VulnerabilityAnalysis) string
map CycloneDX Analysis State / Response to internal status strings used by CreateVulnEventAndApply
func PackageToPurl ¶
func PurlToEcosystem ¶
func SemverSort ¶
func SemverSort(versions []string)
func SortStringsSlice ¶
Types ¶
type CdxBom ¶
type CdxBom struct {
// contains filtered or unexported fields
}
func (*CdxBom) AddDirectChildWhichInheritsChildren ¶
func (bom *CdxBom) AddDirectChildWhichInheritsChildren(parent cdxBomNode, child cdxBomNode)
func (*CdxBom) AddSourceChildrenToTarget ¶
func (*CdxBom) CalculateDepth ¶
func (*CdxBom) CountParentTypes ¶
func (*CdxBom) EjectMinimalDependencyTree ¶
func (bom *CdxBom) EjectMinimalDependencyTree() *minimalTreeNode
func (*CdxBom) GetAllParentNodes ¶
func (*CdxBom) GetComponents ¶
func (*CdxBom) GetComponentsIncludingFakeNodes ¶
func (*CdxBom) GetCsafRootPurls ¶
this returns direct csaf children of csaf information source nodes since csaf does not scope transitive dependencies but we might be able to redistribute found cves to the subtree reachable from those purls.
func (*CdxBom) GetDependencies ¶
func (bom *CdxBom) GetDependencies() *[]cdx.Dependency
func (*CdxBom) GetDependenciesIncludingFakeNodes ¶
func (bom *CdxBom) GetDependenciesIncludingFakeNodes() *[]cdx.Dependency
func (*CdxBom) GetDependenciesOfComponent ¶
func (bom *CdxBom) GetDependenciesOfComponent(componentRef string) *cdx.Dependency
func (*CdxBom) GetDirectDependencies ¶
func (bom *CdxBom) GetDirectDependencies() *[]cdx.Dependency
func (*CdxBom) GetInformationSourceNodes ¶
func (*CdxBom) GetInformationSources ¶
func (*CdxBom) GetMetadata ¶
func (*CdxBom) GetTransitiveDependencies ¶
func (bom *CdxBom) GetTransitiveDependencies() *[]cdx.Dependency
func (*CdxBom) GetVulnerabilities ¶
func (bom *CdxBom) GetVulnerabilities() *[]cdx.Vulnerability
func (*CdxBom) InformationFromVexOrMultipleSBOMs ¶
func (*CdxBom) ReplaceOrAddInformationSourceNode ¶
func (*CdxBom) ReplaceRoot ¶
func (bom *CdxBom) ReplaceRoot(newRoot cdxBomNode)
type Tree ¶
type Tree[Element Node] struct { Root *TreeNode[Element] `json:"root"` // contains filtered or unexported fields }
func BuildDependencyTree ¶
func (*Tree[Element]) AddDirectChildWhichInheritsChildren ¶
func (tree *Tree[Element]) AddDirectChildWhichInheritsChildren(parent Element, child Element)
func (*Tree[Element]) AddSourceChildrenToTarget ¶
func (*Tree[Data]) RenderToMermaid ¶
func (*Tree[Element]) ReplaceNode ¶
func (*Tree[Element]) ReplaceRoot ¶
func (tree *Tree[Element]) ReplaceRoot(node Element)
func (*Tree[Element]) ReplaceSubtree ¶
Click to show internal directories.
Click to hide internal directories.