@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
22import { createMarkdownSummary , Report } from '../types' ;
33import { Instruction } from 'dockerfile-ast' ;
44import { createMarkdownVulnsForLayer } from '../types/report' ;
5+ import { vulnTreeDataProvider } from '../extension' ;
56
67interface DecorationsMap {
78 [ key : string ] : [
@@ -55,7 +56,7 @@ export function clearDecorations(document: vscode.TextDocument) {
5556 }
5657}
5758
58- export function highlightImage ( report : Report , image : string , document : vscode . TextDocument , baseImageRange ?: vscode . Range ) {
59+ export function highlightImage ( report : Report , document : vscode . TextDocument , baseImageRange ?: vscode . Range ) {
5960 if ( ! baseImageRange ) {
6061 return ;
6162 }
@@ -95,14 +96,17 @@ export function highlightLayer(report: Report, instructions : Instruction[], doc
9596 let instructionIndex = instructions . length - 1 ;
9697 let layerIndex = layers . length - 1 ;
9798 let decorations : vscode . DecorationOptions [ ] = [ ] ;
98-
99+ let imageRange : vscode . Range | undefined ;
100+ let layerRanges : Map < string , vscode . Range > = new Map < string , vscode . Range > ( ) ;
101+
99102 while ( instructionIndex >= 0 && layerIndex >= 0 ) {
100103 const instruction = instructions [ instructionIndex ] ;
101104 const layer = layers [ layerIndex ] ;
102105
103106 // Skip FROM instructions as base image is already scanned
104107 if ( instruction . getInstruction ( ) === 'FROM' ) {
105108 instructionIndex = - 1 ;
109+ imageRange = instruction . getRange ( ) as vscode . Range ;
106110 break ;
107111 }
108112
@@ -150,6 +154,10 @@ export function highlightLayer(report: Report, instructions : Instruction[], doc
150154 }
151155 } ;
152156
157+ if ( layer . digest ) {
158+ layerRanges = layerRanges . set ( layer . digest , instruction . getRange ( ) as vscode . Range ) ;
159+ }
160+
153161 decorations . push ( decorationOptions ) ;
154162 }
155163 }
@@ -160,6 +168,8 @@ export function highlightLayer(report: Report, instructions : Instruction[], doc
160168 } ) ;
161169
162170 addDecorations ( document , decorations , decorationType ) ;
171+
172+ vulnTreeDataProvider . updateVulnTree ( report . result . packages , report . info . resultUrl , document , imageRange , layerRanges ) ;
163173}
164174
165175export function grepString ( document : vscode . TextDocument , searchString : string ) : vscode . Range [ ] | undefined {
0 commit comments