scanoss 0.4.10-beta → 0.4.12-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.idea/workspace.xml +22 -18
  2. package/build/main/cli/bin/cli-bin.js +5 -5
  3. package/build/main/cli/commands/wfp.d.ts +1 -0
  4. package/build/main/cli/commands/wfp.js +54 -0
  5. package/build/main/sdk/scanner/Dispatcher/Dispatcher.js +1 -1
  6. package/build/main/sdk/scanner/Scanner.js +3 -3
  7. package/build/main/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.d.ts +1 -1
  8. package/build/main/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +33 -31
  9. package/build/main/tsconfig.tsbuildinfo +21 -21
  10. package/build/module/cli/bin/cli-bin.js +5 -5
  11. package/build/module/cli/commands/wfp.d.ts +1 -0
  12. package/build/module/cli/commands/wfp.js +48 -0
  13. package/build/module/sdk/scanner/Scanner.js +3 -3
  14. package/build/module/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.d.ts +1 -1
  15. package/build/module/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +33 -31
  16. package/build/module/tsconfig.module.tsbuildinfo +21 -21
  17. package/package-lock.json +67 -493
  18. package/package.json +1 -1
  19. package/src/cli/bin/cli-bin.ts +4 -4
  20. package/src/cli/commands/{fingerprint.ts → wfp.ts} +1 -1
  21. package/src/sdk/scanner/Scanner.ts +2 -2
  22. package/src/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.ts +36 -32
  23. package/tests/scanoss.sh +3 -8
  24. package/tests/sdk/Scanner/WfpProvider/WfpSplitter/WfpSplitter.spec.ts +0 -2
  25. package/yarn.lock +4886 -4737
  26. package/build/main/cli/commands/fingerprint.d.ts +0 -1
  27. package/build/main/cli/commands/fingerprint.js +0 -54
  28. package/build/main/sdk/Decompress/DecompressionManager.d.ts +0 -12
  29. package/build/main/sdk/Decompress/DecompressionManager.js +0 -65
  30. package/build/main/sdk/Decompress/Decompressor/DecompressTgz.d.ts +0 -5
  31. package/build/main/sdk/Decompress/Decompressor/DecompressTgz.js +0 -22
  32. package/build/main/sdk/Decompress/Decompressor/DecompressZips.d.ts +0 -5
  33. package/build/main/sdk/Decompress/Decompressor/DecompressZips.js +0 -24
  34. package/build/main/sdk/Decompress/Decompressor/Decompressor.d.ts +0 -10
  35. package/build/main/sdk/Decompress/Decompressor/Decompressor.js +0 -18
  36. package/build/main/sdk/modules/reports/Report.d.ts +0 -24
  37. package/build/main/sdk/modules/reports/Report.js +0 -75
  38. package/build/main/sdk/modules/reports/ReportAdapter.d.ts +0 -12
  39. package/build/main/sdk/modules/reports/ReportAdapter.js +0 -117
  40. package/build/main/sdk/modules/reports/htmlReport/HTMLReport.d.ts +0 -14
  41. package/build/main/sdk/modules/reports/htmlReport/HTMLReport.js +0 -39
  42. package/build/main/sdk/modules/reports/types.d.ts +0 -44
  43. package/build/main/sdk/modules/reports/types.js +0 -8
  44. package/build/main/sdk/tree/Filters/DecompressionFilter.d.ts +0 -7
  45. package/build/main/sdk/tree/Filters/DecompressionFilter.js +0 -21
  46. package/build/module/cli/commands/fingerprint.d.ts +0 -1
  47. package/build/module/cli/commands/fingerprint.js +0 -48
  48. package/build/module/sdk/Decompress/DecompressionManager.d.ts +0 -12
  49. package/build/module/sdk/Decompress/DecompressionManager.js +0 -59
  50. package/build/module/sdk/Decompress/Decompressor/DecompressTgz.d.ts +0 -5
  51. package/build/module/sdk/Decompress/Decompressor/DecompressTgz.js +0 -16
  52. package/build/module/sdk/Decompress/Decompressor/DecompressZips.d.ts +0 -5
  53. package/build/module/sdk/Decompress/Decompressor/DecompressZips.js +0 -18
  54. package/build/module/sdk/Decompress/Decompressor/Decompressor.d.ts +0 -10
  55. package/build/module/sdk/Decompress/Decompressor/Decompressor.js +0 -15
  56. package/build/module/sdk/modules/reports/Report.d.ts +0 -24
  57. package/build/module/sdk/modules/reports/Report.js +0 -80
  58. package/build/module/sdk/modules/reports/ReportAdapter.d.ts +0 -12
  59. package/build/module/sdk/modules/reports/ReportAdapter.js +0 -115
  60. package/build/module/sdk/modules/reports/htmlReport/HTMLReport.d.ts +0 -14
  61. package/build/module/sdk/modules/reports/htmlReport/HTMLReport.js +0 -41
  62. package/build/module/sdk/modules/reports/types.d.ts +0 -44
  63. package/build/module/sdk/modules/reports/types.js +0 -6
  64. package/build/module/sdk/tree/Filters/DecompressionFilter.d.ts +0 -7
  65. package/build/module/sdk/tree/Filters/DecompressionFilter.js +0 -18
  66. package/build/tsconfig.module.tsbuildinfo +0 -1
  67. package/build/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scanoss",
