Documentation
¶
Overview ¶
Package hostdetect provides git hosting provider detection utilities. This package is used for consistent provider identification across: - SBOM generation (supplier extraction) - PURL creation (package type detection) - CVE/vulnerability scanning (ecosystem detection for OSV.dev)
The detection supports both well-known hosts (github.com, gitlab.com, bitbucket.org) and self-hosted/enterprise instances (e.g., gitlab.internal.corp, github.enterprise.com).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsKnownProvider ¶
IsKnownProvider returns true if the provider is a recognized hosting service (not ProviderUnknown). This is useful for determining if PURL type should be specific (github, gitlab, bitbucket) or generic.
func SupportsCVEScanning ¶
SupportsCVEScanning returns true if the provider is supported by vulnerability databases like OSV.dev for CVE scanning.
Types ¶
type Info ¶
type Info struct {
// Provider is the detected git hosting provider.
Provider Provider
// Host is the hostname (e.g., "github.com", "gitlab.internal.corp").
Host string
// Owner is the repository owner/organization (may include nested groups for GitLab).
Owner string
// Repo is the repository name.
Repo string
}
Info contains information extracted from a repository URL.
type Provider ¶
type Provider string
Provider represents a git hosting provider type.
const ( // ProviderGitHub represents GitHub (github.com and GitHub Enterprise). ProviderGitHub Provider = "github" // ProviderGitLab represents GitLab (gitlab.com and self-hosted GitLab). ProviderGitLab Provider = "gitlab" // ProviderBitbucket represents Bitbucket (bitbucket.org and Bitbucket Server). ProviderBitbucket Provider = "bitbucket" // ProviderUnknown represents an unknown or generic git hosting provider. ProviderUnknown Provider = "unknown" )
Provider constants for common git hosting services.
func DetectProvider ¶
DetectProvider determines the provider type from a hostname.
Detection strategy: 1. Exact match on well-known hosts (github.com, gitlab.com, bitbucket.org) 2. Suffix match for enterprise instances (e.g., github.enterprise.com) 3. Contains match for self-hosted instances (e.g., gitlab.internal.corp)
This allows detection of enterprise/self-hosted instances while avoiding false positives like "notgithub.com".