Skip to content

Commit 346f5b3

Browse files
authored
fix(debian): don't include empty licenses for dpkgs (#8623)
1 parent ad58cf4 commit 346f5b3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/fanal/analyzer/pkg/dpkg/copyright.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func (a *dpkgLicenseAnalyzer) parseCopyright(r xio.ReadSeekerAt) ([]types.Licens
9090
l = normalizeLicense(l)
9191
if l != "" {
9292
for _, lic := range licensing.SplitLicenses(l) {
93+
if lic == "" {
94+
continue
95+
}
96+
9397
lic = licensing.Normalize(lic)
9498
if !slices.Contains(licenses, lic) {
9599
licenses = append(licenses, lic)
@@ -101,7 +105,7 @@ func (a *dpkgLicenseAnalyzer) parseCopyright(r xio.ReadSeekerAt) ([]types.Licens
101105
license := commonLicenseReferenceRegexp.FindStringSubmatch(line)
102106
if len(license) == 2 {
103107
l := licensing.Normalize(license[1])
104-
if !slices.Contains(licenses, l) {
108+
if l != "" && !slices.Contains(licenses, l) {
105109
licenses = append(licenses, l)
106110
}
107111
}

pkg/fanal/analyzer/pkg/dpkg/testdata/license-pattern-and-classifier-copyright

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Files: contrib/minizip/*
4747
Copyright: 1998-2010 Gilles Vollant
4848
2007-2008 Even Rouault
4949
2009-2010 Mathias Svensson
50-
License: Zlib
50+
License: Zlib,
5151

5252
Files: debian/*
5353
Copyright: 2000-2017 Mark Brown

0 commit comments

Comments
 (0)