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

Switch to use ScanCommand Component Detection API #471

Merged
merged 1 commit into from
Jan 5, 2024
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PackageVersion>
</ItemDefinitionGroup>
<PropertyGroup>
<ComponentDetectionPackageVersion>4.0.8</ComponentDetectionPackageVersion>
<ComponentDetectionPackageVersion>4.0.11</ComponentDetectionPackageVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AutoMapper" Version="10.1.1" />
Expand Down
19 changes: 13 additions & 6 deletions src/Microsoft.Sbom.Api/Utils/ComponentDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Common;
using Microsoft.ComponentDetection.Contracts.BcdeModels;
using Microsoft.ComponentDetection.Orchestrator.Commands;
using Microsoft.ComponentDetection.Orchestrator.Services;
Expand All @@ -20,20 +21,26 @@ public class ComponentDetector : IComponentDetector
private readonly IDetectorProcessingService detectorProcessingService;
private readonly IDetectorRestrictionService detectorRestrictionService;
private readonly IGraphTranslationService graphTranslationService;
private readonly ILogger<ScanExecutionService> logger;
private readonly IFileWritingService fileWritingService;
private readonly ILogger<ScanExecutionService> scanExecutionLogger;
private readonly ILogger<ScanCommand> scanCommandLogger;

public ComponentDetector(
IEnumerable<ComponentDetection.Contracts.IComponentDetector> detectors,
IDetectorProcessingService detectorProcessingService,
IDetectorRestrictionService detectorRestrictionService,
IGraphTranslationService graphTranslationService,
ILogger<ScanExecutionService> logger)
IFileWritingService fileWritingService,
ILogger<ScanExecutionService> scanExecutionLogger,
ILogger<ScanCommand> scanCommandLogger)
{
this.detectors = detectors;
this.detectorProcessingService = detectorProcessingService;
this.detectorRestrictionService = detectorRestrictionService;
this.graphTranslationService = graphTranslationService;
this.logger = logger;
this.fileWritingService = fileWritingService;
this.scanExecutionLogger = scanExecutionLogger;
this.scanCommandLogger = scanCommandLogger;
}

public virtual async Task<ScanResult> ScanAsync(ScanSettings args)
Expand All @@ -43,8 +50,8 @@ public virtual async Task<ScanResult> ScanAsync(ScanSettings args)
detectorProcessingService,
detectorRestrictionService,
graphTranslationService,
logger);

return await executionService.ExecuteScanAsync(args);
scanExecutionLogger);
var scanCommand = new ScanCommand(fileWritingService, executionService, scanCommandLogger);
return await scanCommand.ExecuteScanCommandAsync(args);
}
}