mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* [wip] single sbom doc Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix more tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update cli tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove scope in import path Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * swap SPDX tag-value formatter to single sbom document Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * bust CLI cache Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update fixture to byte diff Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * byte for byte Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * bust the cache Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * who needs cache Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * add jar for testing Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * no more bit flips Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * update apk with the delta for image and directory cases Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> * restore cache workflow Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com> Co-authored-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>
36 lines
1.7 KiB
Go
36 lines
1.7 KiB
Go
package poweruser
|
|
|
|
import (
|
|
"github.com/anchore/syft/internal/formats/syftjson"
|
|
"github.com/anchore/syft/internal/formats/syftjson/model"
|
|
"github.com/anchore/syft/syft/sbom"
|
|
)
|
|
|
|
type JSONDocument struct {
|
|
// note: poweruser.JSONDocument is meant to always be a superset of packages.JSONDocument, any additional fields
|
|
// here should be optional by supplying "omitempty" on these fields hint to the jsonschema generator to not
|
|
// require these fields. As an accepted rule in this repo all collections should still be initialized in the
|
|
// context of being used in a JSON document.
|
|
FileClassifications []JSONFileClassifications `json:"fileClassifications,omitempty"` // note: must have omitempty
|
|
FileContents []JSONFileContents `json:"fileContents,omitempty"` // note: must have omitempty
|
|
FileMetadata []JSONFileMetadata `json:"fileMetadata,omitempty"` // note: must have omitempty
|
|
Secrets []JSONSecrets `json:"secrets,omitempty"` // note: must have omitempty
|
|
model.Document
|
|
}
|
|
|
|
// NewJSONDocument creates and populates a new JSON document struct from the given cataloging results.
|
|
func NewJSONDocument(s sbom.SBOM, appConfig interface{}) (JSONDocument, error) {
|
|
fileMetadata, err := NewJSONFileMetadata(s.Artifacts.FileMetadata, s.Artifacts.FileDigests)
|
|
if err != nil {
|
|
return JSONDocument{}, err
|
|
}
|
|
|
|
return JSONDocument{
|
|
FileClassifications: NewJSONFileClassifications(s.Artifacts.FileClassifications),
|
|
FileContents: NewJSONFileContents(s.Artifacts.FileContents),
|
|
FileMetadata: fileMetadata,
|
|
Secrets: NewJSONSecrets(s.Artifacts.Secrets),
|
|
Document: syftjson.ToFormatModel(s, appConfig),
|
|
}, nil
|
|
}
|