normalize

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTypeComponent             nodeType = "component"
	NodeTypeSbomInformationSource nodeType = "sbom"
	NodeTypeVexInformationSource  nodeType = "vex"
	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 added in v0.17.0

func ArtifactPurl(scanner string, assetName string) string

func BeautifyPURL added in v0.19.0

func BeautifyPURL(pURL string) (string, error)

function to make purl look more visually appealing

func ConvertToSemver

func ConvertToSemver(originalVersion string) string

ConvertToSemver converts any versioning scheme to a semver-like versioning scheme

func FixFixedVersion added in v0.17.0

func FixFixedVersion(purl string, fixedVersion *string) *string

func MapCDXToEventType added in v0.19.0

func MapCDXToEventType(a *cdx.VulnerabilityAnalysis) string

func MapCDXToVulnStatus added in v0.19.0

func MapCDXToVulnStatus(a *cdx.VulnerabilityAnalysis) string

map CycloneDX Analysis State / Response to internal status strings used by CreateVulnEventAndApply

func PackageToPurl

func PackageToPurl(ecosystem, packageName string) string

func Purl

func Purl(component cdx.Component) string

func PurlToEcosystem

func PurlToEcosystem(purlType string) string

func RemoveOriginTypePrefixIfExists added in v0.19.0

func RemoveOriginTypePrefixIfExists(origin string) (nodeType, string)

func SemverFix

func SemverFix(version string) (string, error)

func SemverSort added in v0.5.14

func SemverSort(versions []string)

func StructuralCompareCdxBoms added in v0.19.0

func StructuralCompareCdxBoms(a, b *cdx.BOM) error

Types

type CdxBom added in v0.19.0

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

func FromCdxBom

func FromCdxBom(bom *cdx.BOM, artifactName, informationSource string) *CdxBom

func FromNormalizedCdxBom added in v0.19.0

func FromNormalizedCdxBom(bom *cdx.BOM, artifactName string) *CdxBom

func MergeCdxBoms added in v0.17.0

func MergeCdxBoms(metadata *cdx.Metadata, boms ...*CdxBom) *CdxBom

func (*CdxBom) AddChild added in v0.19.0

func (bom *CdxBom) AddChild(parent *TreeNode[cdxBomNode], child *TreeNode[cdxBomNode])

func (*CdxBom) AddDirectChildWhichInheritsChildren added in v0.19.0

func (bom *CdxBom) AddDirectChildWhichInheritsChildren(parent cdxBomNode, child cdxBomNode)

func (*CdxBom) AddSourceChildrenToTarget added in v0.19.0

func (bom *CdxBom) AddSourceChildrenToTarget(source *TreeNode[cdxBomNode], target *TreeNode[cdxBomNode])

func (*CdxBom) CalculateDepth added in v0.19.0

func (bom *CdxBom) CalculateDepth() map[string]int

func (*CdxBom) CountParentTypes added in v0.19.0

func (bom *CdxBom) CountParentTypes() map[string]map[nodeType]int

func (*CdxBom) EjectMinimalDependencyTree added in v0.19.0

func (bom *CdxBom) EjectMinimalDependencyTree() *minimalTreeNode

func (*CdxBom) EjectSBOM added in v0.19.0

func (bom *CdxBom) EjectSBOM(assetID *uuid.UUID) *cdx.BOM

func (*CdxBom) EjectVex added in v0.19.0

func (bom *CdxBom) EjectVex(assetID *uuid.UUID) *cdx.BOM

func (*CdxBom) GetComponents added in v0.19.0

func (bom *CdxBom) GetComponents() *[]cdx.Component

func (*CdxBom) GetComponentsIncludingFakeNodes added in v0.19.0

func (bom *CdxBom) GetComponentsIncludingFakeNodes() *[]cdx.Component

func (*CdxBom) GetDependencies added in v0.19.0

func (bom *CdxBom) GetDependencies() *[]cdx.Dependency

func (*CdxBom) GetDependenciesIncludingFakeNodes added in v0.19.0

func (bom *CdxBom) GetDependenciesIncludingFakeNodes() *[]cdx.Dependency

func (*CdxBom) GetDependenciesOfComponent added in v0.19.0

func (bom *CdxBom) GetDependenciesOfComponent(componentRef string) *cdx.Dependency

func (*CdxBom) GetDirectDependencies added in v0.19.0

func (bom *CdxBom) GetDirectDependencies() *[]cdx.Dependency

func (*CdxBom) GetInformationSourceNodes added in v0.19.0

func (bom *CdxBom) GetInformationSourceNodes() []*TreeNode[cdxBomNode]

func (*CdxBom) GetInformationSources added in v0.19.0

func (bom *CdxBom) GetInformationSources() []string

func (*CdxBom) GetMetadata added in v0.19.0

func (bom *CdxBom) GetMetadata() *cdx.Metadata

func (*CdxBom) GetTransitiveDependencies added in v0.19.0

func (bom *CdxBom) GetTransitiveDependencies() *[]cdx.Dependency

func (*CdxBom) GetVulnerabilities added in v0.19.0

func (bom *CdxBom) GetVulnerabilities() *[]cdx.Vulnerability

func (*CdxBom) InformationFromVexOrMultipleSBOMs added in v0.19.0

func (bom *CdxBom) InformationFromVexOrMultipleSBOMs() []string

func (*CdxBom) ReplaceOrAddInformationSourceNode added in v0.19.0

func (bom *CdxBom) ReplaceOrAddInformationSourceNode(subTree *TreeNode[cdxBomNode])

func (*CdxBom) ReplaceRoot added in v0.19.0

func (bom *CdxBom) ReplaceRoot(newRoot cdxBomNode)

type Node added in v0.19.0

type Node interface {
	GetID() string
}

type Tree added in v0.19.0

type Tree[Element Node] struct {
	Root *TreeNode[Element] `json:"root"`
	// contains filtered or unexported fields
}

func BuildDependencyTree added in v0.19.0

func BuildDependencyTree[Element Node](root Element, elements []Element, depMap map[string][]string) Tree[Element]

func (*Tree[Element]) AddChild added in v0.19.0

func (tree *Tree[Element]) AddChild(parent *TreeNode[Element], child *TreeNode[Element])

func (*Tree[Element]) AddDirectChildWhichInheritsChildren added in v0.19.0

func (tree *Tree[Element]) AddDirectChildWhichInheritsChildren(parent Element, child Element)

func (*Tree[Element]) AddSourceChildrenToTarget added in v0.19.0

func (tree *Tree[Element]) AddSourceChildrenToTarget(source *TreeNode[Element], target *TreeNode[Element])

func (*Tree[Data]) Reachable added in v0.19.0

func (tree *Tree[Data]) Reachable(id string) bool

func (*Tree[Data]) RenderToMermaid added in v0.19.0

func (tree *Tree[Data]) RenderToMermaid() string

func (*Tree[Element]) ReplaceNode added in v0.19.0

func (tree *Tree[Element]) ReplaceNode(old *TreeNode[Element], new *TreeNode[Element])

func (*Tree[Element]) ReplaceRoot added in v0.19.0

func (tree *Tree[Element]) ReplaceRoot(node Element)

func (*Tree[Element]) ReplaceSubtree added in v0.19.0

func (tree *Tree[Element]) ReplaceSubtree(other *TreeNode[Element])

func (*Tree[Element]) Visitable added in v0.19.0

func (tree *Tree[Element]) Visitable() ([]string, []string)

type TreeNode added in v0.19.0

type TreeNode[Element Node] struct {
	ID       string               `json:"name"`
	Children []*TreeNode[Element] `json:"children"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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