Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: packages with empty name #3199

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 8 additions & 6 deletions syft/pkg/cataloger/kernel/parse_linux_kernel_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ func parseLinuxKernelFile(_ context.Context, _ file.Resolver, _ *generic.Environ
return nil, nil, nil
}

return []pkg.Package{
newLinuxKernelPackage(
metadata,
reader.Location,
),
}, nil, nil
p := newLinuxKernelPackage(
metadata,
reader.Location,
)
if pkg.IsValid(&p) {
return []pkg.Package{p}, nil, nil
}
return []pkg.Package{}, nil, nil
}

func parseLinuxKernelMetadata(magicType []string) (p pkg.LinuxKernel) {
Expand Down
14 changes: 8 additions & 6 deletions syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ func parseLinuxKernelModuleFile(_ context.Context, _ file.Resolver, _ *generic.E

metadata.Path = reader.Location.RealPath

return []pkg.Package{
newLinuxKernelModulePackage(
*metadata,
reader.Location,
),
}, nil, nil
p := newLinuxKernelModulePackage(
*metadata,
reader.Location,
)
if pkg.IsValid(&p) {
return []pkg.Package{p}, nil, nil
}
return []pkg.Package{}, nil, nil
}

func parseLinuxKernelModuleMetadata(r unionreader.UnionReader) (p *pkg.LinuxKernelModule, err error) {
Expand Down
13 changes: 7 additions & 6 deletions syft/pkg/cataloger/ruby/parse_gemfile_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ func parseGemFileLockEntries(_ context.Context, _ file.Resolver, _ *generic.Envi
if len(candidate) != 2 {
continue
}
pkgs = append(pkgs,
newGemfileLockPackage(
candidate[0],
strings.Trim(candidate[1], "()"),
reader.Location.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation),
),
p := newGemfileLockPackage(
candidate[0],
strings.Trim(candidate[1], "()"),
reader.Location.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation),
)
if pkg.IsValid(&p) {
pkgs = append(pkgs, p)
}
}
}
if err := scanner.Err(); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions syft/pkg/cataloger/ruby/parse_gemspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ func parseGemSpecEntries(_ context.Context, _ file.Resolver, _ *generic.Environm
return nil, nil, fmt.Errorf("unable to decode gem metadata: %w", err)
}

pkgs = append(
pkgs,
newGemspecPackage(
metadata,
reader.Location,
),
p := newGemspecPackage(
metadata,
reader.Location,
)
if pkg.IsValid(&p) {
pkgs = append(pkgs, p)
}
}

return pkgs, nil, nil
Expand Down
Loading