Skip to content

Commit

Permalink
utilized HasExtractedLicensingInfos
Browse files Browse the repository at this point in the history
  • Loading branch information
dira271641 authored and dira271641 committed Apr 4, 2023
1 parent 23c74e4 commit ff35e55
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ test: build
./bin/${BINARY_NAME} -h
copy: test
cp bin/${BINARY_NAME} /sw/bin/
cp bin/${BINARY_NAME}-windows-amd64.exe /mnt/c/bugtracker/sq.exe

help: ## Show this help
@${HELP_CMD}
40 changes: 36 additions & 4 deletions model/spdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,38 @@ func (s *SPDX) Printpkgs(np int) {

}

const noassert = "NOASSERTION"

func (s *SPDX) ExtractLicnese(license_text string) string {

if license_text == noassert || license_text == "" {
return noassert
}
if !strings.Contains(license_text, "LicenseRef-") {
return license_text
}
if strings.Contains(license_text, "LicenseRef-") {
license_infos := s.HasExtractedLicensingInfos
if len(license_infos) > 0 {
for _, lic_info := range license_infos {
if license_text == lic_info.LicenseID {
if lic_info.Name == "" {
if lic_info.ExtractedText != "" {
return lic_info.ExtractedText
} else {
return noassert
}
} else {
return lic_info.Name

}
}
}
}
}
return noassert
}

func (s *SPDX) PrintpkgsIP(np int) {

table := simpletable.New()
Expand Down Expand Up @@ -602,8 +634,8 @@ func (s *SPDX) PrintpkgsIP(np int) {
{Text: pkg.Name},
{Text: pkg.VersionInfo},
// {Text: pkg.Homepage},
{Text: pkg.LicenseDeclared},
{Text: pkg.LicenseConcluded},
{Text: s.ExtractLicnese(pkg.LicenseDeclared)},
{Text: s.ExtractLicnese(pkg.LicenseConcluded)},
{Text: fmt.Sprintf("%v", pkg.FilesAnalyzed)},
// {Text: pkg.DownloadLocation},
{Text: pkg.CopyrightText},
Expand Down Expand Up @@ -665,8 +697,8 @@ func (s *SPDX) PrintpkgsExt(np int) {
{Text: pkg.Name},
{Text: pkg.VersionInfo},
{Text: pkg.Homepage},
{Text: pkg.LicenseDeclared},
{Text: pkg.LicenseConcluded},
{Text: s.ExtractLicnese(pkg.LicenseDeclared)},
{Text: s.ExtractLicnese(pkg.LicenseConcluded)},
{Text: fmt.Sprintf("%v", pkg.FilesAnalyzed)},
{Text: pkg.DownloadLocation},
{Text: pkg.CopyrightText},
Expand Down

0 comments on commit ff35e55

Please sign in to comment.