Skip to content

Commit 15b8b79

Browse files
[8.15](backport #5215) refactor: update go-rpm library (#5257)
* refactor: update go-rpm library (#5215) Bump go-rpm to new version and update path go-rpm library was moved to github.com/cavaliergopher/rpm. The checksum assertion has been removed as the method doesn't actually return the checksum but it's hardcoded to return the string sha256. (cherry picked from commit 8e6af84) # Conflicts: # NOTICE.txt # go.sum * fix: regenerate notice and run go mod tidy --------- Co-authored-by: kruskall <99559985+kruskall@users.noreply.github.com>
1 parent 607051e commit 15b8b79

File tree

4 files changed

+10
-52
lines changed

4 files changed

+10
-52
lines changed

NOTICE.txt

+3-31
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,12 @@ THE SOFTWARE.
355355

356356

357357
--------------------------------------------------------------------------------
358-
Dependency : github.com/cavaliercoder/go-rpm
359-
Version: v0.0.0-20190131055624-7a9c54e3d83e
358+
Dependency : github.com/cavaliergopher/rpm
359+
Version: v1.2.0
360360
Licence type (autodetected): BSD-3-Clause
361361
--------------------------------------------------------------------------------
362362

363-
Contents of probable licence file $GOMODCACHE/github.com/cavaliercoder/go-rpm@v0.0.0-20190131055624-7a9c54e3d83e/LICENSE:
363+
Contents of probable licence file $GOMODCACHE/github.com/cavaliergopher/rpm@v1.2.0/LICENSE:
364364

365365
Copyright (c) 2017 Ryan Armstrong. All rights reserved.
366366

@@ -20240,34 +20240,6 @@ SOFTWARE.
2024020240

2024120241

2024220242

20243-
--------------------------------------------------------------------------------
20244-
Dependency : github.com/cavaliercoder/badio
20245-
Version: v0.0.0-20160213150051-ce5280129e9e
20246-
Licence type (autodetected): MIT
20247-
--------------------------------------------------------------------------------
20248-
20249-
Contents of probable licence file $GOMODCACHE/github.com/cavaliercoder/badio@v0.0.0-20160213150051-ce5280129e9e/LICENSE:
20250-
20251-
Copyright (c) 2015 Ryan Armstrong
20252-
20253-
Permission is hereby granted, free of charge, to any person obtaining a copy of
20254-
this software and associated documentation files (the "Software"), to deal in
20255-
the Software without restriction, including without limitation the rights to
20256-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
20257-
the Software, and to permit persons to whom the Software is furnished to do so,
20258-
subject to the following conditions:
20259-
20260-
The above copyright notice and this permission notice shall be included in all
20261-
copies or substantial portions of the Software.
20262-
20263-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20264-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20265-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20266-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20267-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20268-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20269-
20270-
2027120243
--------------------------------------------------------------------------------
2027220244
Dependency : github.com/cespare/xxhash/v2
2027320245
Version: v2.3.0

dev-tools/packaging/package_test.go

+4-15
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"testing"
3131

3232
"github.com/blakesmith/ar"
33-
"github.com/cavaliercoder/go-rpm"
33+
"github.com/cavaliergopher/rpm"
3434
"github.com/stretchr/testify/assert"
3535
"github.com/stretchr/testify/require"
3636
"gopkg.in/yaml.v3"
@@ -112,7 +112,7 @@ func TestDocker(t *testing.T) {
112112
// Sub-tests
113113

114114
func checkRPM(t *testing.T, file string) {
115-
p, rpmPkg, err := readRPM(file)
115+
p, _, err := readRPM(file)
116116
if err != nil {
117117
t.Error(err)
118118
return
@@ -130,7 +130,6 @@ func checkRPM(t *testing.T, file string) {
130130
checkLicensesPresent(t, "/usr/share", p)
131131
checkSystemdUnitPermissions(t, p)
132132
ensureNoBuildIDLinks(t, p)
133-
checkRPMDigestTypeSHA256(t, rpmPkg)
134133
}
135134

136135
func checkDeb(t *testing.T, file string, buf *bytes.Buffer) {
@@ -580,16 +579,6 @@ func ensureNoBuildIDLinks(t *testing.T, p *packageFile) {
580579
})
581580
}
582581

583-
// checkRPMDigestTypeSHA256 verifies that the RPM contains sha256 digests.
584-
// https://github.com/elastic/beats/issues/23670
585-
func checkRPMDigestTypeSHA256(t *testing.T, rpmPkg *rpm.PackageFile) {
586-
t.Run("rpm_digest_type_is_sha256", func(t *testing.T) {
587-
if rpmPkg.ChecksumType() != "sha256" {
588-
t.Errorf("expected SHA256 digest type but got %v", rpmPkg.ChecksumType())
589-
}
590-
})
591-
}
592-
593582
// Helpers
594583

595584
type packageFile struct {
@@ -619,8 +608,8 @@ func getFiles(t *testing.T, pattern *regexp.Regexp) []string {
619608
return files
620609
}
621610

622-
func readRPM(rpmFile string) (*packageFile, *rpm.PackageFile, error) {
623-
p, err := rpm.OpenPackageFile(rpmFile)
611+
func readRPM(rpmFile string) (*packageFile, *rpm.Package, error) {
612+
p, err := rpm.Open(rpmFile)
624613
if err != nil {
625614
return nil, nil, err
626615
}

go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/antlr4-go/antlr/v4 v4.13.0
1010
github.com/billgraziano/dpapi v0.4.0
1111
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2
12-
github.com/cavaliercoder/go-rpm v0.0.0-20190131055624-7a9c54e3d83e
12+
github.com/cavaliergopher/rpm v1.2.0
1313
github.com/cenkalti/backoff/v4 v4.3.0
1414
github.com/docker/go-units v0.5.0
1515
github.com/dolmen-go/contextio v0.0.0-20200217195037-68fc5150bcd5
@@ -91,7 +91,6 @@ require (
9191
)
9292

9393
require (
94-
github.com/cavaliercoder/badio v0.0.0-20160213150051-ce5280129e9e // indirect
9594
github.com/distribution/reference v0.6.0 // indirect
9695
github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.106.1
9796
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.106.1

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2 h1:oMCHnXa6CCCafdPDb
134134
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
135135
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
136136
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
137-
github.com/cavaliercoder/badio v0.0.0-20160213150051-ce5280129e9e h1:YYUjy5BRwO5zPtfk+aa2gw255FIIoi93zMmuy19o0bc=
138-
github.com/cavaliercoder/badio v0.0.0-20160213150051-ce5280129e9e/go.mod h1:V284PjgVwSk4ETmz84rpu9ehpGg7swlIH8npP9k2bGw=
139-
github.com/cavaliercoder/go-rpm v0.0.0-20190131055624-7a9c54e3d83e h1:Gbx+iVCXG/1m5WSnidDGuHgN+vbIwl+6fR092ANU+Y8=
140-
github.com/cavaliercoder/go-rpm v0.0.0-20190131055624-7a9c54e3d83e/go.mod h1:AZIh1CCnMrcVm6afFf96PBvE2MRpWFco91z8ObJtgDY=
137+
github.com/cavaliergopher/rpm v1.2.0 h1:s0h+QeVK252QFTolkhGiMeQ1f+tMeIMhGl8B1HUmGUc=
138+
github.com/cavaliergopher/rpm v1.2.0/go.mod h1:R0q3vTqa7RUvPofAZYrnjJ63hh2vngjFfphuXiExVos=
141139
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
142140
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
143141
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

0 commit comments

Comments
 (0)