-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,679 additions
and
297 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
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
2 changes: 1 addition & 1 deletion
2
.../formats/spdx22json/model/external_ref.go → ...ormats/common/spdxhelpers/external_ref.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package model | ||
package spdxhelpers | ||
|
||
type ReferenceCategory string | ||
|
||
|
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 |
---|---|---|
@@ -1,51 +1,26 @@ | ||
package spdxhelpers | ||
|
||
import ( | ||
"github.com/anchore/syft/internal/formats/spdx22json/model" | ||
"github.com/anchore/syft/internal/log" | ||
"github.com/anchore/syft/syft/pkg" | ||
) | ||
|
||
func ExternalRefs(p pkg.Package) (externalRefs []model.ExternalRef) { | ||
externalRefs = make([]model.ExternalRef, 0) | ||
func ExternalRefs(p pkg.Package) (externalRefs []ExternalRef) { | ||
externalRefs = make([]ExternalRef, 0) | ||
|
||
for _, c := range p.CPEs { | ||
externalRefs = append(externalRefs, model.ExternalRef{ | ||
ReferenceCategory: model.SecurityReferenceCategory, | ||
externalRefs = append(externalRefs, ExternalRef{ | ||
ReferenceCategory: SecurityReferenceCategory, | ||
ReferenceLocator: pkg.CPEString(c), | ||
ReferenceType: model.Cpe23ExternalRefType, | ||
ReferenceType: Cpe23ExternalRefType, | ||
}) | ||
} | ||
|
||
if p.PURL != "" { | ||
externalRefs = append(externalRefs, model.ExternalRef{ | ||
ReferenceCategory: model.PackageManagerReferenceCategory, | ||
externalRefs = append(externalRefs, ExternalRef{ | ||
ReferenceCategory: PackageManagerReferenceCategory, | ||
ReferenceLocator: p.PURL, | ||
ReferenceType: model.PurlExternalRefType, | ||
ReferenceType: PurlExternalRefType, | ||
}) | ||
} | ||
return externalRefs | ||
} | ||
|
||
func ExtractPURL(refs []model.ExternalRef) string { | ||
for _, r := range refs { | ||
if r.ReferenceType == model.PurlExternalRefType { | ||
return r.ReferenceLocator | ||
} | ||
} | ||
return "" | ||
} | ||
|
||
func ExtractCPEs(refs []model.ExternalRef) (cpes []pkg.CPE) { | ||
for _, r := range refs { | ||
if r.ReferenceType == model.Cpe23ExternalRefType { | ||
cpe, err := pkg.NewCPE(r.ReferenceLocator) | ||
if err != nil { | ||
log.Warnf("unable to extract SPDX CPE=%q: %+v", r.ReferenceLocator, err) | ||
continue | ||
} | ||
cpes = append(cpes, cpe) | ||
} | ||
} | ||
return cpes | ||
} |
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,17 @@ | ||
package spdxhelpers | ||
|
||
type FileType string | ||
|
||
const ( | ||
DocumentationFileType FileType = "DOCUMENTATION" // if the file serves as documentation | ||
ImageFileType FileType = "IMAGE" // if the file is associated with a picture image file (MIME type of image/*, e.g., .jpg, .gif) | ||
VideoFileType FileType = "VIDEO" // if the file is associated with a video file type (MIME type of video/*) | ||
ArchiveFileType FileType = "ARCHIVE" // if the file represents an archive (.tar, .jar, etc.) | ||
SpdxFileType FileType = "SPDX" // if the file is an SPDX document | ||
ApplicationFileType FileType = "APPLICATION" // if the file is associated with a specific application type (MIME type of application/*) | ||
SourceFileType FileType = "SOURCE" // if the file is human readable source code (.c, .html, etc.) | ||
BinaryFileType FileType = "BINARY" // if the file is a compiled object, target image or binary executable (.o, .a, etc.) | ||
TextFileType FileType = "TEXT" // if the file is human readable text file (MIME type of text/*) | ||
AudioFileType FileType = "AUDIO" // if the file is associated with an audio file (MIME type of audio/* , e.g. .mp3) | ||
OtherFileType FileType = "OTHER" // if the file doesn't fit into the above categories (generated artifacts, data files, etc.) | ||
) |
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
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
Oops, something went wrong.