Skip to content

Commit

Permalink
Merge pull request kubernetes#2213 from hectorj2f/fix_panic_license
Browse files Browse the repository at this point in the history
bom: fix panic when LICENSE file is not found
  • Loading branch information
k8s-ci-robot committed Aug 19, 2021
2 parents eeb22d2 + 5eda9dc commit 2f3587e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/spdx/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ func (di *spdxDefaultImplementation) GetDirectoryLicense(
if err != nil {
return nil, errors.Wrap(err, "getting directory license")
}
if licenseResult == nil {
logrus.Warnf("License classifier could not find a license for directory: %v", err)
return nil, nil
}
return licenseResult.License, nil
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/spdx/spdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ func (spdx *SPDX) PackageFromDirectory(dirPath string) (pkg *Package, err error)
if err != nil {
return nil, errors.Wrap(err, "scanning directory for licenses")
}
if lic == nil {
logrus.Warnf("License classifier could not find a license for directory: %v", err)
} else {
if lic != nil {
licenseTag = lic.LicenseID
}

Expand Down

0 comments on commit 2f3587e

Please sign in to comment.