fix: packages with empty name

the problem we faced:
Some packages did not have a name.
The pkg has already the function valid, but that is not everywhere used. This commit adds the validation only for catalogers we have seen the error.

Signed-off-by: Chris Lenz <chris@freelenzer.at>
This commit is contained in:
Chris Lenz 2024-09-05 19:13:03 +02:00
parent 7c96a10cbe
commit 3337727672
4 changed files with 29 additions and 24 deletions

View file

@ -35,12 +35,14 @@ func parseLinuxKernelFile(_ context.Context, _ file.Resolver, _ *generic.Environ
return nil, nil, nil
}
return []pkg.Package{
newLinuxKernelPackage(
p := newLinuxKernelPackage(
metadata,
reader.Location,
),
}, nil, nil
)
if pkg.IsValid(&p) {
return []pkg.Package{p}, nil, nil
}
return []pkg.Package{}, nil, nil
}
func parseLinuxKernelMetadata(magicType []string) (p pkg.LinuxKernel) {

View file

@ -30,12 +30,14 @@ func parseLinuxKernelModuleFile(_ context.Context, _ file.Resolver, _ *generic.E
metadata.Path = reader.Location.RealPath
return []pkg.Package{
newLinuxKernelModulePackage(
p := newLinuxKernelModulePackage(
*metadata,
reader.Location,
),
}, nil, nil
)
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) {

View file

@ -42,13 +42,14 @@ func parseGemFileLockEntries(_ context.Context, _ file.Resolver, _ *generic.Envi
if len(candidate) != 2 {
continue
}
pkgs = append(pkgs,
newGemfileLockPackage(
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 {

View file

@ -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(
p := newGemspecPackage(
metadata,
reader.Location,
),
)
if pkg.IsValid(&p) {
pkgs = append(pkgs, p)
}
}
return pkgs, nil, nil