File tree 3 files changed +25
-1
lines changed
3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export interface ArgsOptions {
68
68
// (see the snyk-mvn-plugin or snyk-gradle-plugin)
69
69
_doubleDashArgs : string [ ] ;
70
70
_ : MethodArgs ;
71
- [ key : string ] : boolean | string | MethodArgs | string [ ] ; // The two last types are for compatibility only
71
+ [ key : string ] : boolean | string | number | MethodArgs | string [ ] ; // The two last types are for compatibility only
72
72
}
73
73
74
74
export function args ( rawArgv : string [ ] ) : Args {
@@ -227,6 +227,10 @@ export function args(rawArgv: string[]): Args {
227
227
}
228
228
}
229
229
230
+ if ( argv . detectionDepth !== undefined ) {
231
+ argv . detectionDepth = Number ( argv . detectionDepth ) ;
232
+ }
233
+
230
234
if ( argv . skipUnresolved !== undefined ) {
231
235
if ( argv . skipUnresolved === 'false' ) {
232
236
argv . allowMissing = false ;
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
1
2
import 'source-map-support/register' ;
2
3
import * as Debug from 'debug' ;
3
4
import * as pathLib from 'path' ;
@@ -39,6 +40,7 @@ import {
39
40
SupportedUserReachableFacingCliArgs ,
40
41
} from '../lib/types' ;
41
42
import { SarifFileOutputEmptyError } from '../lib/errors/empty-sarif-output-error' ;
43
+ import { InvalidDetectionDepthValue } from '../lib/errors/invalid-detection-depth-value' ;
42
44
43
45
const debug = Debug ( 'snyk' ) ;
44
46
const EXIT_CODES = {
@@ -261,6 +263,14 @@ async function main() {
261
263
throw new FileFlagBadInputError ( ) ;
262
264
}
263
265
266
+ if (
267
+ typeof args . options . detectionDepth !== 'undefined' &&
268
+ ( args . options . detectionDepth <= 0 ||
269
+ Number . isNaN ( args . options . detectionDepth ) )
270
+ ) {
271
+ throw new InvalidDetectionDepthValue ( ) ;
272
+ }
273
+
264
274
validateUnsupportedSarifCombinations ( args ) ;
265
275
266
276
validateOutputFile ( args . options , 'json' , new JsonFileOutputBadInputError ( ) ) ;
Original file line number Diff line number Diff line change
1
+ import { CustomError } from './custom-error' ;
2
+
3
+ export class InvalidDetectionDepthValue extends CustomError {
4
+ constructor ( ) {
5
+ const msg = `Unsupported value for --detection-depth flag. Expected a positive integer.` ;
6
+ super ( msg ) ;
7
+ this . code = 422 ;
8
+ this . userMessage = msg ;
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments