Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/codacy/codacy-engine-golang-seed/v6
go 1.23

require (
github.com/CycloneDX/cyclonedx-go v0.10.0
github.com/samber/lo v1.52.0
github.com/sirupsen/logrus v1.9.4
github.com/stretchr/testify v1.11.1
Expand Down
12 changes: 0 additions & 12 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 22 additions & 3 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"encoding/json"

"github.com/CycloneDX/cyclonedx-go"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -46,9 +45,29 @@
return i.File
}

// SBOM represents a Software Bill of Materials in the CycloneDX format.
// An "enum" representing the supported BOM formats.

Check notice on line 48 in result.go

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

result.go#L48

comment on exported type BomFormat should be of the form "BomFormat ..." (with optional leading article)
type BomFormat string

const (
// [CycloneDX] specification in JSON format.

Check notice on line 52 in result.go

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

result.go#L52

comment on exported const CycloneDXJSON should be of the form "CycloneDXJSON ..."
//
// [CycloneDX]: https://cyclonedx.org/
CycloneDXJSON = BomFormat("CycloneDXJSON")
)

// SBOM - Software Bill of Materials
//
// A SBOM declares the inventory of components used to build a software artifact, including any open source and
// proprietary software components.
type SBOM struct {
cyclonedx.BOM
// The format of the SBOM. Currently only [CycloneDX] specification in JSON format is supported.
//
// [CycloneDX]: https://cyclonedx.org/
BomFormat BomFormat `json:"bomFormat"`
// The version of the SBOM format used to build this SBOM.
SpecVersion string `json:"specVersion"`
// The actual SBOM content. To be parsed by downstream consumers according to `bomFormat` and `specVersion`.
Sbom string `json:"sbom"`
}

func (s SBOM) ToJSON() ([]byte, error) {
Expand Down
8 changes: 6 additions & 2 deletions result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ func TestResultsToJSON(t *testing.T) {
File: "file-error",
Message: "file-error",
}
sbom := SBOM{}
sbom := SBOM{
BomFormat: CycloneDXJSON,
SpecVersion: "1.6",
Sbom: `{"bomFormat":"CycloneDX","specVersion":"1.6","metadata"...}`,
}
badResult := BadResult{}

expectedJSONResults := []string{
`{"filename":"file","line":5,"message":"message","patternId":"pattern ID", "sourceId":"CVE-2025-11111"}`,
`{"filename":"file-error","message":"file-error"}`,
`{"bomFormat":"","specVersion":"SpecVersion(0)","version":0}`,
`{"bomFormat":"CycloneDXJSON","specVersion":"1.6","sbom":"{\"bomFormat\":\"CycloneDX\",\"specVersion\":\"1.6\",\"metadata\"...}"}`,
}

// Act
Expand Down