Skip to content

Commit

Permalink
feat(sbom): add custom marshaler to prevent b64 encoding
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Goller <[email protected]>
  • Loading branch information
goller committed Sep 23, 2023
1 parent f0c7008 commit b6687bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/sbom/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ type SBOM struct {
Image *ImageSBOM `json:"image"`
}

// This is a custom marshaler to prevent conversion of JSON statement into base64.
func (s *SBOM) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Statement json.RawMessage `json:"statement"`
Platform string `json:"platform"`
Image *ImageSBOM `json:"image,omitempty"`
}{
Statement: json.RawMessage(s.Statement),
Platform: s.Platform,
Image: s.Image,
})
}

// ImageSBOM describes an image that is described by an SBOM.
type ImageSBOM struct {
// Name is the image name and tag.
Expand Down

0 comments on commit b6687bc

Please sign in to comment.