Skip to content

Commit b0b8848

Browse files
committed
CLIS-36 Limit the numbers of file= in a fingerprint block
1 parent 3d7bebe commit b0b8848

File tree

5 files changed

+386
-224
lines changed

5 files changed

+386
-224
lines changed

Diff for: src/cli/bin/cli-bin.ts

+104-31
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { wfpHandler } from '../commands/wfp';
66
import { scanHandler } from '../commands/scan';
77
import { Utils } from '../../sdk/Utils/Utils';
88

9-
10-
119
function CLIErrorHandler(e: Error) {
1210
console.error(' ');
1311
console.error(e);
@@ -17,61 +15,136 @@ function CLIErrorHandler(e: Error) {
1715
async function main() {
1816
program
1917
.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+
);
2121

2222
program
2323
.command('scan <source>')
2424
.description('Scan a folder/file')
2525
.option('-w, --wfp', 'Scan a .wfp file instead of a folder')
2626
.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+
)
2935
.option(' --extract-deep <number>', 'Sets uncompress recursion level')
3036
.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+
)
3969
.option('--obfuscate', 'Obfuscate fingerprints')
4070
.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+
)
4483
.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+
)
4896
.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+
`
51105
Examples:
52106
$ scanoss-js scan -o scan-output.json <source-folder>`
53107
);
54108

55-
program
109+
program
56110
.command('dep <source>')
57111
.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+
});
61125

62-
program
126+
program
63127
.command('wfp <source>')
64128
.description('Generates fingerprints for a folder/file')
65129
.option('-H, --hpsm', 'Scan using winnowing high precision matching')
66130
.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+
});
70144

71-
await program.parseAsync(process.argv);
145+
await program.parseAsync(process.argv);
72146
}
73147

74-
75148
try {
76149
main();
77150
} catch (e) {

0 commit comments

Comments
 (0)