Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make targets package a dev dependency and fix package supplier trimming #725

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions src/Microsoft.Sbom.Targets/Microsoft.Sbom.Targets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Description>Tasks and targets for running the SBOM tool.</Description>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<SbomCLIToolTargetFramework>net8.0</SbomCLIToolTargetFramework>
<DevelopmentDependency>true</DevelopmentDependency>

<!-- This target will run when MSBuild is collecting the files to be packaged, and we'll implement it below. This property controls the dependency list for this packaging process, so by adding our custom property we hook ourselves into the process in a supported way. -->
<TargetsForTfmSpecificBuildOutput>
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.Sbom.Targets/SbomInputValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ public bool ValidateAndSanitizeRequiredParams()
}
}

this.PackageSupplier = Remove_Spaces_Tabs_Newlines(this.PackageSupplier);
this.PackageName = Remove_Spaces_Tabs_Newlines(this.PackageName);
this.PackageVersion = Remove_Spaces_Tabs_Newlines(this.PackageVersion);
this.PackageSupplier = Remove_Tabs_Newlines(this.PackageSupplier);
this.PackageName = Remove_Tabs_Newlines(this.PackageName);
this.PackageVersion = Remove_Tabs_Newlines(this.PackageVersion);
this.NamespaceBaseUri = this.NamespaceBaseUri.Trim();
this.BuildDropPath = this.BuildDropPath.Trim();

return true;
}

public string Remove_Spaces_Tabs_Newlines(string value)
public string Remove_Tabs_Newlines(string value)
{
return value.Replace("\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty);
return value.Replace("\n", string.Empty).Replace("\t", string.Empty).Trim();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,21 @@ private static IEnumerable<object[]> GetPackageSupplierCases()
{
yield return new object[] { "Test-\nMicrosoft", PackageName, PackageVersion };
yield return new object[] { "Test\t-Microsoft", PackageName, PackageVersion };
yield return new object[] { "Test - Microsoft ", PackageName, PackageVersion };
yield return new object[] { "Test - Mic\tro\nsoft", PackageName, PackageVersion };
yield return new object[] { "Test-Mic\tro\nsoft", PackageName, PackageVersion };
}

private static IEnumerable<object[]> GetPackageNameCases()
{
yield return new object[] { PackageSupplier, "CoseSign\nTool", PackageVersion };
yield return new object[] { PackageSupplier, "Cose\tSign\tTool", PackageVersion };
yield return new object[] { PackageSupplier, "Cose Sign Tool ", PackageVersion };
yield return new object[] { PackageSupplier, "Cose S\ti\ngn \n Too\tl", PackageVersion };
yield return new object[] { PackageSupplier, "CoseS\ti\ngn\nToo\tl", PackageVersion };
}

private static IEnumerable<object[]> GetPackageVersionCases()
{
yield return new object[] { PackageSupplier, PackageName, "0.0\n.1" };
yield return new object[] { PackageSupplier, PackageName, "0.0\t.1" };
yield return new object[] { PackageSupplier, PackageName, "0. 0. 1" };
yield return new object[] { PackageSupplier, PackageName, "0 . \t 0 \n .1" };
yield return new object[] { PackageSupplier, PackageName, "0.\t0\n.1" };
}

[TestMethod]
Expand Down