@@ -2,6 +2,8 @@ package com.codacy.plugins.api.results
2
2
3
3
import com .codacy .plugins .api .{ErrorMessage , Source }
4
4
5
+ import java .time .Instant
6
+
5
7
sealed trait Result
6
8
7
9
object Result {
@@ -31,6 +33,107 @@ object Result {
31
33
32
34
case class FileError (filename : Source .File , message : Option [ErrorMessage ]) extends Result
33
35
36
+ /** SBOM - Software Bill of Materials
37
+ *
38
+ * A SBOM declares the inventory of components used to build a software artifact, including any open source and
39
+ * proprietary software components.
40
+ *
41
+ * This class models CycloneDX 1.6 BOM format.
42
+ *
43
+ * @param bomFormat The format of the SBOM.
44
+ * @param specVersion The version of the SBOM format used to build this SBOM.
45
+ * @param metadata SBOM metadata.
46
+ * @param components A list of software components.
47
+ * @param dependencies Document dependency relationships between components.
48
+ * @see https://github.com/CycloneDX/cyclonedx-core-java/blob/master/src/main/resources/bom-1.6.schema.json
49
+ */
50
+ case class SBOM (bomFormat : SBOM .BOMFormat .Value ,
51
+ specVersion : String ,
52
+ metadata : SBOM .Metadata ,
53
+ components : List [SBOM .Component ],
54
+ dependencies : List [SBOM .Dependency ])
55
+ extends Result
56
+
57
+ object SBOM {
58
+ type BOMFormat = BOMFormat .Value
59
+ object BOMFormat extends Enumeration {
60
+ val CycloneDX : Value = Value (" CycloneDX" )
61
+ }
62
+
63
+ /** SBOM metadata.
64
+ *
65
+ * @param timestamp When the SBOM file was generated.
66
+ * @param tools The tools used in the SBOM creation.
67
+ * @param component The artifact that the SBOM describes.
68
+ */
69
+ case class Metadata (timestamp : Instant , tools : Tools , component : Component )
70
+
71
+ case class Tools (components : List [Tool ])
72
+
73
+ /** A tool used in SBOM generation. E.g. Trivy.
74
+ *
75
+ * @param `type` The tool type.
76
+ * @param name The tool name.
77
+ * @param group The tool group. E.g. com.codacy.
78
+ * @param version The tool version.
79
+ */
80
+ case class Tool (`type` : Component .Type , name : String , group : String , version : String )
81
+
82
+ /** A software or hardware component used to build a software artifact.
83
+ *
84
+ * @param `bom-ref` An identifier used to reference the component elsewhere in the SBOM. Unique within the SBOM.
85
+ * @param `type` The type of component.
86
+ * @param name The component name.
87
+ * @param group The component group.
88
+ * @param version The component version.
89
+ * @param purl The package URL. See https://github.com/package-url/purl-spec
90
+ * @param properties A list of component properties as name-value pairs.
91
+ * @param licenses Component licenses.
92
+ */
93
+ case class Component (`bom-ref` : String ,
94
+ `type` : Component .Type ,
95
+ name : String ,
96
+ group : Option [String ],
97
+ version : Option [String ],
98
+ purl : Option [String ],
99
+ properties : List [Property ],
100
+ licenses : List [LicenseWrapper ])
101
+
102
+ object Component {
103
+ type Type = Type .Value
104
+ object Type extends Enumeration {
105
+ val Application : Value = Value (" application" )
106
+ val Framework : Value = Value (" framework" )
107
+ val Library : Value = Value (" library" )
108
+ val Container : Value = Value (" container" )
109
+ val Platform : Value = Value (" platform" )
110
+ val OperatingSystem : Value = Value (" operating-system" )
111
+ val Device : Value = Value (" device" )
112
+ val DeviceDrive : Value = Value (" device-driver" )
113
+ val Firmware : Value = Value (" firmware" )
114
+ val File : Value = Value (" file" )
115
+ val MachineLearningModel : Value = Value (" machine-learning-model" )
116
+ val Data : Value = Value (" data" )
117
+ val CryptographicAsset : Value = Value (" cryptographic-asset" )
118
+ }
119
+ }
120
+
121
+ /** A name-value pair representing a piece of information not officially supported by the SBOM schema. */
122
+ case class Property (name : String , value : String )
123
+
124
+ case class LicenseWrapper (license : License )
125
+
126
+ /** A software license. */
127
+ case class License (name : String )
128
+
129
+ /** Documents a dependency relationship between components.
130
+ *
131
+ * @param ref The reference to a component. Same as [[Component.`bom-ref` ]].
132
+ * @param dependsOn References to other components this component depends on.
133
+ */
134
+ case class Dependency (ref : String , dependsOn : List [String ])
135
+ }
136
+
34
137
type Level = Level .Value
35
138
36
139
object Level extends Enumeration {
0 commit comments