Add pacman (alpm) parser support (#943)

Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
Morten Linderud
2022-06-13 18:51:37 +00:00
committed by GitHub
co-authored by Christopher Phillips
parent f15d4a9984
commit e72d68b0c6
42 changed files with 2348 additions and 43 deletions
+4
View File
@@ -111,6 +111,10 @@ func parseOsRelease(contents string) (*Release, error) {
IDLike: idLike,
Version: values["VERSION"],
VersionID: values["VERSION_ID"],
VersionCodename: values["VERSION_CODENAME"],
BuildID: values["BUILD_ID"],
ImageID: values["IMAGE_ID"],
ImageVersion: values["IMAGE_VERSION"],
Variant: values["VARIANT"],
VariantID: values["VARIANT_ID"],
HomeURL: values["HOME_URL"],
+3
View File
@@ -125,6 +125,7 @@ func TestIdentifyRelease(t *testing.T) {
ID: "ubuntu",
IDLike: []string{"debian"},
Version: "20.04 LTS (Focal Fossa)",
VersionCodename: "focal",
VersionID: "20.04",
HomeURL: "https://www.ubuntu.com/",
SupportURL: "https://help.ubuntu.com/",
@@ -217,6 +218,7 @@ func TestIdentifyRelease(t *testing.T) {
Name: "Arch Linux",
ID: "arch",
IDLike: nil,
BuildID: "rolling",
HomeURL: "https://www.archlinux.org/",
SupportURL: "https://bbs.archlinux.org/",
BugReportURL: "https://bugs.archlinux.org/",
@@ -349,6 +351,7 @@ func TestParseOsRelease(t *testing.T) {
IDLike: []string{"debian"},
Version: "20.04 LTS (Focal Fossa)",
VersionID: "20.04",
VersionCodename: "focal",
HomeURL: "https://www.ubuntu.com/",
SupportURL: "https://help.ubuntu.com/",
BugReportURL: "https://bugs.launchpad.net/ubuntu/",
+8 -1
View File
@@ -8,6 +8,10 @@ type Release struct {
IDLike []string `cyclonedx:"idLike"` // list of operating system identifiers in the same syntax as the ID= setting. It should list identifiers of operating systems that are closely related to the local operating system in regards to packaging and programming interfaces.
Version string // identifies the operating system version, excluding any OS name information, possibly including a release code name, and suitable for presentation to the user.
VersionID string `cyclonedx:"versionID"` // identifies the operating system version, excluding any OS name information or release code name, and suitable for processing by scripts or usage in generated filenames.
VersionCodename string `cyclonedx:"versionCodename"`
BuildID string `cyclonedx:"buildID"` // A string uniquely identifying the system image originally used as the installation base.
ImageID string `cyclonedx:"imageID"`
ImageVersion string `cyclonedx:"imageVersion"`
Variant string `cyclonedx:"variant"` // identifies a specific variant or edition of the operating system suitable for presentation to the user.
VariantID string `cyclonedx:"variantID"` // identifies a specific variant or edition of the operating system. This may be interpreted by other packages in order to determine a divergent default configuration.
HomeURL string
@@ -30,6 +34,9 @@ func (r *Release) String() string {
if r.Version != "" {
return r.ID + " " + r.Version
}
if r.VersionID != "" {
return r.ID + " " + r.VersionID
}
return r.ID + " " + r.VersionID
return r.ID + " " + r.BuildID
}