Skip to content
Open
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
3 changes: 3 additions & 0 deletions pkg/fanal/types/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ type Package struct {

// Files installed by the package
InstalledFiles []string `json:",omitempty"`

// Additional information about the component
Properties map[string]string `json:",omitempty"`
}

func (pkg *Package) Empty() bool {
Expand Down
5 changes: 5 additions & 0 deletions pkg/sbom/io/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ func fillPkgFieldsFromComponentProps(props []core.Property, pkg *ftypes.Package)
buildInfo.Nvr = prop.Value
case core.PropertyArch:
buildInfo.Arch = prop.Value
default:
if pkg.Properties == nil {
pkg.Properties = make(map[string]string)
}
pkg.Properties[prop.Name] = prop.Value
}
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/sbom/io/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ var (
Name: core.PropertySrcVersion,
Value: "2.0.0",
},
{
Name: "custom_property",
Value: "property value",
},
},
Licenses: []string{"GPL-2.0"},
}
Expand Down Expand Up @@ -286,6 +290,9 @@ func TestDecoder_Decode_OSPackages(t *testing.T) {
"rhel-9-for-aarch64-appstream-source-rpms",
},
},
Properties: map[string]string{
"custom_property": "property value",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions pkg/sbom/io/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ func (*Encoder) component(result types.Result, pkg ftypes.Package) *core.Compone
}
}

for name, value := range pkg.Properties {
properties = append(properties, core.Property{
Name: name,
Value: value,
External: true,
})
}

var files []core.File
if pkg.FilePath != "" || pkg.Digest != "" {
files = append(files, core.File{
Expand Down
7 changes: 7 additions & 0 deletions pkg/sbom/io/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func TestEncoder_Encode(t *testing.T) {
Version: "2.13.4",
},
},
Properties: map[string]string{
"custom_property": "property value",
},
},
{
ID: "com.fasterxml.jackson.core:jackson-databind:2.13.4",
Expand Down Expand Up @@ -358,6 +361,10 @@ func TestEncoder_Encode(t *testing.T) {
Name: core.PropertyPkgType,
Value: "jar",
},
{
Name: "custom_property",
Value: "property value",
},
},
PkgIdentifier: ftypes.PkgIdentifier{
UID: "A6BD5A2FE5C00E10",
Expand Down