Skip to content

Commit

Permalink
Check for GenerateSBOM setting
Browse files Browse the repository at this point in the history
  • Loading branch information
credfeto committed Dec 17, 2024
1 parent e2d3daa commit f8e4b73
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
## [Unreleased]
### Added
- Check for projects having the Microsoft SBOM tool
- Check for GenerateSBOM setting on packable projects
### Fixed
### Changed
- Dependencies - Updated ThisAssembly.AssemblyInfo to 1.5.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Xml;
using FunFair.BuildCheck.ProjectChecks.Helpers;
using Microsoft.Extensions.Logging;

namespace FunFair.BuildCheck.ProjectChecks.Settings;

public sealed class GenerateSbomPolicy : SimplePropertyProjectCheckBase
{
public GenerateSbomPolicy(ILogger<GenerateSbomPolicy> logger)
: base(propertyName: "GenerateSBOM", requiredValue: "true", logger: logger)
{
}

protected override bool CanCheck(string projectName, string projectFolder, XmlDocument project)
{
return project.IsPackable();
}
}
3 changes: 2 additions & 1 deletion src/FunFair.BuildCheck.Runner/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ private static IServiceCollection GeneralProjectSettings(this IServiceCollection
.AddProjectCheck<TieredCompilationPolicy>()
.AddProjectCheck<EnableMicrosoftExtensionsConfigurationBinderSourceGeneratorPolicy>()
.AddProjectCheck<JsonSerializerIsReflectionEnabledByDefaultPolicy>()
.AddProjectCheck<OptimizationPreferencePolicy>();
.AddProjectCheck<OptimizationPreferencePolicy>()
.AddProjectCheck<GenerateSbomPolicy>();
}

private static IServiceCollection PublishingSettings(this IServiceCollection services)
Expand Down

0 comments on commit f8e4b73

Please sign in to comment.