util

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package util provides utility functions for import/export operations in the Ortelius CLI.

Package util provides utility functions for import/export operations in the Ortelius CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanName

func CleanName(name string) string

CleanName removes periods and dashes from the name, replacing with underscores

func CleanPURL

func CleanPURL(purlStr string) (string, error)

CleanPURL removes qualifiers (after ?) and subpath (after #) to create canonical PURL

func Contains

func Contains(slice []string, item string) bool

Contains checks if a string slice contains an item

func EcosystemToPurlType added in v1.0.1

func EcosystemToPurlType(ecosystem string) string

EcosystemToPurlType converts OSV ecosystem to PURL type

func ExtractChartVersion

func ExtractChartVersion(chartPath string) string

ExtractChartVersion extracts version from a Helm chart file

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists

func FindChartPath

func FindChartPath(shortname string) string

FindChartPath finds a Helm chart file

func FindFile

func FindFile(candidates []string) string

FindFile finds the first existing file from a list of candidates

func GetBasePURL added in v1.0.1

func GetBasePURL(purlStr string) (string, error)

GetBasePURL removes the version component from a PURL to create a base package identifier This is used for matching CVE PURLs (which lack versions) with SBOM component PURLs (which include versions) Example: pkg:npm/lodash@4.17.20 -> pkg:npm/lodash

func GetDerivedEnvMapping

func GetDerivedEnvMapping(mapping map[string]string) map[string]string

GetDerivedEnvMapping builds environment mapping with git metadata

func GetEnvDefault

func GetEnvDefault(key, defVal string) string

GetEnvDefault is a convenience function for handling env vars

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

GetEnvOrDefault returns environment variable value or default

func GetStringOrDefault

func GetStringOrDefault(value, defaultValue string) string

GetStringOrDefault returns value or default if empty

func IsEmpty

func IsEmpty(s string) bool

IsEmpty checks if a string is empty or contains only whitespace

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty checks if a string is not empty

func IsVersionAffected added in v1.0.1

func IsVersionAffected(version string, affected models.Affected) bool

IsVersionAffected checks if a version is affected by OSV ranges

func ParsePURL added in v1.0.1

func ParsePURL(purlStr string) (*packageurl.PackageURL, error)

ParsePURL parses a PURL string and returns the parsed PackageURL

func RunCmd

func RunCmd(cmd string) string

RunCmd executes a shell command and returns the trimmed output

Types

This section is empty.

Jump to

Keyboard shortcuts

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