@@ -6,8 +6,6 @@ import { wfpHandler } from '../commands/wfp';
6
6
import { scanHandler } from '../commands/scan' ;
7
7
import { Utils } from '../../sdk/Utils/Utils' ;
8
8
9
-
10
-
11
9
function CLIErrorHandler ( e : Error ) {
12
10
console . error ( ' ' ) ;
13
11
console . error ( e ) ;
@@ -17,61 +15,136 @@ function CLIErrorHandler(e: Error) {
17
15
async function main ( ) {
18
16
program
19
17
. version ( Utils . getPackageVersion ( ) )
20
- . description ( 'The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.' )
18
+ . description (
19
+ 'The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.'
20
+ ) ;
21
21
22
22
program
23
23
. command ( 'scan <source>' )
24
24
. description ( 'Scan a folder/file' )
25
25
. option ( '-w, --wfp' , 'Scan a .wfp file instead of a folder' )
26
26
. option ( '-H, --hpsm' , 'Scan using winnowing high precision matching' )
27
- . option ( '-x, --extract' , 'Extract compressed files before launch scan in folder <<zip_name>>-unzipped' )
28
- . option ( ' --extract-overwrite' , 'Overwrite folder when decompressing if exists' )
27
+ . option (
28
+ '-x, --extract' ,
29
+ 'Extract compressed files before launch scan in folder <<zip_name>>-unzipped'
30
+ )
31
+ . option (
32
+ ' --extract-overwrite' ,
33
+ 'Overwrite folder when decompressing if exists'
34
+ )
29
35
. option ( ' --extract-deep <number>' , 'Sets uncompress recursion level' )
30
36
. option ( ' --extract-suffix <suffix>' , 'Sets suffix for the folder name' )
31
- . option ( '-c, --concurrency <number>' , 'Number of concurrent connections to use while scanning (optional -default 10)' )
32
- . option ( '-n, --ignore <ignore>' , 'Ignore components specified in the SBOM file' )
33
- . option ( '-o, --output <filename>' , 'Output result file name (optional - default stdout)' )
34
- . option ( '-f, --format <format>' , 'Result output format. {JSON, HTML} Default: JSON' )
35
- . option ( '-F, --flags <flags>' , 'Scanning engine flags (1: disable snippet matching, 2 enable snippet ids, 4: disable dependencies, 8: disable licenses, 16: disable copyrights,32: disable vulnerabilities, 64: disable quality, 128: disable cryptography,256: disable best match, 512: Report identified files)' )
36
- . option ( '-P, --post-size <postsize>' , 'Number of kilobytes to limit the post to while scanning (optional - default 64)' )
37
- . option ( '-R, --max-retry <retry>' , 'Max number of retries for each POST (optional -default 5)' )
38
- . option ( '-M, --timeout <timeout>' , 'Timeout (in seconds) for API communication (optional -default 120)' )
37
+ . option (
38
+ '-c, --concurrency <number>' ,
39
+ 'Number of concurrent connections to use while scanning (optional -default 10)'
40
+ )
41
+ . option (
42
+ '-n, --ignore <ignore>' ,
43
+ 'Ignore components specified in the SBOM file'
44
+ )
45
+ . option (
46
+ '-o, --output <filename>' ,
47
+ 'Output result file name (optional - default stdout)'
48
+ )
49
+ . option (
50
+ '-f, --format <format>' ,
51
+ 'Result output format. {JSON, HTML} Default: JSON'
52
+ )
53
+ . option (
54
+ '-F, --flags <flags>' ,
55
+ 'Scanning engine flags (1: disable snippet matching, 2 enable snippet ids, 4: disable dependencies, 8: disable licenses, 16: disable copyrights,32: disable vulnerabilities, 64: disable quality, 128: disable cryptography,256: disable best match, 512: Report identified files)'
56
+ )
57
+ . option (
58
+ '-P, --post-size <postsize>' ,
59
+ 'Number of kilobytes to limit the post to while scanning (optional - default 32)'
60
+ )
61
+ . option (
62
+ '-R, --max-retry <retry>' ,
63
+ 'Max number of retries for each POST (optional -default 5)'
64
+ )
65
+ . option (
66
+ '-M, --timeout <timeout>' ,
67
+ 'Timeout (in seconds) for API communication (optional -default 120)'
68
+ )
39
69
. option ( '--obfuscate' , 'Obfuscate fingerprints' )
40
70
. option ( '-D, --dependencies' , 'Add dependency scanning' )
41
- . option ( '--apiurl <apiurl>' , 'SCANOSS API URL (optional - default: https://osskb.org/api/scan/direct)' )
42
- . option ( '--api2url <api2url>' , 'SCANOSS gRPC API 2.0 URL (optional - default: scanoss.com:443)' )
43
- . option ( '-k, --key <key>' , 'SCANOSS API Key token (optional - not required for default OSSKB URL)' )
71
+ . option (
72
+ '--apiurl <apiurl>' ,
73
+ 'SCANOSS API URL (optional - default: https://osskb.org/api/scan/direct)'
74
+ )
75
+ . option (
76
+ '--api2url <api2url>' ,
77
+ 'SCANOSS gRPC API 2.0 URL (optional - default: scanoss.com:443)'
78
+ )
79
+ . option (
80
+ '-k, --key <key>' ,
81
+ 'SCANOSS API Key token (optional - not required for default OSSKB URL)'
82
+ )
44
83
. option ( '--ignore-cert-errors' , 'Ignore self signed certificate errors' )
45
- . option ( '--ca-cert <cert>' , 'Specify a path for a cert used in SSL/TLS connection' )
46
- . option ( '--proxy <proxy>' , 'Proxy URL to use for connections (optional). Can also use the environment variable "HTTPS_PROXY=[ip]:[port]" and "grcp_proxy=[ip]:[port]" for gRPC' )
47
- . option ( '--pac <pac>' , 'Proxy auto configuration (optional). Specify a file, http url or ftp url' )
84
+ . option (
85
+ '--ca-cert <cert>' ,
86
+ 'Specify a path for a cert used in SSL/TLS connection'
87
+ )
88
+ . option (
89
+ '--proxy <proxy>' ,
90
+ 'Proxy URL to use for connections (optional). Can also use the environment variable "HTTPS_PROXY=[ip]:[port]" and "grcp_proxy=[ip]:[port]" for gRPC'
91
+ )
92
+ . option (
93
+ '--pac <pac>' ,
94
+ 'Proxy auto configuration (optional). Specify a file, http url or ftp url'
95
+ )
48
96
. option ( '-v, --verbose' , 'Makes scan operation verbose' )
49
- . action ( ( source , options ) => { scanHandler ( source , options ) . catch ( ( e ) => { CLIErrorHandler ( e ) } ) } )
50
- . addHelpText ( 'after' , `
97
+ . action ( ( source , options ) => {
98
+ scanHandler ( source , options ) . catch ( ( e ) => {
99
+ CLIErrorHandler ( e ) ;
100
+ } ) ;
101
+ } )
102
+ . addHelpText (
103
+ 'after' ,
104
+ `
51
105
Examples:
52
106
$ scanoss-js scan -o scan-output.json <source-folder>`
53
107
) ;
54
108
55
- program
109
+ program
56
110
. command ( 'dep <source>' )
57
111
. description ( 'Scan for dependencies' )
58
- . option ( '-o, --output <filename>' , 'Output result file name (optional - default stdout)' )
59
- . option ( '-a, --grpc-host <host>' , 'SCANOSS GRPC HOST (optional - default: scanoss.com:443)' )
60
- . action ( ( source , options ) => { depHandler ( source , options ) . catch ( ( e ) => { CLIErrorHandler ( e ) } ) } )
112
+ . option (
113
+ '-o, --output <filename>' ,
114
+ 'Output result file name (optional - default stdout)'
115
+ )
116
+ . option (
117
+ '-a, --grpc-host <host>' ,
118
+ 'SCANOSS GRPC HOST (optional - default: scanoss.com:443)'
119
+ )
120
+ . action ( ( source , options ) => {
121
+ depHandler ( source , options ) . catch ( ( e ) => {
122
+ CLIErrorHandler ( e ) ;
123
+ } ) ;
124
+ } ) ;
61
125
62
- program
126
+ program
63
127
. command ( 'wfp <source>' )
64
128
. description ( 'Generates fingerprints for a folder/file' )
65
129
. option ( '-H, --hpsm' , 'Scan using winnowing high precision matching' )
66
130
. option ( '--obfuscate' , 'Obfuscate fingerprints' )
67
- . option ( '-o, --output <filename>' , 'Output result file name (optional - default stdout)' )
68
- . option ( '-p, --block-size <size>' , 'Maximum size in Kb for each fingerprint block (optional - default 64Kb)' )
69
- . action ( ( source , options ) => { wfpHandler ( source , options ) . catch ( ( e ) => { CLIErrorHandler ( e ) } ) } )
131
+ . option (
132
+ '-o, --output <filename>' ,
133
+ 'Output result file name (optional - default stdout)'
134
+ )
135
+ . option (
136
+ '-p, --block-size <size>' ,
137
+ 'Maximum size in Kb for each fingerprint block (optional - default 64Kb)'
138
+ )
139
+ . action ( ( source , options ) => {
140
+ wfpHandler ( source , options ) . catch ( ( e ) => {
141
+ CLIErrorHandler ( e ) ;
142
+ } ) ;
143
+ } ) ;
70
144
71
- await program . parseAsync ( process . argv ) ;
145
+ await program . parseAsync ( process . argv ) ;
72
146
}
73
147
74
-
75
148
try {
76
149
main ( ) ;
77
150
} catch ( e ) {
0 commit comments