You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-from-source.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The sbom tool code is designed to be as extensible as possible. All the interfac
20
20
21
21
The `Microsoft.Sbom.Common` project contains the base of common code, constants, etc. that all the projects can call.
22
22
23
-
The `Microsoft.Sbom.Contracts` project defines the interfaces that the tool uses to call the SBOM tool using a C# API. The `ISBOMGenerator` class defines two methods that the tool uses to directly call the SBOM tool from C# code. The `Microsoft.Sbom.Tool` project defines a command line interface (CLI) interface to talk to the SBOM tool.
23
+
The `Microsoft.Sbom.Contracts` project defines the interfaces that the tool uses to call the SBOM tool using a C# API. The `ISbomGenerator` class defines two methods that the tool uses to directly call the SBOM tool from C# code. The `Microsoft.Sbom.Tool` project defines a command line interface (CLI) interface to talk to the SBOM tool.
Copy file name to clipboardExpand all lines: docs/sbom-tool-api-reference.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Add a reference to the [Microsoft.Sbom.Api](https://www.nuget.org/packages/Micro
27
27
28
28
## Getting started
29
29
30
-
The main entry point for the SBOM generator is in the `SBOMGenerator` class. In order to create an instance of the SBOMGenerator class there are a few arguments that need to be provided. These arguments can be resolved through the dependency injection framework. The following code snippet shows one way to create an instance of the SBOMGenerator class using the dependency injection framework in a pattern that is common when using this approach. Note that this approach is not the only one which will work. For example, if you'd like to avoid implementing the `IHostedService` interface, it should be possible to create a ServiceCollection without using ASP.NET as well.
30
+
The main entry point for the SBOM generator is in the `SbomGenerator` class. In order to create an instance of the SbomGenerator class there are a few arguments that need to be provided. These arguments can be resolved through the dependency injection framework. The following code snippet shows one way to create an instance of the SbomGenerator class using the dependency injection framework in a pattern that is common when using this approach. Note that this approach is not the only one which will work. For example, if you'd like to avoid implementing the `IHostedService` interface, it should be possible to create a ServiceCollection without using ASP.NET as well.
31
31
32
32
Following our suggested approach, you can create a Host and add a hosted service that will call the SBOM API along with its dependencies. By calling `.AddSbomTool()` on the service collection, the SBOM API will be added to the dependency injection framework and can be resolved by the hosted service. The hosted service can then be started by calling `RunConsoleAsync` on the host.
33
33
@@ -56,7 +56,7 @@ class Program
56
56
Now that the entry point is set up, we can define the hosted service. In this example, we will use the `GenerationService` class (This class is user defined) as the hosted service. The `GenerationService` class will be responsible for calling the SBOM API and generating the SBOM.
57
57
The following snippet shows how to set up the `GenerationService` class so that arguments are resolved through DI.
58
58
59
-
In this approach, your class must implement the `IHostedService` interface and provide an implementation for the `StartAsync` and `StopAsync` methods. Now you can pass an instance of the `ISBOMGenerator` interface to the constructor of your class. This interface is provided by the SBOM API and can be resolved by the DI framework. The `ISBOMGenerator` interface provides the methods to generate the SBOM.
59
+
In this approach, your class must implement the `IHostedService` interface and provide an implementation for the `StartAsync` and `StopAsync` methods. Now you can pass an instance of the `ISbomGenerator` interface to the constructor of your class. This interface is provided by the SBOM API and can be resolved by the DI framework. The `ISbomGenerator` interface provides the methods to generate the SBOM.
60
60
61
61
Descriptions of the arguments to the `GenerateSbomAsync` method can be found [here](#scan-based-sbom-generator-api) and [here](#self-provided-data-based-sbom-generator-api) and can be defined anywhere necessary as long as they are passed to the `GenerateSbomAsync` method.
@@ -99,22 +99,22 @@ The generator object provides two different API implementations for creating the
99
99
100
100
Below are 2 additional helper methods.
101
101
102
-
### GetSupportedSBOMSpecifications
102
+
### `GetSupportedSbomSpecifications`
103
103
104
-
The `SBOMSpecification` object represents a SBOM format. Each `SBOMSpecification` contains a `name` and a `version`. This structure defines a single format of SBOM. Sample SPDX version 2.2 format representations include:
104
+
The `SbomSpecification` object represents a SBOM format. Each `SbomSpecification` contains a `name` and a `version`. This structure defines a single format of SBOM. Sample SPDX version 2.2 format representations include:
While this API supports the creation of a SBOM output file in multiple formats, it currently only supports the SPDX version 2.2 architecture. Users looking to implement other SBOM architectures can use this API call, which provides the full list of all supported formats.
@@ -139,12 +139,12 @@ This API is a useful tool when utilizing the self-provided data-based API. The A
139
139
140
140
In order to call the API, the user must first include a minimum of one required object and one optional data object.
141
141
142
-
### SBOM Metadata
142
+
### SbomMetadata
143
143
144
-
The `SBOMMetadata` object provides the API with additional metadata for use in configuring output metadata values in the SBOM file, e.g., product name or version:
144
+
The `SbomMetadata` object provides the API with additional metadata for use in configuring output metadata values in the SBOM file, e.g., product name or version:
* The `rootPath` dictates the destination path for publishing the build artifacts. The API will scan all files in 'rootPath' and will subsequently add them to the 'files' section in the SBOM output file. If the command does not include the `manifestDirPath` parameter, the tool will generate the SBOM inside the default `_manifest` folder.
191
191
* The `componentPath` parameter normally contains the source folder, which the API will search for dependency components. The 'packages' section in the SBOM file will list the discovered components.
192
192
193
-
* The `metadata` and `configuration` parameters accept the [`SBOMMetadata`](#sbommetadata) and [`RuntimeConfiguration`](#runtimeconfiguration) objects respectively.
193
+
* The `metadata` and `configuration` parameters accept the [`SbomMetadata`](#sbommetadata) and [`RuntimeConfiguration`](#runtimeconfiguration) objects respectively.
194
194
* As desired, the `manifestDirPath` parameter allows users to specify a full folder path if they want the API to save the SBOM to a directory other than the default `_manifest` location. The API will store the SBOM file in the `_manifest` subfolder under the user-specified path.
195
195
196
-
The API asynchronously returns a `SBOMGenerationResult` object. A successful SBOM file generation will set the `IsSuccessful` flag value to `true`. A failed generation run will add the errors to the `Errors` list.
196
+
The API asynchronously returns a `SbomGenerationResult` object. A successful SBOM file generation will set the `IsSuccessful` flag value to `true`. A failed generation run will add the errors to the `Errors` list.
197
197
198
198
## Self-provided data-based SBOM generator API
199
199
200
200
There might be occasions where users do not want the API to scan for the target components. The self-provided data-based API is an ideal choice for those scenarios where users have the list of files and packages for inclusion in the SBOM file. The self-provided data-based SBOM generator API gives users the ability to serialize the data in the desired format.
201
201
202
202
Users will still have to provide the metadata and runtime objects for this API.
203
203
204
-
### SBOMFile
204
+
### SbomFile
205
205
206
-
`Path` and `Checksum` are the only required properties for use in the `SBOMFile` object in order to represent a file inside the SBOM. The API will serialize any additional values unchanged "as-is" in the output SBOM file.
206
+
`Path` and `Checksum` are the only required properties for use in the `SbomFile` object in order to represent a file inside the SBOM. The API will serialize any additional values unchanged "as-is" in the output SBOM file.
207
207
208
208
```C#
209
-
varfile=newSBOMFile
209
+
varfile=newSbomFile
210
210
{
211
211
Path="./tmp/file2.txt",
212
212
Checksum=newList<Checksum>
@@ -219,12 +219,12 @@ var file = new SBOMFile
219
219
220
220
The API looks for a relative path starting with a period `.`. All path separators should include forward slashes `/` in compliance with the SPDX version 2.2 specification.
221
221
222
-
### SBOMPackage
222
+
### SbomPackage
223
223
224
-
'SBOMPackage' represents a dependency component for the product. The `PackageName` is the only required property. The API will serialize all other properties unchanged "as-is" in the final output SBOM file.
224
+
'SbomPackage' represents a dependency component for the product. The `PackageName` is the only required property. The API will serialize all other properties unchanged "as-is" in the final output SBOM file.
225
225
226
226
```C#
227
-
varpackage=newSBOMPackage
227
+
varpackage=newSbomPackage
228
228
{
229
229
PackageName="com.test.Foo",
230
230
@@ -236,7 +236,7 @@ You can call the API as shown below:
@@ -245,14 +245,14 @@ var result = await generator.GenerateSBOMAsync(rootPath: scanPath,
245
245
```
246
246
247
247
* The `rootPath` specifies the path for placing the output SBOM file. User specifying the destination path with the `manifestDirPath` parameter can utilize the `null` value for `rootPath`.
248
-
* The `files` parameter contains a list of `SBOMFile` objects.
249
-
* The `packages` parameter contains a list of `SBOMPackage` objects.
250
-
* The `metadata` and `runtimeConfiguration` parameters accept the [`SBOMMetadata`](#sbommetadata) and [`RuntimeConfiguration`](#runtimeconfiguration) objects (respectively).
248
+
* The `files` parameter contains a list of `SbomFile` objects.
249
+
* The `packages` parameter contains a list of `SbomPackage` objects.
250
+
* The `metadata` and `runtimeConfiguration` parameters accept the [`SbomMetadata`](#sbommetadata) and [`RuntimeConfiguration`](#runtimeconfiguration) objects (respectively).
251
251
* If users want the API to generate the output SBOM in a different folder other the default location, they need to provide the path in the `manifestDirPath` parameter. Users will find the SBOM file under the `_manifest` directory at the user-specified path.
252
252
253
253
## SBOM Validation
254
254
255
-
Now that you have generated the SBOM file, you can validate it using the `SBOMValidator` class. Setup for this will be very similar to the `SBOMGenerator` class. Here is an example:
255
+
Now that you have generated the SBOM file, you can validate it using the `SbomValidator` class. Setup for this will be very similar to the `SbomGenerator` class. Here is an example:
256
256
257
257
```C#
258
258
usingMicrosoft.Extensions.DependencyInjection;
@@ -276,7 +276,7 @@ class Program
276
276
}
277
277
```
278
278
279
-
After the Host is set up, you can inject the `ISBOMValidator` interface into your service and use it to validate the SBOM file. Here is an example:
279
+
After the Host is set up, you can inject the `ISbomValidator` interface into your service and use it to validate the SBOM file. Here is an example:
280
280
Note that the only arguments required are the `buildDropPath`, the `outputPath`, and the `SbomSpecification`. The `buildDropPath` is the path to the directory containing the _manifest directory. The `outPath` is the path to the file where the validation output will be written. The only `SbomSpecification` currently supported is `SPDX 2.2`.
// If assembly name is not defined and namespace was not provided then return the default namespace as per spdx spec https://spdx.github.io/spdx-spec/v2.2.2/document-creation-information/#653-examples.
0 commit comments