-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logic for parsing javascript and ruby package vendor candidates from url and author fields and stop generating wildcard vendor candidates Signed-off-by: Weston Steimel <[email protected]>
- Loading branch information
1 parent
47b5bb9
commit 52cebc2
Showing
3 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cpe | ||
|
||
import "github.com/anchore/syft/syft/pkg" | ||
|
||
func candidateVendorsForJavascript(p pkg.Package) fieldCandidateSet { | ||
if p.MetadataType != pkg.NpmPackageJSONMetadataType { | ||
return nil | ||
} | ||
|
||
vendors := newFieldCandidateSet() | ||
metadata, ok := p.Metadata.(pkg.NpmPackageJSONMetadata) | ||
if !ok { | ||
return nil | ||
} | ||
|
||
if metadata.Author != "" { | ||
vendors.add(fieldCandidate{ | ||
value: normalizePersonName(stripEmailSuffix(metadata.Author)), | ||
disallowSubSelections: true, | ||
}) | ||
} | ||
|
||
if metadata.URL != "" { | ||
vendors.union(candidateVendorsFromURL(metadata.URL)) | ||
} | ||
|
||
if metadata.Homepage != "" { | ||
vendors.union(candidateVendorsFromURL(metadata.Homepage)) | ||
} | ||
|
||
return vendors | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters