Skip to content

Commit d867abc

Browse files
authored
Normalize "SBOM" to "Sbom" through most of the code base (#950)
1 parent 8c746d2 commit d867abc

File tree

93 files changed

+288
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+288
-288
lines changed

docs/building-from-source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The sbom tool code is designed to be as extensible as possible. All the interfac
2020

2121
The `Microsoft.Sbom.Common` project contains the base of common code, constants, etc. that all the projects can call.
2222

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.
2424

2525
## Building on Visual Studio
2626

docs/sbom-tool-api-reference.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Add a reference to the [Microsoft.Sbom.Api](https://www.nuget.org/packages/Micro
2727

2828
## Getting started
2929

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.
3131

3232
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.
3333

@@ -56,7 +56,7 @@ class Program
5656
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.
5757
The following snippet shows how to set up the `GenerationService` class so that arguments are resolved through DI.
5858

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.
6060

6161
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.
6262

@@ -68,9 +68,9 @@ namespace SBOMApiExample
6868
{
6969
public class GenerationService: IHostedService
7070
{
71-
private readonly ISBOMGenerator generator;
71+
private readonly ISbomGenerator generator;
7272
private readonly IHostApplicationLifetime hostApplicationLifetime;
73-
public GenerationService(ISBOMGenerator generator, IHostApplicationLifetime hostApplicationLifetime)
73+
public GenerationService(ISbomGenerator generator, IHostApplicationLifetime hostApplicationLifetime)
7474
{
7575
this.generator = generator;
7676
this.hostApplicationLifetime = hostApplicationLifetime;
@@ -99,22 +99,22 @@ The generator object provides two different API implementations for creating the
9999

100100
Below are 2 additional helper methods.
101101

102-
### GetSupportedSBOMSpecifications
102+
### `GetSupportedSbomSpecifications`
103103

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:
105105

106106
```C#
107107
using Microsoft.Sbom.Contracts;
108108

109-
var spdx22Specification = new SBOMSpecification("SPDX", "2.2");
109+
var spdx22Specification = new SbomSpecification("SPDX", "2.2");
110110
```
111111

112112
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.
113113

114114
```C#
115115
using Xunit;
116116

117-
var specifications = generator.GetSupportedSBOMSpecifications();
117+
var specifications = generator.GetSupportedSbomSpecifications();
118118

119119
Assert.True(specifications.Count() == 1);
120120
Assert.Equal("SPDX", specifications.First().Name);
@@ -139,12 +139,12 @@ This API is a useful tool when utilizing the self-provided data-based API. The A
139139

140140
In order to call the API, the user must first include a minimum of one required object and one optional data object.
141141

142-
### SBOM Metadata
142+
### SbomMetadata
143143

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:
145145

146146
```C#
147-
SBOMMetadata metadata = new SBOMMetadata()
147+
SbomMetadata metadata = new SbomMetadata()
148148
{
149149
PackageName = "MyProject", //Required
150150
PackageVersion = "0.0.1", // Required
@@ -190,23 +190,23 @@ Assert.False(result.Errors.Any());
190190
* 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.
191191
* 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.
192192

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.
194194
* 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.
195195

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.
197197

198198
## Self-provided data-based SBOM generator API
199199

200200
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.
201201

202202
Users will still have to provide the metadata and runtime objects for this API.
203203

204-
### SBOMFile
204+
### SbomFile
205205

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.
207207

208208
```C#
209-
var file = new SBOMFile
209+
var file = new SbomFile
210210
{
211211
Path = "./tmp/file2.txt",
212212
Checksum = new List<Checksum>
@@ -219,12 +219,12 @@ var file = new SBOMFile
219219

220220
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.
221221

222-
### SBOMPackage
222+
### SbomPackage
223223

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.
225225

226226
```C#
227-
var package = new SBOMPackage
227+
var package = new SbomPackage
228228
{
229229
PackageName = "com.test.Foo",
230230

@@ -236,7 +236,7 @@ You can call the API as shown below:
236236
```C#
237237
using Microsoft.Sbom.Contracts.Enums;
238238

239-
var result = await generator.GenerateSBOMAsync(rootPath: scanPath,
239+
var result = await generator.GenerateSbomAsync(rootPath: scanPath,
240240
files: sbomFiles,
241241
packages: sbomPackages,
242242
metadata: metadata,
@@ -245,14 +245,14 @@ var result = await generator.GenerateSBOMAsync(rootPath: scanPath,
245245
```
246246

247247
* 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).
251251
* 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.
252252

253253
## SBOM Validation
254254

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:
256256

257257
```C#
258258
using Microsoft.Extensions.DependencyInjection;
@@ -276,7 +276,7 @@ class Program
276276
}
277277
```
278278

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:
280280
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`.
281281
All other arguments are optional.
282282

@@ -288,11 +288,11 @@ namespace SBOMApiExample
288288
{
289289
public class ValidationService : IHostedService
290290
{
291-
private readonly ISBOMValidator sbomValidator;
291+
private readonly ISbomValidator sbomValidator;
292292
private readonly IHostApplicationLifetime hostApplicationLifetime;
293293

294294
public ValidationService(
295-
ISBOMValidator sbomValidator,
295+
ISbomValidator sbomValidator,
296296
IHostApplicationLifetime hostApplicationLifetime)
297297
{
298298
this.sbomValidator = sbomValidator;

src/Microsoft.Sbom.Adapters/ComponentDetectionToSBOMPackageAdapter.cs renamed to src/Microsoft.Sbom.Adapters/ComponentDetectionToSbomPackageAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Microsoft.Sbom.Adapters;
1414

15-
public class ComponentDetectionToSBOMPackageAdapter
15+
public class ComponentDetectionToSbomPackageAdapter
1616
{
1717
/// <summary>
1818
/// Parses the output from Component Detection and converts it into a list of <see cref="SbomPackage"/> objects.

src/Microsoft.Sbom.Api/Config/ApiConfigurationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static InputConfiguration GetConfiguration(
3737
string manifestDirPath,
3838
IEnumerable<SbomFile> files,
3939
IEnumerable<SbomPackage> packages,
40-
SBOMMetadata metadata,
40+
SbomMetadata metadata,
4141
IList<SbomSpecification> specifications = null,
4242
RuntimeConfiguration runtimeConfiguration = null,
4343
string externalDocumentReferenceListFile = null,
@@ -195,7 +195,7 @@ private static ConfigurationSetting<T> GetConfigurationSetting<T>(T value)
195195
return new ConfigurationSetting<T>
196196
{
197197
Value = value,
198-
Source = SettingSource.SBOMApi
198+
Source = SettingSource.SbomApi
199199
};
200200
}
201201

src/Microsoft.Sbom.Api/Config/ConfigSanitizer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ConfigSanitizer
2727
private readonly IFileSystemUtils fileSystemUtils;
2828
private readonly IAssemblyConfig assemblyConfig;
2929

30-
internal static string SBOMToolVersion => VersionValue.Value;
30+
internal static string SbomToolVersion => VersionValue.Value;
3131

3232
private static readonly Lazy<string> VersionValue = new Lazy<string>(() => typeof(SbomToolCmdRunner).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? string.Empty);
3333

@@ -208,15 +208,15 @@ private ConfigurationSetting<AlgorithmName> GetHashAlgorithmName(IConfiguration
208208
private ConfigurationSetting<string> GetNamespaceBaseUri(IConfiguration configuration, ILogger logger)
209209
{
210210
// If assembly name is not defined but a namespace was provided, then return the current value.
211-
if (string.IsNullOrWhiteSpace(assemblyConfig.DefaultSBOMNamespaceBaseUri) && !string.IsNullOrEmpty(configuration.NamespaceUriBase?.Value))
211+
if (string.IsNullOrWhiteSpace(assemblyConfig.DefaultSbomNamespaceBaseUri) && !string.IsNullOrEmpty(configuration.NamespaceUriBase?.Value))
212212
{
213213
return configuration.NamespaceUriBase;
214214
}
215215

216216
// 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.
217-
if (string.IsNullOrWhiteSpace(assemblyConfig.DefaultSBOMNamespaceBaseUri) && string.IsNullOrEmpty(configuration.NamespaceUriBase?.Value))
217+
if (string.IsNullOrWhiteSpace(assemblyConfig.DefaultSbomNamespaceBaseUri) && string.IsNullOrEmpty(configuration.NamespaceUriBase?.Value))
218218
{
219-
var defaultNamespaceUriBase = $"https://spdx.org/spdxdocs/sbom-tool-{SBOMToolVersion}-{Guid.NewGuid()}";
219+
var defaultNamespaceUriBase = $"https://spdx.org/spdxdocs/sbom-tool-{SbomToolVersion}-{Guid.NewGuid()}";
220220

221221
logger.Information($"No namespace URI base provided, using unique generated default value {defaultNamespaceUriBase}");
222222

@@ -231,7 +231,7 @@ private ConfigurationSetting<string> GetNamespaceBaseUri(IConfiguration configur
231231
// show a warning on the console.
232232
if (!string.IsNullOrWhiteSpace(configuration.NamespaceUriBase?.Value))
233233
{
234-
if (!string.IsNullOrWhiteSpace(assemblyConfig.DefaultSBOMNamespaceBaseUri))
234+
if (!string.IsNullOrWhiteSpace(assemblyConfig.DefaultSbomNamespaceBaseUri))
235235
{
236236
logger.Information("Custom namespace URI base provided, using provided value instead of default");
237237
}
@@ -242,7 +242,7 @@ private ConfigurationSetting<string> GetNamespaceBaseUri(IConfiguration configur
242242
return new ConfigurationSetting<string>
243243
{
244244
Source = SettingSource.Default,
245-
Value = assemblyConfig.DefaultSBOMNamespaceBaseUri
245+
Value = assemblyConfig.DefaultSbomNamespaceBaseUri
246246
};
247247
}
248248

src/Microsoft.Sbom.Api/Config/SbomToolCmdRunner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.Sbom.Api.Config;
1414
[ArgProductName("sbom-tool")]
1515
public class SbomToolCmdRunner
1616
{
17-
internal static string SBOMToolVersion => VersionValue.Value;
17+
internal static string SbomToolVersion => VersionValue.Value;
1818

1919
private static readonly Lazy<string> VersionValue = new Lazy<string>(() =>
2020
{
@@ -86,9 +86,9 @@ public RedactArgs Redact(RedactArgs redactArgs)
8686
[ArgDescription("Displays the version of the tool being used. Can be used as '--version'")]
8787
public void Version()
8888
{
89-
if (!string.IsNullOrEmpty(SBOMToolVersion))
89+
if (!string.IsNullOrEmpty(SbomToolVersion))
9090
{
91-
Console.WriteLine(SBOMToolVersion);
91+
Console.WriteLine(SbomToolVersion);
9292
}
9393
else
9494
{

src/Microsoft.Sbom.Api/Config/Validators/ConfigValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void Validate(string propertyName, object propertyValue, AttributeCollect
9898

9999
private bool NamespaceUriBaseIsNullOrHasDefaultValue(object propertyValue)
100100
{
101-
var defaultProperty = assemblyConfig.DefaultSBOMNamespaceBaseUri;
101+
var defaultProperty = assemblyConfig.DefaultSbomNamespaceBaseUri;
102102

103103
if (propertyValue == null || !string.IsNullOrEmpty(defaultProperty))
104104
{

src/Microsoft.Sbom.Api/Executors/ConcurrentSha256HashValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private async Task Validate(InternalSbomFileInfo internalFileInfo, Channel<FileV
7979
// If we have the files from both locations present in the hash, validate if the hashes match.
8080
if (newValue?.FileLocation == Sbom.Entities.FileLocation.All)
8181
{
82-
if (string.Equals(newValue.OnDiskHash?.ChecksumValue, newValue.SBOMFileHash?.ChecksumValue, StringComparison.InvariantCultureIgnoreCase))
82+
if (string.Equals(newValue.OnDiskHash?.ChecksumValue, newValue.SbomFileHash?.ChecksumValue, StringComparison.InvariantCultureIgnoreCase))
8383
{
8484
await output.Writer.WriteAsync(new FileValidationResult { Path = internalFileInfo.Path });
8585
}

0 commit comments

Comments
 (0)