You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi 馃憢
Currently, it seems that the only way to use this tool is by command line.
It seems that the DI registration is using AsSingleton for all the components and not a scoped instance, leading to errors between calls because of the states the detectors are using.
It will be very appreciated if docs on how to use this tool as a library will be added (as it states in the README.md that it could)
It seems that the DI registration is using AsSingleton for all the components and not a scoped instance, leading to errors between calls because of the states the detectors are using.
Seems like there are detectors that holds state which leads to errors between calling such as:
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Microsoft.ComponentDetection.Detectors.NuGet.NuGetProjectModelProjectCentricComponentDetector.OnDetectionFinishedAsync()
at Microsoft.ComponentDetection.Contracts.FileComponentDetector.ProcessAsync(IObservable`1 processRequests, IDictionary`2 detectorArgs)
at Microsoft.ComponentDetection.Contracts.FileComponentDetector.ExecuteDetectorAsync(ScanRequest request)
at Microsoft.ComponentDetection.Orchestrator.Services.DetectorProcessingService.WithExperimentalScanGuardsAsync(Func`1 detectionTaskGenerator, Boolean isExperimentalDetector, DetectorExecutionTelemetryRecord telemetryRecord)
at Microsoft.ComponentDetection.Orchestrator.Services.DetectorProcessingService.<>c__DisplayClass4_0.<<ProcessDetectorsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.ComponentDetection.Orchestrator.Services.DetectorProcessingService.ProcessDetectorsAsync(IDetectionArguments detectionArguments, IEnumerable`1 detectors, DetectorRestrictions detectorRestrictions)
at Microsoft.ComponentDetection.Orchestrator.Services.BcdeScanExecutionService.ExecuteScanAsync(IDetectionArguments detectionArguments)
Base path has not yet been initialized in File Writing Service!
Microsoft.ComponentDetection.Commonexception.StackTraceString:
at Microsoft.ComponentDetection.Common.FileWritingService.EnsureInit()
at Microsoft.ComponentDetection.Common.FileWritingService.ResolveFilePath(String relativeFilePath)
at Microsoft.ComponentDetection.Orchestrator.Experiments.DefaultExperimentProcessor.ProcessExperimentAsync(IExperimentConfiguration config, ExperimentDiff diff)
at Microsoft.ComponentDetection.Orchestrator.Experiments.ExperimentService.FinishAsync()
Running as a library, I don't expect the file-writing service to do anything, right?
Base path has not yet been initialized in File Writing Service!
Microsoft.ComponentDetection.Commonexception.StackTraceString:
at Microsoft.ComponentDetection.Common.FileWritingService.EnsureInit()
at Microsoft.ComponentDetection.Common.FileWritingService.ResolveFilePath(String relativeFilePath)
at Microsoft.ComponentDetection.Orchestrator.Experiments.DefaultExperimentProcessor.ProcessExperimentAsync(IExperimentConfiguration config, ExperimentDiff diff)
at Microsoft.ComponentDetection.Orchestrator.Experiments.ExperimentService.FinishAsync()
Running as a library, I don't expect the file-writing service to do anything, right?
Call Init in the file writer service, or register a service that does nothing.
Activity
melotic commentedon Aug 17, 2023
Hi,
CD is supported as using a library. You'd have to use DI to resolve a
IBcdeScanExecutionServiceand runExecuteScanAsync.You can use the extension method
AddComponentDetectionto yourServiceCollectionto register all dependencies.component-detection/src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs
Line 41 in 74fae32
Can you share the exact error?
edena-legit commentedon Aug 20, 2023
Seems like there are detectors that holds state which leads to errors between calling such as:
edena-legit commentedon Aug 20, 2023
I'm receiving the following error as well:
Running as a library, I don't expect the file-writing service to do anything, right?
edena-legit commentedon Aug 23, 2023
Justin Perez (@melotic), Anything on that?
melotic commentedon Aug 28, 2023
Call
Initin the file writer service, or register a service that does nothing.component-detection/src/Microsoft.ComponentDetection.Orchestrator/Orchestrator.cs
Line 165 in 2b86e05