diff --git a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt index 6729865a8..0f8338991 100644 --- a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt +++ b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt @@ -47,80 +47,82 @@ class AnalyticsScanListener(val project: Project) { ) } - fun initScanListener() = project.messageBus.connect().subscribe( - SnykScanListener.SNYK_SCAN_TOPIC, - object : SnykScanListener { - var start: Long = 0 + private val snykScanListener = object : SnykScanListener { + var start: Long = 0 - override fun scanningStarted() { - start = System.currentTimeMillis() - } + override fun scanningStarted() { + start = System.currentTimeMillis() + } - override fun scanningOssFinished(ossResult: OssResult) { + override fun scanningOssFinished(ossResult: OssResult) { + val scanDoneEvent = getScanDoneEvent( + System.currentTimeMillis() - start, + "Snyk Open Source", + ossResult.criticalSeveritiesCount(), + ossResult.highSeveritiesCount(), + ossResult.mediumSeveritiesCount(), + ossResult.lowSeveritiesCount() + ) + getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) + } + + override fun scanningSnykCodeFinished(snykCodeResults: SnykCodeResults?) { + snykCodeResults?.let { val scanDoneEvent = getScanDoneEvent( System.currentTimeMillis() - start, - "Snyk Open Source", - ossResult.criticalSeveritiesCount(), - ossResult.highSeveritiesCount(), - ossResult.mediumSeveritiesCount(), - ossResult.lowSeveritiesCount() + "Snyk Code", + snykCodeResults.totalCriticalCount, + snykCodeResults.totalErrorsCount, + snykCodeResults.totalWarnsCount, + snykCodeResults.totalInfosCount, ) getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) } + } - override fun scanningSnykCodeFinished(snykCodeResults: SnykCodeResults?) { - snykCodeResults?.let { - val scanDoneEvent = getScanDoneEvent( - System.currentTimeMillis() - start, - "Snyk Code", - snykCodeResults.totalCriticalCount, - snykCodeResults.totalErrorsCount, - snykCodeResults.totalWarnsCount, - snykCodeResults.totalInfosCount, - ) - getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) - } - } + override fun scanningIacFinished(iacResult: IacResult) { + val scanDoneEvent = getScanDoneEvent( + System.currentTimeMillis() - start, + "Snyk IaC", + iacResult.criticalSeveritiesCount(), + iacResult.highSeveritiesCount(), + iacResult.mediumSeveritiesCount(), + iacResult.lowSeveritiesCount() + ) + getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) + } - override fun scanningIacFinished(iacResult: IacResult) { - val scanDoneEvent = getScanDoneEvent( - System.currentTimeMillis() - start, - "Snyk IaC", - iacResult.criticalSeveritiesCount(), - iacResult.highSeveritiesCount(), - iacResult.mediumSeveritiesCount(), - iacResult.lowSeveritiesCount() - ) - getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) - } + override fun scanningOssError(snykError: SnykError) { + // do nothing + } - override fun scanningOssError(snykError: SnykError) { - // do nothing - } + override fun scanningIacError(snykError: SnykError) { + // do nothing + } - override fun scanningIacError(snykError: SnykError) { - // do nothing - } + override fun scanningSnykCodeError(snykError: SnykError) { + // do nothing + } - override fun scanningSnykCodeError(snykError: SnykError) { - // do nothing - } + override fun scanningContainerFinished(containerResult: ContainerResult) { + val scanDoneEvent = getScanDoneEvent( + System.currentTimeMillis() - start, + "Snyk Container", + containerResult.criticalSeveritiesCount(), + containerResult.highSeveritiesCount(), + containerResult.mediumSeveritiesCount(), + containerResult.lowSeveritiesCount() + ) + getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) + } - override fun scanningContainerFinished(containerResult: ContainerResult) { - val scanDoneEvent = getScanDoneEvent( - System.currentTimeMillis() - start, - "Snyk Container", - containerResult.criticalSeveritiesCount(), - containerResult.highSeveritiesCount(), - containerResult.mediumSeveritiesCount(), - containerResult.lowSeveritiesCount() - ) - getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) - } + override fun scanningContainerError(snykError: SnykError) { + // do nothing + } + } - override fun scanningContainerError(snykError: SnykError) { - // do nothing - } - }, + fun initScanListener() = project.messageBus.connect().subscribe( + SnykScanListener.SNYK_SCAN_TOPIC, + snykScanListener, ) } diff --git a/src/main/kotlin/io/snyk/plugin/services/SnykTaskQueueService.kt b/src/main/kotlin/io/snyk/plugin/services/SnykTaskQueueService.kt index 0977432d8..284ac293f 100644 --- a/src/main/kotlin/io/snyk/plugin/services/SnykTaskQueueService.kt +++ b/src/main/kotlin/io/snyk/plugin/services/SnykTaskQueueService.kt @@ -194,7 +194,6 @@ class SnykTaskQueueService(val project: Project) { settings.localCodeEngineEnabled = sastCliConfigSettings?.localCodeEngine?.enabled settings.localCodeEngineUrl = sastCliConfigSettings?.localCodeEngine?.url settings.reportFalsePositivesEnabled = sastCliConfigSettings?.reportFalsePositivesEnabled - val start = System.currentTimeMillis() when (settings.sastOnServerEnabled) { true -> { getSnykCode(project)?.scan()