scanoss 0.4.11-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 (63) hide show
  1. package/.idea/workspace.xml +6 -2
  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/WfpProvider/WfpCalculator/WfpCalculator.d.ts +1 -1
  7. package/build/main/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +33 -31
  8. package/build/main/tsconfig.tsbuildinfo +20 -20
  9. package/build/module/cli/bin/cli-bin.js +5 -5
  10. package/build/module/cli/commands/wfp.d.ts +1 -0
  11. package/build/module/cli/commands/wfp.js +48 -0
  12. package/build/module/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.d.ts +1 -1
  13. package/build/module/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +33 -31
  14. package/build/module/tsconfig.module.tsbuildinfo +20 -20
  15. package/package-lock.json +67 -493
  16. package/package.json +1 -1
  17. package/src/cli/bin/cli-bin.ts +4 -4
  18. package/src/cli/commands/{fingerprint.ts → wfp.ts} +1 -1
  19. package/src/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.ts +36 -32
  20. package/tests/sdk/Scanner/WfpProvider/WfpSplitter/WfpSplitter.spec.ts +0 -2
  21. package/yarn.lock +4886 -4737
  22. package/build/main/cli/commands/fingerprint.d.ts +0 -1
  23. package/build/main/cli/commands/fingerprint.js +0 -54
  24. package/build/main/sdk/Decompress/DecompressionManager.d.ts +0 -12
  25. package/build/main/sdk/Decompress/DecompressionManager.js +0 -65
  26. package/build/main/sdk/Decompress/Decompressor/DecompressTgz.d.ts +0 -5
  27. package/build/main/sdk/Decompress/Decompressor/DecompressTgz.js +0 -22
  28. package/build/main/sdk/Decompress/Decompressor/DecompressZips.d.ts +0 -5
  29. package/build/main/sdk/Decompress/Decompressor/DecompressZips.js +0 -24
  30. package/build/main/sdk/Decompress/Decompressor/Decompressor.d.ts +0 -10
  31. package/build/main/sdk/Decompress/Decompressor/Decompressor.js +0 -18
  32. package/build/main/sdk/modules/reports/Report.d.ts +0 -24
  33. package/build/main/sdk/modules/reports/Report.js +0 -75
  34. package/build/main/sdk/modules/reports/ReportAdapter.d.ts +0 -12
  35. package/build/main/sdk/modules/reports/ReportAdapter.js +0 -117
  36. package/build/main/sdk/modules/reports/htmlReport/HTMLReport.d.ts +0 -14
  37. package/build/main/sdk/modules/reports/htmlReport/HTMLReport.js +0 -39
  38. package/build/main/sdk/modules/reports/types.d.ts +0 -44
  39. package/build/main/sdk/modules/reports/types.js +0 -8
  40. package/build/main/sdk/tree/Filters/DecompressionFilter.d.ts +0 -7
  41. package/build/main/sdk/tree/Filters/DecompressionFilter.js +0 -21
  42. package/build/module/cli/commands/fingerprint.d.ts +0 -1
  43. package/build/module/cli/commands/fingerprint.js +0 -48
  44. package/build/module/sdk/Decompress/DecompressionManager.d.ts +0 -12
  45. package/build/module/sdk/Decompress/DecompressionManager.js +0 -59
  46. package/build/module/sdk/Decompress/Decompressor/DecompressTgz.d.ts +0 -5
  47. package/build/module/sdk/Decompress/Decompressor/DecompressTgz.js +0 -16
  48. package/build/module/sdk/Decompress/Decompressor/DecompressZips.d.ts +0 -5
  49. package/build/module/sdk/Decompress/Decompressor/DecompressZips.js +0 -18
  50. package/build/module/sdk/Decompress/Decompressor/Decompressor.d.ts +0 -10
  51. package/build/module/sdk/Decompress/Decompressor/Decompressor.js +0 -15
  52. package/build/module/sdk/modules/reports/Report.d.ts +0 -24
  53. package/build/module/sdk/modules/reports/Report.js +0 -80
  54. package/build/module/sdk/modules/reports/ReportAdapter.d.ts +0 -12
  55. package/build/module/sdk/modules/reports/ReportAdapter.js +0 -115
  56. package/build/module/sdk/modules/reports/htmlReport/HTMLReport.d.ts +0 -14
  57. package/build/module/sdk/modules/reports/htmlReport/HTMLReport.js +0 -41
  58. package/build/module/sdk/modules/reports/types.d.ts +0 -44
  59. package/build/module/sdk/modules/reports/types.js +0 -6
  60. package/build/module/sdk/tree/Filters/DecompressionFilter.d.ts +0 -7
  61. package/build/module/sdk/tree/Filters/DecompressionFilter.js +0 -18
  62. package/build/tsconfig.module.tsbuildinfo +0 -1
  63. package/build/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scanoss",
3
- "version": "0.4.11-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.11-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.
@@ -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 ****/
@@ -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
  });