Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/checks/so_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ func (o *SoNameOptions) checkSonamesMatch(ctx context.Context, existingPackages
log.Infof("checking soname file %s", soname)
sonameParts := strings.Split(soname, ".so")

// DT_SONAME is arbitrary metadata and isn't required to contain ".so",
// in which case there's no version to compare against.
if len(sonameParts) < 2 {
log.Infof("no version found in soname %s, skipping", soname)
continue
}

// Find the version and optional qualifier
matches := r.FindStringSubmatch(sonameParts[1])
if len(matches) > 0 {
Expand All @@ -203,6 +210,11 @@ func (o *SoNameOptions) checkSonamesMatch(ctx context.Context, existingPackages
// now iterate over new soname files and compare with existing files
for _, soname := range newSonameFiles {
sonameParts := strings.Split(soname, ".so")
if len(sonameParts) < 2 {
log.Infof("no version found in soname %s, skipping", soname)
continue
}

name := sonameParts[0]
versionStr := strings.TrimPrefix(sonameParts[1], ".")
existingVersionStr := existingSonameMap[name]
Expand Down
8 changes: 8 additions & 0 deletions pkg/checks/so_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ func TestSoNameOptions_checkSonamesMatch(t *testing.T) {
name: "ignore_non_standard_version_suffix", existingSonameFiles: []string{"libgs.so.10.02.debug"}, newSonameFiles: []string{"libgs.so.10.02.debug"},
wantErr: assert.NoError,
},
{
name: "existing_dt_soname_without_so", existingSonameFiles: []string{"libevil"}, newSonameFiles: []string{"foo.so.1"},
wantErr: assert.NoError,
},
{
name: "new_dt_soname_without_so", existingSonameFiles: []string{"foo.so.1"}, newSonameFiles: []string{"badsoname"},
wantErr: assert.NoError,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down