From 9a3de2d16d8710ad13378d086126126988c9afda Mon Sep 17 00:00:00 2001 From: Sarah Oslund Date: Thu, 4 Jan 2024 08:55:53 -0800 Subject: [PATCH] Switch to use ScanCommand CD API --- Directory.Packages.props | 2 +- .../Utils/ComponentDetector.cs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 484813a93..85533223d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - 4.0.8 + 4.0.11 diff --git a/src/Microsoft.Sbom.Api/Utils/ComponentDetector.cs b/src/Microsoft.Sbom.Api/Utils/ComponentDetector.cs index efb2bcb77..02c1461ff 100644 --- a/src/Microsoft.Sbom.Api/Utils/ComponentDetector.cs +++ b/src/Microsoft.Sbom.Api/Utils/ComponentDetector.cs @@ -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; @@ -20,20 +21,26 @@ public class ComponentDetector : IComponentDetector private readonly IDetectorProcessingService detectorProcessingService; private readonly IDetectorRestrictionService detectorRestrictionService; private readonly IGraphTranslationService graphTranslationService; - private readonly ILogger logger; + private readonly IFileWritingService fileWritingService; + private readonly ILogger scanExecutionLogger; + private readonly ILogger scanCommandLogger; public ComponentDetector( IEnumerable detectors, IDetectorProcessingService detectorProcessingService, IDetectorRestrictionService detectorRestrictionService, IGraphTranslationService graphTranslationService, - ILogger logger) + IFileWritingService fileWritingService, + ILogger scanExecutionLogger, + ILogger 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 ScanAsync(ScanSettings args) @@ -43,8 +50,8 @@ public virtual async Task 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); } }