3
- "version": "0.4.10-beta",
3
+ "version": "0.4.12-beta",
4
4
  "description": "The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { program } from 'commander';
4
4
  import { depHandler } from '../commands/dep';
5
- import { fingerprintHandler } from '../commands/fingerprint';
5
+ import { wfpHandler } from '../commands/wfp';
6
6
  import { scanHandler } from '../commands/scan';
7
7
 
8
8
 
@@ -17,7 +17,7 @@ function CLIErrorHandler(e: Error) {
17
17
 
18
18
  async function main() {
19
19
  program
20
- .version("0.4.10-beta")
20
+ .version("0.4.12-beta")
21
21
  .description('The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.')
22
22
 
23
23
  program
@@ -53,12 +53,12 @@ async function main() {
53
53
  .action((source, options) => {depHandler(source, options).catch((e) => {CLIErrorHandler(e)})})
54
54
 
55
55
  program
56
- .command('fingerprint <source>')
56
+ .command('wfp <source>')
57
57
  .description('Generates fingerprints for a folder/file')
58
58
  .option('-H, --hpsm', 'Scan using winnowing high precision matching')
59
59
  .option('-o, --output <filename>', 'Output result file name (optional - default stdout)')
60
60
  .option('-p, --block-size <size>', 'Maximum size in Kb for each fingerprint block (optional - default 64Kb)')
61
- .action((source, options) => {fingerprintHandler(source, options).catch((e) => {CLIErrorHandler(e)})})
61
+ .action((source, options) => {wfpHandler(source, options).catch((e) => {CLIErrorHandler(e)})})
62
62
 
63
63
  await program.parseAsync(process.argv);
64
64
  }
@@ -11,7 +11,7 @@ import { Tree } from '../../sdk/tree/Tree';
11
11
  import { DependencyFilter } from '../../sdk/tree/Filters/DependencyFilter';
12
12
 
13
13
 
14
- export async function fingerprintHandler(rootPath: string, options: any): Promise<void> {
14
+ export async function wfpHandler(rootPath: string, options: any): Promise<void> {
15
15
 
16
16
  rootPath = rootPath.replace(/\/$/, ''); // Remove trailing slash if exists
17
17
  rootPath = rootPath.replace(/^\./, process.env.PWD); // Convert relative path to absolute path.
@@ -217,7 +217,7 @@ export class Scanner extends EventEmitter {
217
217
  if (this.scannerInput[0].wfpPath) {
218
218
  this.wfpProvider = new WfpSplitter();
219
219
  this.setWinnowerListeners();
220
- this.wfpProvider.start({wfpPath: this.scannerInput[0].wfpPath});
220
+ this.wfpProvider.start(this.scannerInput[0]);
221
221
  } else {
222
222
  const folderRoot = this.scannerInput[0].folderRoot;
223
223
  const winnowingMode = this.scannerInput[0].winnowingMode;
@@ -291,7 +291,7 @@ export class Scanner extends EventEmitter {
291
291
  if (scannerInput[0]?.wfpPath) {
292
292
  this.wfpProvider = new WfpSplitter();
293
293
  this.setWinnowerListeners();
294
- this.wfpProvider.start({wfpPath: scannerInput[0].wfpPath});
294
+ this.wfpProvider.start(scannerInput[0]);
295
295
  } else {
296
296
  const folderRoot = this.scannerInput[0].folderRoot;
297
297
  const winnowingMode = this.scannerInput[0].winnowingMode;
@@ -36,7 +36,7 @@ export class WfpSplitter extends WfpProvider {
36
36
  this.fingerprints = [];
37
37
  this.continue = true;
38
38
  this.fingerprintIndex = 0;
39
- this.ignoreFiles = new Set(params.fileList);
39
+ this.ignoreFiles = new Set(params?.fileList);
40
40
 
41
41
  const wfpPath = params.wfpPath;
42
42
 
@@ -98,39 +98,43 @@ export class WfpSplitter extends WfpProvider {
98
98
  //Use a loop to make sure we read all currently available data
99
99
  while (this.continue && null !== (this.chunkDataRead = this.wfpStream.read(1 * 1024 * 1024))) { // Read chunks of 1MB 1*1024*1024
100
100
 
101
- // Removes fingerprints that are loose because the file=...... was removed in previous iteration
102
- if (ignoreFirstChunkOfFingerprint) { //TODO: Test this scenario
103
- //If there is no file= delete everything then
104
- if (this.chunkDataRead.indexOf("file=") >= 0) {
105
- this.chunkDataRead = this.chunkDataRead.substring(this.chunkDataRead.indexOf('file='));
106
- ignoreFirstChunkOfFingerprint = false;
107
- } else this.chunkDataRead = "";
108
- }
109
-
110
101
  /**** This part removes all the wfp that includes the paths inside this.ignoreFiles ****/
111
- const rWfpPath = new RegExp(/^file=\w+,\d+,(?<path>.+)$/gm)
112
- //Search for paths in the wfp and compares with the ignorefiles set
113
- //When there is a match the matched fingerprint is deleted on the fly
114
- let result;
115
- while((result = rWfpPath.exec(this.chunkDataRead)) !== null) {
116
- if (this.ignoreFiles.has(result?.groups?.path)) {
117
- const indexDeleteFrom = result.index
118
-
119
- //TODO: Verify this condition
120
- //If there is no next file= in the string, remove until end.
121
- let indexDeleteTo = this.chunkDataRead.indexOf('file=', indexDeleteFrom+1)
122
- if (indexDeleteTo < 0) {
123
- indexDeleteTo = this.chunkDataRead.length;
124
-
125
- //After the deletion of a wfp there are no other file=, so then set ignoreFirstChunkOfFingerprint to true.
126
- //In the next iteration, the next chunk of data will be fingerprints without a file=. So, this first part will be discarded.
127
- ignoreFirstChunkOfFingerprint = true;
128
- }
102
+ if (this.ignoreFiles.size > 0) {
103
+
104
+ // Removes fingerprints that are loose because the file=...... was removed in previous iteration
105
+ if (ignoreFirstChunkOfFingerprint) { //TODO: Test this scenario
106
+ //If there is no file= delete everything then
107
+ if (this.chunkDataRead.indexOf("file=") >= 0) {
108
+ this.chunkDataRead = this.chunkDataRead.substring(this.chunkDataRead.indexOf('file='));
109
+ ignoreFirstChunkOfFingerprint = false;
110
+ } else this.chunkDataRead = "";
111
+ }
112
+
129
113
 
130
- const first = this.chunkDataRead.substring(0,indexDeleteFrom);
131
- const second = this.chunkDataRead.substring(indexDeleteTo, this.chunkDataRead.length);
132
- this.chunkDataRead = first + second;
133
- rWfpPath.lastIndex = 0; //Make sure we reset the state of the regex.
114
+ const rWfpPath = new RegExp(/^file=\w+,\d+,(?<path>.+)$/gm)
115
+ //Search for paths in the wfp and compares with the ignorefiles set
116
+ //When there is a match the matched fingerprint is deleted on the fly
117
+ let result;
118
+ while ((result = rWfpPath.exec(this.chunkDataRead)) !== null) {
119
+ if (this.ignoreFiles.has(result?.groups?.path)) {
120
+ const indexDeleteFrom = result.index
121
+
122
+ //TODO: Verify this condition
123
+ //If there is no next file= in the string, remove until end.
124
+ let indexDeleteTo = this.chunkDataRead.indexOf('file=', indexDeleteFrom + 1)
125
+ if (indexDeleteTo < 0) {
126
+ indexDeleteTo = this.chunkDataRead.length;
127
+
128
+ //After the deletion of a wfp there are no other file=, so then set ignoreFirstChunkOfFingerprint to true.
129
+ //In the next iteration, the next chunk of data will be fingerprints without a file=. So, this first part will be discarded.
130
+ ignoreFirstChunkOfFingerprint = true;
131
+ }
132
+
133
+ const first = this.chunkDataRead.substring(0, indexDeleteFrom);
134
+ const second = this.chunkDataRead.substring(indexDeleteTo, this.chunkDataRead.length);
135
+ this.chunkDataRead = first + second;
136
+ rWfpPath.lastIndex = 0; //Make sure we reset the state of the regex.
137
+ }
134
138
  }
135
139
  }
136
140
  /**** This part removes all the wfp that includes the paths inside this.ignoreFiles ****/
package/tests/scanoss.sh CHANGED
@@ -1,15 +1,10 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- # filename: commandLine.sh
4
- # author: @theBuzzyCoder
5
-
6
-
7
-
8
3
  #
9
4
  # Print help info
10
5
  #
11
6
  help() {
12
- echo "Usage: $0 [-h]
7
+ echo "Usage: $0 [-h] -w winnowing.wfp -r result.json
13
8
  [-r file to result.json]
14
9
  [-w file to winnowing]"
15
10
  exit 2
@@ -21,8 +16,8 @@ cmd_compare_wfp_result() {
21
16
  if [ ! -e "$result_json_path" ] || [ ! -e "$winnowing_path" ]; then
22
17
  echo "Error: Please, specify a valid path"
23
18
  exit 1
24
- fi
25
-
19
+ fi
20
+
26
21
  diff <(sed -n -E 's/file=\w+,[[:digit:]]+,//p' "$winnowing_path" | sort) <(jq -r '.scanner | keys | .[]' "$result_json_path" | sort)
27
22
 
28
23
  exit 1
@@ -28,8 +28,6 @@ describe('Suit test for WfpSplitter Class', () => {
28
28
  }
29
29
  }
30
30
 
31
- console.log(wfp)
32
-
33
31
  });
34
32
 
35
33
  });