Skip to content

🌐 Ecosystem

Ecosystem identifies the package manager / registry a software package belongs to — a core concept for PURL and SBOM handling. This module declares the Ecosystem type, all exported ecosystem constants, the EcosystemInfo metadata struct, and helpers for lookup, normalization, and CPE-based hinting.

Type: Ecosystem

go
type Ecosystem string

A string-typed identifier for a package ecosystem.

Constants

go
const (
    EcosystemNPM      Ecosystem = "npm"
    EcosystemMaven    Ecosystem = "maven"
    EcosystemPyPI     Ecosystem = "pypi"
    EcosystemGo       Ecosystem = "golang"
    EcosystemNuGet    Ecosystem = "nuget"
    EcosystemDocker   Ecosystem = "docker"
    EcosystemRubyGems Ecosystem = "gem"
    EcosystemCargo    Ecosystem = "cargo"
    EcosystemComposer Ecosystem = "composer"
    EcosystemConan    Ecosystem = "conan"
    EcosystemConda    Ecosystem = "conda"
    EcosystemHex      Ecosystem = "hex"
    EcosystemPub      Ecosystem = "pub"
    EcosystemSwift    Ecosystem = "swift"
    EcosystemAlpine   Ecosystem = "alpine"
    EcosystemDebian   Ecosystem = "deb"
    EcosystemRPM      Ecosystem = "rpm"
    EcosystemGeneric  Ecosystem = "generic"
)
ConstantValueDescription
EcosystemNPMnpmNode.js package manager (npm)
EcosystemMavenmavenJava/Kotlin projects (Maven Central, Google Android)
EcosystemPyPIpypiPython Package Index
EcosystemGogolangGo modules
EcosystemNuGetnuget.NET package manager
EcosystemDockerdockerDocker container images
EcosystemRubyGemsgemRuby package manager
EcosystemCargocargoRust package manager
EcosystemComposercomposerPHP package manager
EcosystemConanconanC/C++ package manager
EcosystemCondacondaCross-language package manager
EcosystemHexhexElixir/Erlang ecosystem
EcosystemPubpubDart/Flutter package manager
EcosystemSwiftswiftSwift package manager
EcosystemAlpinealpineAlpine Linux (apk) packages
EcosystemDebiandebDebian/Ubuntu (deb) packages
EcosystemRPMrpmRed Hat/Fedora (rpm) packages
EcosystemGenericgenericGeneric / unknown ecosystem

Type: EcosystemInfo

go
type EcosystemInfo struct {
    Name        string
    FullName    string
    RegistryURL string
    PURLType    string
}
FieldTypeDescription
NamestringEcosystem name
FullNamestringEcosystem full name
RegistryURLstringDefault registry URL
PURLTypestringPURL type field value

ℹ️ GetEcosystemInfo

go
func GetEcosystemInfo(ecosystem Ecosystem) (EcosystemInfo, error)

Returns the metadata for the given ecosystem.

ParameterTypeDescription
ecosystemEcosystemThe ecosystem to look up
ReturnTypeDescription
#1EcosystemInfoThe ecosystem metadata, zero-value on error
#2errorNon-nil if the ecosystem is unknown
go
info, err := cpeskills.GetEcosystemInfo(cpeskills.EcosystemMaven)
if err != nil {
    log.Fatal(err)
}
fmt.Println(info.FullName, info.RegistryURL)
// Maven Central https://repo.maven.apache.org/maven2

📜 ListEcosystems

go
func ListEcosystems() []Ecosystem

Returns all registered ecosystems. The order is not specified (map iteration order).

ReturnTypeDescription
#1[]EcosystemAll registered ecosystems
go
for _, eco := range cpeskills.ListEcosystems() {
    fmt.Println(eco)
}

🔁 EcosystemFromPURLType

go
func EcosystemFromPURLType(purlType string) Ecosystem

Maps a PURL type field to an Ecosystem, returning EcosystemGeneric when no ecosystem matches.

ParameterTypeDescription
purlTypestringThe PURL type string
ReturnTypeDescription
#1EcosystemThe matching ecosystem, or EcosystemGeneric
go
fmt.Println(cpeskills.EcosystemFromPURLType("cargo")) // cargo
fmt.Println(cpeskills.EcosystemFromPURLType("unknown")) // generic

✅ IsEcosystemSupported

go
func IsEcosystemSupported(ecosystem Ecosystem) bool

Reports whether the ecosystem is registered.

ParameterTypeDescription
ecosystemEcosystemThe ecosystem to check
ReturnTypeDescription
#1booltrue if the ecosystem is registered
go
fmt.Println(cpeskills.IsEcosystemSupported(cpeskills.EcosystemNPM)) // true

💡 CPEPartToEcosystemHint

go
func CPEPartToEcosystemHint(part *Part) []Ecosystem

Returns a heuristic list of ecosystems that a CPE Part might belong to, used to assist CPE→PURL mapping. Applications (a) map to most package ecosystems; operating systems (o) map to Linux-distribution ecosystems; hardware (h) maps to EcosystemGeneric. Returns nil when part is nil.

ParameterTypeDescription
part*PartThe CPE part
ReturnTypeDescription
#1[]EcosystemCandidate ecosystems, or nil if part is nil
go
hints := cpeskills.CPEPartToEcosystemHint(cpeskills.PartApplication)
fmt.Println(hints) // [npm maven pypi golang ...]

🧹 NormalizeEcosystemName

go
func NormalizeEcosystemName(name string) (Ecosystem, error)

Normalizes an ecosystem name, accepting common aliases such as node.jsEcosystemNPM, javaEcosystemMaven, pythonEcosystemPyPI. Falls back to a direct Ecosystem(name) match when no alias applies.

ParameterTypeDescription
namestringThe name or alias to normalize
ReturnTypeDescription
#1EcosystemThe normalized ecosystem, empty on error
#2errorNon-nil if the name is unknown
go
eco, err := cpeskills.NormalizeEcosystemName("node.js")
if err != nil {
    log.Fatal(err)
}
fmt.Println(eco) // npm

📐 Ecosystem Registry Diagram

Released under the MIT License.