Skip to content

Commit

Permalink
Make targets package a dev dependency and fix package supplier trimmi…
Browse files Browse the repository at this point in the history
…ng (#726)

* Make targets package a dev dependency and fix package supplier trimming

* Fix whitespace

* Disallow new lines and tabs but not spaces

* retrigger CI

* PR feedback
  • Loading branch information
sfoslund authored Sep 26, 2024
1 parent 7b69133 commit 59a68d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
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).Replace(" ", string.Empty);
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,16 +171,14 @@ 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()
Expand Down

0 comments on commit 59a68d1

Please sign in to comment.