diff --git a/src/providers/tree-view/utils.ts b/src/providers/tree-view/utils.ts index 42327ab..ec295a0 100644 --- a/src/providers/tree-view/utils.ts +++ b/src/providers/tree-view/utils.ts @@ -3,6 +3,7 @@ import {AnyDetection, IacDetection, SastDetection, ScaDetection, SecretDetection import {FileScanResult} from './provider'; import {SeverityFirstLetter, TreeView, TreeViewDisplayedData} from './types'; import {ScanType, SEVERITY_PRIORITIES} from '../../constants'; +import {cliService} from '../../services/CliService'; interface RefreshTreeViewDataArgs { detections: AnyDetection[]; @@ -27,11 +28,14 @@ export function refreshTreeViewData( return; } + const projectRoot = cliService.getProjectRootDirectory(); + const {provider} = treeView; const affectedFiles: FileScanResult[] = []; const detectionsMapped = mapDetectionsByFileName(detections, scanType); detectionsMapped.forEach((vulnerabilities, fullFilePath) => { - affectedFiles.push(new FileScanResult(fullFilePath, fullFilePath, vulnerabilities)); + const projectRelativePath = path.relative(projectRoot, fullFilePath); + affectedFiles.push(new FileScanResult(projectRelativePath, fullFilePath, vulnerabilities)); }); provider.refresh(affectedFiles, scanType); } diff --git a/src/services/scanners/IacScanner.ts b/src/services/scanners/IacScanner.ts index a5c7ac8..9b3b3ce 100644 --- a/src/services/scanners/IacScanner.ts +++ b/src/services/scanners/IacScanner.ts @@ -1,4 +1,5 @@ import * as vscode from 'vscode'; +import * as path from 'path'; import {extensionOutput} from '../../logging/extension-output'; import {cliWrapper} from '../../cli-wrapper/cli-wrapper'; import statusBar from '../../utils/status-bar'; @@ -162,8 +163,11 @@ const detectionsToDiagnostics = async ( let message = `Severity: ${detection.severity}\n`; message += `Description: ${detection.message}\n`; + message += `IaC Provider: ${detection.detection_details.infra_provider}\n`; - message += `In file: ${detection.detection_details.file_name}\n`; + + const fileName = path.basename(detection.detection_details.file_name); + message += `In file: ${fileName}\n`; const diagnostic = new vscode.Diagnostic( document.lineAt(detection_details.line_in_file - 1).range,