diff --git a/providers/os/resources/os.lr b/providers/os/resources/os.lr index 3e83e912ae..fc174c1549 100644 --- a/providers/os/resources/os.lr +++ b/providers/os/resources/os.lr @@ -614,11 +614,8 @@ package @defaults("name version") { // Common Platform Enumeration (CPE) for the package cpes []core.cpe - // Package origin (optional) + // Package origin (optional) (This includes the version when present) origin() string - // Package origin version (optional) - originVersion() string - // Available version available string diff --git a/providers/os/resources/os.lr.go b/providers/os/resources/os.lr.go index dfcaa99017..4fa6a15853 100644 --- a/providers/os/resources/os.lr.go +++ b/providers/os/resources/os.lr.go @@ -1132,9 +1132,6 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "package.origin": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlPackage).GetOrigin()).ToDataRes(types.String) }, - "package.originVersion": func(r plugin.Resource) *plugin.DataRes { - return (r.(*mqlPackage).GetOriginVersion()).ToDataRes(types.String) - }, "package.available": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlPackage).GetAvailable()).ToDataRes(types.String) }, @@ -3097,10 +3094,6 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlPackage).Origin, ok = plugin.RawToTValue[string](v.Value, v.Error) return }, - "package.originVersion": func(r plugin.Resource, v *llx.RawData) (ok bool) { - r.(*mqlPackage).OriginVersion, ok = plugin.RawToTValue[string](v.Value, v.Error) - return - }, "package.available": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlPackage).Available, ok = plugin.RawToTValue[string](v.Value, v.Error) return @@ -8128,7 +8121,6 @@ type mqlPackage struct { Purl plugin.TValue[string] Cpes plugin.TValue[[]interface{}] Origin plugin.TValue[string] - OriginVersion plugin.TValue[string] Available plugin.TValue[string] Installed plugin.TValue[bool] Outdated plugin.TValue[bool] @@ -8216,12 +8208,6 @@ func (c *mqlPackage) GetOrigin() *plugin.TValue[string] { }) } -func (c *mqlPackage) GetOriginVersion() *plugin.TValue[string] { - return plugin.GetOrCompute[string](&c.OriginVersion, func() (string, error) { - return c.originVersion() - }) -} - func (c *mqlPackage) GetAvailable() *plugin.TValue[string] { return &c.Available } diff --git a/providers/os/resources/os.lr.manifest.yaml b/providers/os/resources/os.lr.manifest.yaml index be6122a145..757dd6c27e 100644 --- a/providers/os/resources/os.lr.manifest.yaml +++ b/providers/os/resources/os.lr.manifest.yaml @@ -587,8 +587,6 @@ resources: installed: {} name: {} origin: {} - originVersion: - min_mondoo_version: latest outdated: {} purl: min_mondoo_version: latest diff --git a/providers/os/resources/packages.go b/providers/os/resources/packages.go index 23c8af5ff7..22b0b86a37 100644 --- a/providers/os/resources/packages.go +++ b/providers/os/resources/packages.go @@ -75,7 +75,6 @@ func initPackage(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[str res.Arch.State = plugin.StateIsSet | plugin.StateIsNull res.Format.State = plugin.StateIsSet | plugin.StateIsNull res.Origin.State = plugin.StateIsSet | plugin.StateIsNull - res.OriginVersion.State = plugin.StateIsSet | plugin.StateIsNull res.Status.State = plugin.StateIsSet | plugin.StateIsNull res.Files.State = plugin.StateIsSet | plugin.StateIsNull return nil, res, nil @@ -96,10 +95,6 @@ func (p *mqlPackage) origin() (string, error) { return "", nil } -func (p *mqlPackage) originVersion() (string, error) { - return "", nil -} - func (p *mqlPackage) files() ([]interface{}, error) { if p.filesState == packages.PkgFilesNotAvailable { return nil, nil @@ -195,19 +190,18 @@ func (x *mqlPackages) list() ([]interface{}, error) { } pkg, err := CreateResource(x.MqlRuntime, "package", map[string]*llx.RawData{ - "name": llx.StringData(osPkg.Name), - "version": llx.StringData(osPkg.Version), - "available": llx.StringData(available), - "arch": llx.StringData(osPkg.Arch), - "status": llx.StringData(osPkg.Status), - "description": llx.StringData(osPkg.Description), - "format": llx.StringData(osPkg.Format), - "installed": llx.BoolData(true), - "origin": llx.StringData(osPkg.Origin), - "originVersion": llx.StringData(osPkg.OriginVersion), - "epoch": llx.StringData(osPkg.Epoch), - "purl": llx.StringData(osPkg.PUrl), - "cpes": llx.ArrayData(cpes, types.Resource("cpe")), + "name": llx.StringData(osPkg.Name), + "version": llx.StringData(osPkg.Version), + "available": llx.StringData(available), + "arch": llx.StringData(osPkg.Arch), + "status": llx.StringData(osPkg.Status), + "description": llx.StringData(osPkg.Description), + "format": llx.StringData(osPkg.Format), + "installed": llx.BoolData(true), + "origin": llx.StringData(osPkg.Origin), + "epoch": llx.StringData(osPkg.Epoch), + "purl": llx.StringData(osPkg.PUrl), + "cpes": llx.ArrayData(cpes, types.Resource("cpe")), }) if err != nil { return nil, err diff --git a/providers/os/resources/packages/dpkg_packages.go b/providers/os/resources/packages/dpkg_packages.go index 3b96ee306d..05a64747cb 100644 --- a/providers/os/resources/packages/dpkg_packages.go +++ b/providers/os/resources/packages/dpkg_packages.go @@ -81,16 +81,7 @@ func ParseDpkgPackages(pf *inventory.Platform, input io.Reader) ([]Package, erro case key == "Status": pkg.Status = strings.TrimSpace(m[2]) case key == "Source": - o := DPKG_ORIGIN_REGEX.FindStringSubmatch(m[2]) - if len(o) >= 1 { - pkg.Origin = strings.TrimSpace(o[1]) - } else { - log.Error().Str("origin", m[2]).Msg("cannot parse dpkg origin") - } - // Some packages also have a version as part of the Source field - if len(o) >= 2 { - pkg.OriginVersion = strings.TrimSpace(o[2]) - } + pkg.Origin = strings.TrimSpace(m[2]) // description supports multi-line statements, start desc case key == "Description": pkg.Description = strings.TrimSpace(m[2]) diff --git a/providers/os/resources/packages/dpkg_packages_test.go b/providers/os/resources/packages/dpkg_packages_test.go index 113cc9a0d7..47ab713710 100644 --- a/providers/os/resources/packages/dpkg_packages_test.go +++ b/providers/os/resources/packages/dpkg_packages_test.go @@ -57,12 +57,11 @@ The sfdisk utility is mostly for automation and scripting uses.`, assert.Equal(t, findPkg(m, p.Name), p, p.Name) p = Package{ - Name: "libaudit1", - Version: "1:2.4-1+b1", - Arch: "amd64", - Status: "install ok installed", - Origin: "audit", - OriginVersion: "1:2.4-1", + Name: "libaudit1", + Version: "1:2.4-1+b1", + Arch: "amd64", + Status: "install ok installed", + Origin: "audit (1:2.4-1)", Description: `Dynamic library for security auditing The audit-libs package contains the dynamic libraries needed for applications to use the audit framework. It is used to monitor systems for diff --git a/providers/os/resources/packages/packages.go b/providers/os/resources/packages/packages.go index de5c6add9c..4b9566d39e 100644 --- a/providers/os/resources/packages/packages.go +++ b/providers/os/resources/packages/packages.go @@ -33,9 +33,8 @@ type Package struct { // this may be the source package or an origin // e.g. on alpine it is used for parent packages // o Package Origin - https://wiki.alpinelinux.org/wiki/Apk_spec - Origin string `json:"origin"` - OriginVersion string `json:"originVersion"` - Format string `json:"format"` + Origin string `json:"origin"` + Format string `json:"format"` // Package Url follows https://github.com/package-url/purl-spec PUrl string `json:"purl,omitempty"`