github.com/anchore/syft@v1.38.2/syft/format/syftjson/model/linux_release.go (about)

     1  package model
     2  
     3  import (
     4  	"encoding/json"
     5  )
     6  
     7  // IDLikes represents a list of distribution IDs that this Linux distribution is similar to or derived from, as defined in os-release ID_LIKE field.
     8  type IDLikes []string
     9  
    10  // LinuxRelease contains Linux distribution identification and version information extracted from /etc/os-release or similar system files.
    11  type LinuxRelease struct {
    12  	// PrettyName is a human-readable operating system name with version.
    13  	PrettyName string `json:"prettyName,omitempty"`
    14  
    15  	// Name is the operating system name without version information.
    16  	Name string `json:"name,omitempty"`
    17  
    18  	// ID is the lower-case operating system identifier (e.g., "ubuntu", "rhel").
    19  	ID string `json:"id,omitempty"`
    20  
    21  	// IDLike is a list of operating system IDs this distribution is similar to or derived from.
    22  	IDLike IDLikes `json:"idLike,omitempty"`
    23  
    24  	// Version is the operating system version including codename if available.
    25  	Version string `json:"version,omitempty"`
    26  
    27  	// VersionID is the operating system version number or identifier.
    28  	VersionID string `json:"versionID,omitempty"`
    29  
    30  	// VersionCodename is the operating system release codename (e.g., "jammy", "bullseye").
    31  	VersionCodename string `json:"versionCodename,omitempty"`
    32  
    33  	// BuildID is a build identifier for the operating system.
    34  	BuildID string `json:"buildID,omitempty"`
    35  
    36  	// ImageID is an identifier for container or cloud images.
    37  	ImageID string `json:"imageID,omitempty"`
    38  
    39  	// ImageVersion is the version for container or cloud images.
    40  	ImageVersion string `json:"imageVersion,omitempty"`
    41  
    42  	// Variant is the operating system variant name (e.g., "Server", "Workstation").
    43  	Variant string `json:"variant,omitempty"`
    44  
    45  	// VariantID is the lower-case operating system variant identifier.
    46  	VariantID string `json:"variantID,omitempty"`
    47  
    48  	// HomeURL is the homepage URL for the operating system.
    49  	HomeURL string `json:"homeURL,omitempty"`
    50  
    51  	// SupportURL is the support or help URL for the operating system.
    52  	SupportURL string `json:"supportURL,omitempty"`
    53  
    54  	// BugReportURL is the bug reporting URL for the operating system.
    55  	BugReportURL string `json:"bugReportURL,omitempty"`
    56  
    57  	// PrivacyPolicyURL is the privacy policy URL for the operating system.
    58  	PrivacyPolicyURL string `json:"privacyPolicyURL,omitempty"`
    59  
    60  	// CPEName is the Common Platform Enumeration name for the operating system.
    61  	CPEName string `json:"cpeName,omitempty"`
    62  
    63  	// SupportEnd is the end of support date or version identifier.
    64  	SupportEnd string `json:"supportEnd,omitempty"`
    65  
    66  	// ExtendedSupport indicates whether extended security or support is available.
    67  	ExtendedSupport bool `json:"extendedSupport,omitempty"`
    68  }
    69  
    70  func (s *IDLikes) UnmarshalJSON(data []byte) error {
    71  	var str string
    72  	var strSlice []string
    73  
    74  	// we support unmarshalling from a single value to support syft json schema v2
    75  	if err := json.Unmarshal(data, &str); err == nil {
    76  		*s = []string{str}
    77  	} else if err := json.Unmarshal(data, &strSlice); err == nil {
    78  		*s = strSlice
    79  	} else {
    80  		return err
    81  	}
    82  	return nil
    83  }