@@ -10,20 +10,15 @@ import { IGraphResponse, XrayScanProgress } from 'jfrog-client-js';
10
10
import { RootNode } from '../treeDataProviders/dependenciesTree/dependenciesRoot/rootTree' ;
11
11
import { AnalyzerUtils } from '../treeDataProviders/utils/analyzerUtils' ;
12
12
import { StepProgress } from '../treeDataProviders/utils/stepProgress' ;
13
- import { ExcludeScanner , Module } from '../types/jfrogAppsConfig' ;
14
- import { AppsConfigUtils } from '../utils/appConfigUtils' ;
15
13
import { Configuration } from '../utils/configuration' ;
16
14
import { Resource } from '../utils/resource' ;
17
15
import { ScanUtils } from '../utils/scanUtils' ;
18
16
import { Utils } from '../utils/utils' ;
19
17
import { GraphScanLogic } from './scanGraphLogic' ;
20
18
import { ApplicabilityRunner , ApplicabilityScanResponse } from './scanRunners/applicabilityScan' ;
21
- import { BinaryRunner } from './scanRunners/binaryRunner' ;
22
- import { IacRunner , IacScanResponse } from './scanRunners/iacScan' ;
23
- import { SastScanResponse , SastRunner } from './scanRunners/sastScan' ;
24
- import { SecretsRunner , SecretsScanResponse } from './scanRunners/secretsScan' ;
19
+ import { JasScanner } from './scanRunners/binaryRunner' ;
25
20
26
- export interface SupportedScans {
21
+ export interface EntitledScans {
27
22
dependencies : boolean ;
28
23
applicability : boolean ;
29
24
sast : boolean ;
@@ -39,7 +34,7 @@ export class ScanManager implements ExtensionComponent {
39
34
private static readonly RESOURCE_CHECK_UPDATE_INTERVAL_MILLISECS : number = 1000 * 60 * 60 * 24 ;
40
35
41
36
private static lastOutdatedCheck : number ;
42
- private _supportedScans : SupportedScans = { } as SupportedScans ;
37
+ private _entitledScans : EntitledScans = { } as EntitledScans ;
43
38
44
39
constructor ( private _connectionManager : ConnectionManager , protected _logManager : LogManager ) { }
45
40
@@ -56,16 +51,16 @@ export class ScanManager implements ExtensionComponent {
56
51
return this . _connectionManager ;
57
52
}
58
53
59
- public get supportedScans ( ) : SupportedScans {
60
- return this . _supportedScans ;
54
+ public get entitledScans ( ) : EntitledScans {
55
+ return this . _entitledScans ;
61
56
}
62
57
63
58
/**
64
59
* Updates all the resources that are outdated.
65
60
* @param supportedScans - the supported scan to get the needed resources. if default, should call getSupportedScans before calling this method.
66
61
* @returns true if all the outdated resources updated successfully, false otherwise
67
62
*/
68
- public async updateResources ( supportedScans : SupportedScans = this . _supportedScans ) : Promise < boolean > {
63
+ public async updateResources ( supportedScans : EntitledScans = this . _entitledScans ) : Promise < boolean > {
69
64
let result : boolean = true ;
70
65
await ScanUtils . backgroundTask ( async ( progress : vscode . Progress < { message ?: string ; increment ?: number } > ) => {
71
66
progress . report ( { message : 'Checking for updates' } ) ;
@@ -98,7 +93,7 @@ export class ScanManager implements ExtensionComponent {
98
93
return result ;
99
94
}
100
95
101
- private async getOutdatedResources ( supportedScans : SupportedScans ) : Promise < Resource [ ] > {
96
+ private async getOutdatedResources ( supportedScans : EntitledScans ) : Promise < Resource [ ] > {
102
97
if ( ! this . shouldCheckOutdated ( ) ) {
103
98
return [ ] ;
104
99
}
@@ -130,23 +125,16 @@ export class ScanManager implements ExtensionComponent {
130
125
return ! ScanManager . lastOutdatedCheck || Date . now ( ) - ScanManager . lastOutdatedCheck > ScanManager . RESOURCE_CHECK_UPDATE_INTERVAL_MILLISECS ;
131
126
}
132
127
133
- private getResources ( supportedScans : SupportedScans ) : Resource [ ] {
128
+ private getResources ( supportedScans : EntitledScans ) : Resource [ ] {
134
129
let resources : Resource [ ] = [ ] ;
135
130
if ( supportedScans . applicability || supportedScans . iac || supportedScans . secrets ) {
136
- resources . push ( BinaryRunner . getAnalyzerManagerResource ( this . _logManager ) ) ;
131
+ resources . push ( JasScanner . getAnalyzerManagerResource ( this . _logManager ) ) ;
137
132
} else {
138
133
this . logManager . logMessage ( 'You are not entitled to run Advanced Security scans' , 'DEBUG' ) ;
139
134
}
140
135
return resources ;
141
136
}
142
137
143
- /**
144
- * Validate if the graph-scan is supported in the Xray version
145
- */
146
- public async validateGraphSupported ( ) : Promise < boolean > {
147
- return await ConnectionUtils . testXrayVersionForScanGraph ( this . _connectionManager . createJfrogClient ( ) , this . _logManager ) ;
148
- }
149
-
150
138
/**
151
139
* Check if Contextual Analysis (Applicability) is supported for the user
152
140
*/
@@ -179,14 +167,9 @@ export class ScanManager implements ExtensionComponent {
179
167
/**
180
168
* Get all the entitlement status for each type of scan the manager offers
181
169
*/
182
- public async getSupportedScans ( ) : Promise < SupportedScans > {
183
- let supportedScans : SupportedScans = { } as SupportedScans ;
170
+ public async getSupportedScans ( ) : Promise < EntitledScans > {
171
+ let supportedScans : EntitledScans = { } as EntitledScans ;
184
172
let requests : Promise < any > [ ] = [ ] ;
185
- requests . push (
186
- this . validateGraphSupported ( )
187
- . then ( res => ( supportedScans . dependencies = res ) )
188
- . catch ( err => ScanUtils . onScanError ( err , this . _logManager , true ) )
189
- ) ;
190
173
requests . push (
191
174
this . isApplicabilitySupported ( )
192
175
. then ( res => ( supportedScans . applicability = res ) )
@@ -208,7 +191,7 @@ export class ScanManager implements ExtensionComponent {
208
191
. catch ( err => ScanUtils . onScanError ( err , this . _logManager , true ) )
209
192
) ;
210
193
await Promise . all ( requests ) ;
211
- this . _supportedScans = supportedScans ;
194
+ this . _entitledScans = supportedScans ;
212
195
return supportedScans ;
213
196
}
214
197
@@ -250,60 +233,4 @@ export class ScanManager implements ExtensionComponent {
250
233
) ;
251
234
return await applicableRunner . scan ( directory , checkCancel , cveToRun , skipFiles ) ;
252
235
}
253
-
254
- /**
255
- * Scan directory for 'Infrastructure As Code' (Iac) issues.
256
- * @param module - the module that will be scanned
257
- * @param checkCancel - check if should cancel
258
- * @returns the Iac scan response
259
- */
260
- public async scanIac ( module : Module , checkCancel : ( ) => void ) : Promise < IacScanResponse | undefined > {
261
- let iacRunner : IacRunner = new IacRunner ( this . _connectionManager , this . logManager ) ;
262
- if ( ! iacRunner . validateSupported ( ) ) {
263
- this . _logManager . logMessage ( 'Iac runner could not find binary to run' , 'WARN' ) ;
264
- return undefined ;
265
- }
266
- if ( AppsConfigUtils . ShouldSkipScanner ( module , ExcludeScanner . Iac ) ) {
267
- this . _logManager . debug ( 'Skipping IaC scanning' ) ;
268
- return undefined ;
269
- }
270
- return await iacRunner . scan ( module , checkCancel ) ;
271
- }
272
- /**
273
- * Scan directory for secrets issues.
274
- * @param module - the module that will be scanned
275
- * @param checkCancel - check if should cancel
276
- * @returns the Secrets scan response
277
- */
278
- public async scanSecrets ( module : Module , checkCancel : ( ) => void ) : Promise < SecretsScanResponse | undefined > {
279
- let secretsRunner : SecretsRunner = new SecretsRunner ( this . _connectionManager , this . logManager ) ;
280
- if ( ! secretsRunner . validateSupported ( ) ) {
281
- this . _logManager . logMessage ( 'Secrets runner could not find binary to run' , 'WARN' ) ;
282
- return undefined ;
283
- }
284
- if ( AppsConfigUtils . ShouldSkipScanner ( module , ExcludeScanner . Secrets ) ) {
285
- this . _logManager . debug ( 'Skipping secrets scanning' ) ;
286
- return undefined ;
287
- }
288
- return await secretsRunner . scan ( module , checkCancel ) ;
289
- }
290
-
291
- /**
292
- * Scan for SAST issues.
293
- * @param module - the module that will be scanned
294
- * @param requests - the SAST requests to run
295
- * @returns the scan response
296
- */
297
- public async scanSast ( module : Module , checkCancel : ( ) => void ) : Promise < SastScanResponse | undefined > {
298
- let sastRunner : SastRunner = new SastRunner ( this . _connectionManager , this . _logManager ) ;
299
- if ( ! sastRunner . validateSupported ( ) ) {
300
- this . _logManager . logMessage ( 'Sast runner could not find binary to run' , 'WARN' ) ;
301
- return undefined ;
302
- }
303
- if ( AppsConfigUtils . ShouldSkipScanner ( module , ExcludeScanner . Sast ) ) {
304
- this . _logManager . debug ( 'Skipping SAST scanning' ) ;
305
- return undefined ;
306
- }
307
- return sastRunner . scan ( module , checkCancel ) ;
308
- }
309
236
}
0 commit comments