Skip to content

Commit

Permalink
Users/ksigmund/random fixes (#17)
Browse files Browse the repository at this point in the history
Random fixes

Co-authored-by: Kevin Sigmund <ksigmund@microsoft.com>
  • Loading branch information
ksigmund and Kevin Sigmund authored Jun 23, 2022
1 parent 83cf940 commit 32625ea
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Microsoft.Sbom.Api
/// Creates the Ninject bindings for the whole project.
/// </summary>
/// <remarks>
/// Microsoft.ManifestTool.Api.dll is the assembly name of the SBOM API project.
/// Microsoft.Sbom.Api.dll is the assembly name of the SBOM API project.
/// Using pattern matching until all bindings are in the same assembly.
/// </remarks>
public class Bindings : NinjectModule
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Config/Args/GenerationArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GenerationArgs : CommonArgs
public string BuildListFile { get; set; }

/// <summary>
/// Gets or sets the root folder where the generated manifest (and other files like bsi.json) files will be placed.
/// Gets or sets the root folder where the generated manifest files as well as other files will be placed.
/// By default we will generate this folder in the same level as the build drop with the name '_manifest'.
/// </summary>
[ArgShortcut("m")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Collections.Generic;
using System.Linq;

namespace DropValidator.Api.Config.Extensions
namespace Microsoft.Sbom.Api.Config.Extensions
{
/// <summary>
/// Provides extension methods for an instance of <see cref="IConfiguration"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ namespace Microsoft.Sbom.Api.Config
[ArgDescription("The manifest tool validates or generates a manifest for a build artifact.")]
[ArgExceptionBehavior(ArgExceptionPolicy.StandardExceptionHandling)]
[ArgProductName("ManifestTool.exe")]
public class ManifestToolCmdRunner
public class SbomToolCmdRunner
{
private readonly StandardKernel kernel;

public ManifestToolCmdRunner()
public SbomToolCmdRunner()
{
IsFailed = false;
kernel = new StandardKernel(new Bindings());
}

public ManifestToolCmdRunner(StandardKernel kernel)
public SbomToolCmdRunner(StandardKernel kernel)
{
IsFailed = false;
this.kernel = kernel ?? throw new ArgumentNullException(nameof(kernel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Castle.Core.Internal;
using DropValidator.Api.Config.Extensions;
using Microsoft.Sbom.Api.Config.Extensions;
using Microsoft.Sbom.Extensions;
using Microsoft.ComponentDetection.Common;
using Microsoft.ComponentDetection.Contracts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Microsoft.Sbom.Extensions.Entities;

namespace DropValidator.Api.Output.Telemetry.Entities
namespace Microsoft.Sbom.Api.Output.Telemetry.Entities
{
/// <summary>
/// Represents a SBOM file object and contains additional properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using DropValidator.Api.Output.Telemetry.Entities;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Api.Entities.Output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Api.Entities.Output;
using Microsoft.Sbom.Api.Output.Telemetry.Entities;
using DropValidator.Api.Output.Telemetry.Entities;
using PowerArgs;
using System.IO;
using Microsoft.Sbom.Common;
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Sbom.Api/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public static class Constants

public static AlgorithmName DefaultHashAlgorithmName = AlgorithmName.SHA256;

public const string ManifestBsiFileName = "bsi.json";

public const string SPDXFileExtension = ".spdx.json";
public const string DocumentNamespaceString = "documentNamespace";
public const string NameString = "name";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ namespace Microsoft.SPDX22SBOMParser.Entities.Enums
public enum ExternalRepositoryType
{
#region Security
Cpe22,
Cpe23,
cpe22,
cpe23,

#endregion

#region Persistent-Id

Swh,
swh,

#endregion

#region Package-Manager

Maven_central,
Npm,
Nuget,
Bower,
Purl,
maven_central,
npm,
nuget,
bower,
purl,

#endregion

#region Other

Idstring
idstring

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void AddPackageUrls(this SPDXPackage spdxPackage, SBOMPackage pack
var extRef = new ExternalReference
{
ReferenceCategory = ReferenceCategory.PACKAGE_MANAGER,
Type = ExternalRepositoryType.Purl,
Type = ExternalRepositoryType.purl,
Locator = FormatPackageUrl(packageInfo.PackageUrl)
};

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class Program

public static async Task<int> Main(string[] args)
{
var result = await Args.InvokeActionAsync<ManifestToolCmdRunner>(args);
var result = await Args.InvokeActionAsync<SbomToolCmdRunner>(args);
Log.CloseAndFlush();
if (result.Cancelled || result.HandledException != null || result.Args.IsFailed)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using DropValidator.Api.Config.Extensions;
using Microsoft.Sbom.Api.Config.Extensions;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Api.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task ManifestToolCmdRunner_Generate_BuildPathNoWritePermissions_Acc
{
var bindings = new Bindings();

var runner = new ManifestToolCmdRunner(new StandardKernel(bindings));
var runner = new SbomToolCmdRunner(new StandardKernel(bindings));

var fileSystemUtilsMock = new Mock<IFileSystemUtils>();
fileSystemUtilsMock.Setup(f => f.DirectoryExists(It.IsAny<string>())).Returns(true).Verifiable();
Expand All @@ -44,7 +44,7 @@ public async Task ManifestToolCmdRunner_Generate_Success()
{
var bindings = new Bindings();

var runner = new ManifestToolCmdRunner(new StandardKernel(bindings));
var runner = new SbomToolCmdRunner(new StandardKernel(bindings));

var fileSystemUtilsMock = new Mock<IFileSystemUtils>();
fileSystemUtilsMock.Setup(f => f.DirectoryExists(It.IsAny<string>())).Returns(true).Verifiable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace DropValidator.Api.Utils.Tests
namespace Microsoft.Sbom.Api.Utils.Tests
{
[TestClass]
public class IdentifierUtilsTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ await externalDocumentReferenceChannel.Writer.WriteAsync(new ExternalDocumentRef

var outputs = resultJson["Outputs"];
JArray sortedOutputs = new JArray(outputs.OrderBy(obj => (string)obj["Source"]));
var expectedJson = JObject.Parse(GoodJson);
JArray expectedSortedOutputs = new JArray(outputs.OrderBy(obj => (string)obj["Source"]));

var packages = resultJson["Packages"];
Expand Down Expand Up @@ -433,21 +432,5 @@ public async Task ManifestGenerationWorkflowTests_SBOMDir_NotDefault_NotDeleted(
fileSystemMock.Verify(f => f.DeleteDir(It.IsAny<string>(), true), Times.Never);
Assert.IsFalse(result);
}

private const string GoodJson = "{\"Outputs\":[{\"Source\":\"/child1/file2\",\"AzureArtifactsHash\":" +
"\"/root/child1/file2hash\",\"Sha256Hash\":\"/root/child1/file2hash\"},{\"Source\":\"/child1/file1\"," +
"\"AzureArtifactsHash\":\"/root/child1/file1hash\",\"Sha256Hash\":\"/root/child1/file1hash\"},{\"Source\":" +
"\"/child2/file3\",\"AzureArtifactsHash\":\"/root/child2/file3hash\",\"Sha256Hash\":\"/root/child2/file3hash\"}" +
",{\"Source\":\"/child2/file4\",\"AzureArtifactsHash\":\"/root/child2/file4hash\",\"Sha256Hash\":\"/root/child2" +
"/file4hash\"},{\"Source\":\"/child2/grandchild1/file6\",\"AzureArtifactsHash\":\"/root/child2/grandchild1/" +
"file6hash\",\"Sha256Hash\":\"/root/child2/grandchild1/file6hash\"},{\"Source\":\"/child2/grandchild1/file10" +
"\",\"AzureArtifactsHash\":\"/root/child2/grandchild1/file10hash\",\"Sha256Hash\":\"/root/child2/grandchild1" +
"/file10hash\"},{\"Source\":\"/child2/grandchild1/file9\",\"AzureArtifactsHash\":\"/root/child2/grandchild1" +
"/file9hash\",\"Sha256Hash\":\"/root/child2/grandchild1/file9hash\"},{\"Source\":\"/child3/file11\",\"Azure" +
"ArtifactsHash\":\"/root/child3/file11hash\",\"Sha256Hash\":\"/root/child3/file11hash\"},{\"Source\":\"/chi" +
"ld2/file5\",\"AzureArtifactsHash\":\"/root/child2/file5hash\",\"Sha256Hash\":\"/root/child2/file5hash\"},{" +
"\"Source\":\"/child2/grandchild1/file7\",\"AzureArtifactsHash\":\"/root/child2/grandchild1/file7hash\",\"S" +
"ha256Hash\":\"/root/child2/grandchild1/file7hash\"},{\"Source\":\"/child3/file12\",\"AzureArtifactsHash\":" +
"\"/root/child3/file12hash\",\"Sha256Hash\":\"/root/child3/file12hash\"}]}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void AddPackageUrlsTest_Success()
spdxPackage.AddPackageUrls(packageInfo);
var externalRef = spdxPackage.ExternalReferences.First();
Assert.AreEqual(ReferenceCategory.PACKAGE_MANAGER, externalRef.ReferenceCategory);
Assert.AreEqual(ExternalRepositoryType.Purl, externalRef.Type);
Assert.AreEqual(ExternalRepositoryType.purl, externalRef.Type);
Assert.AreEqual(PackageUrl, externalRef.Locator);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public void AddPackageUrlsTest_WithEncoding_Success(string inputUrl, string expe
var externalRef = spdxPackage.ExternalReferences.First();

Assert.AreEqual(ReferenceCategory.PACKAGE_MANAGER, externalRef.ReferenceCategory);
Assert.AreEqual(ExternalRepositoryType.Purl, externalRef.Type);
Assert.AreEqual(ExternalRepositoryType.purl, externalRef.Type);
Assert.AreEqual(expectedUrl, externalRef.Locator);
}

Expand Down

0 comments on commit 32625ea

Please sign in to comment.