diff --git a/pkg/helper/helper.go b/pkg/helper/helper.go index 2c16de1..6a96cc2 100644 --- a/pkg/helper/helper.go +++ b/pkg/helper/helper.go @@ -155,7 +155,9 @@ func GetCopyright(content string) string { if strings.EqualFold(copyrightLookup, tokens[0]) { cr[matchLevel2] = line - if re.MatchString(tokens[1]) { + has_multiple_tokens := len(tokens) > 1 + + if has_multiple_tokens && re.MatchString(tokens[1]) { cr[matchLevel1] = line } } diff --git a/pkg/modules/gem/helper.go b/pkg/modules/gem/helper.go index 0e47eb9..5a72877 100644 --- a/pkg/modules/gem/helper.go +++ b/pkg/modules/gem/helper.go @@ -564,7 +564,7 @@ func isDuplicate(value string, spec Spec) bool { return skip } -// Builds Dependency Tree from Gemfile.lock +// Builds Dependency Tree from Gemfile.lock func BuildLockDependencyTree(rows []string) { var startIndex, specPosition int diff --git a/pkg/modules/yarn/handler.go b/pkg/modules/yarn/handler.go index 2799959..c2fd6a8 100644 --- a/pkg/modules/yarn/handler.go +++ b/pkg/modules/yarn/handler.go @@ -94,7 +94,7 @@ func (m *yarn) SetRootModule(path string) error { } // GetRootModule return -//root package information ex. Name, Version +// root package information ex. Name, Version func (m *yarn) GetRootModule(path string) (*models.Module, error) { r := reader.New(filepath.Join(path, m.metadata.Manifest[0])) pkResult, err := r.ReadJson() @@ -207,15 +207,16 @@ func (m *yarn) buildDependencies(path string, deps []dependency) ([]models.Modul if name == "optionalDependencies:" { continue } - - version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"") - if extractVersion(version) == "*" { - continue - } - mod.Modules[name] = &models.Module{ - Name: name, - Version: extractVersion(version), - CheckSum: &models.CheckSum{Content: []byte(fmt.Sprintf("%s-%s", name, version))}, + if len(ar) > 1 { + version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"") + if extractVersion(version) == "*" { + continue + } + mod.Modules[name] = &models.Module{ + Name: name, + Version: extractVersion(version), + CheckSum: &models.CheckSum{Content: []byte(fmt.Sprintf("%s-%s", name, version))}, + } } } } @@ -390,12 +391,13 @@ func appendNestedDependencies(deps []dependency) []dependency { if name == "optionalDependencies:" { continue } - - version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"") - if extractVersion(version) == "*" { - continue + if len(ar) > 1 { + version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"") + if extractVersion(version) == "*" { + continue + } + allDeps = append(allDeps, dependency{Name: name, Version: extractVersion(version)}) } - allDeps = append(allDeps, dependency{Name: name, Version: extractVersion(version)}) } } }