-
Notifications
You must be signed in to change notification settings - Fork 734
Closed
Labels
bugSomething isn't workingSomething isn't workingchangelog-ignoreDon't include this issue in the release changelogDon't include this issue in the release changelog
Description
What happened:
Some of the components I get on a system have an empty name like:
{
"bom-ref": "5c2ce977a3f2f724",
"type": "library",
"name": "",
"version": "1.8",
"licenses": [
{
"license": {
"name": "GPL"
}
}
],
"purl": "pkg:generic/@1.8",
"properties": [
{
"name": "syft:package:foundBy",
"value": "linux-kernel-cataloger"
},
I looked into the code and saw that there is a IsValid function for packages (
Lines 83 to 85 in 1aaa644
| func IsValid(p *Package) bool { | |
| return p != nil && p.Name != "" | |
| } |
but not all of the cataloger do respect that.
What you expected to happen:
I would expect that components (packages) that are not valid would not get exported.
Steps to reproduce the issue:
I ran that on a local filesystem.
Anything else we need to know?:
NO
Environment:
-
Output of
syft version:
latest master, because I also tested with the source and own compilation.
but also 1.11.1 -
OS (e.g:
cat /etc/os-releaseor similar):
in my case the following patch helped:
Index: syft/pkg/cataloger/ruby/parse_gemspec.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/syft/pkg/cataloger/ruby/parse_gemspec.go b/syft/pkg/cataloger/ruby/parse_gemspec.go
--- a/syft/pkg/cataloger/ruby/parse_gemspec.go (revision 7c96a10cbea82e94c843112c8394abac7672b0dc)
+++ b/syft/pkg/cataloger/ruby/parse_gemspec.go (date 1725491039246)
@@ -102,13 +102,13 @@
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
Index: syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go b/syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go
--- a/syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go (revision 7c96a10cbea82e94c843112c8394abac7672b0dc)
+++ b/syft/pkg/cataloger/kernel/parse_linux_kernel_module_file.go (date 1725490779123)
@@ -30,12 +30,14 @@
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) {
Index: syft/pkg/cataloger/kernel/parse_linux_kernel_file.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/syft/pkg/cataloger/kernel/parse_linux_kernel_file.go b/syft/pkg/cataloger/kernel/parse_linux_kernel_file.go
--- a/syft/pkg/cataloger/kernel/parse_linux_kernel_file.go (revision 7c96a10cbea82e94c843112c8394abac7672b0dc)
+++ b/syft/pkg/cataloger/kernel/parse_linux_kernel_file.go (date 1725490728661)
@@ -35,12 +35,14 @@
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) {
Index: syft/pkg/cataloger/ruby/parse_gemfile_lock.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/syft/pkg/cataloger/ruby/parse_gemfile_lock.go b/syft/pkg/cataloger/ruby/parse_gemfile_lock.go
--- a/syft/pkg/cataloger/ruby/parse_gemfile_lock.go (revision 7c96a10cbea82e94c843112c8394abac7672b0dc)
+++ b/syft/pkg/cataloger/ruby/parse_gemfile_lock.go (date 1725490344297)
@@ -42,13 +42,14 @@
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 {
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingchangelog-ignoreDon't include this issue in the release changelogDon't include this issue in the release changelog
Type
Projects
Status
Done