scanoss 0.7.8 → 0.7.9

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 +47 -31
  2. package/.nyc_output/3da9f448-90e4-4399-887b-e4fd1b8d7052.json +1 -0
  3. package/.nyc_output/processinfo/3da9f448-90e4-4399-887b-e4fd1b8d7052.json +1 -0
  4. package/.nyc_output/processinfo/index.json +1 -0
  5. package/build/main/index.d.ts +2 -0
  6. package/build/main/index.js +3 -1
  7. package/build/main/sdk/FileCount/FileCount.d.ts +6 -0
  8. package/build/main/sdk/FileCount/FileCount.js +88 -0
  9. package/build/main/sdk/FileCount/FileCountFilter.d.ts +2 -0
  10. package/build/main/sdk/FileCount/FileCountFilter.js +10 -0
  11. package/build/main/sdk/FileCount/Interfaces.d.ts +19 -0
  12. package/build/main/sdk/FileCount/Interfaces.js +8 -0
  13. package/build/main/sdk/Filtering/DefaultFilterForDependencies.d.ts +2 -0
  14. package/build/main/sdk/Filtering/DefaultFilterForDependencies.js +144 -0
  15. package/build/main/sdk/Filtering/DefaultFilterForScanning.d.ts +2 -0
  16. package/build/main/sdk/Filtering/DefaultFilterForScanning.js +193 -0
  17. package/build/main/sdk/Filtering/Filtering.d.ts +80 -0
  18. package/build/main/sdk/Filtering/Filtering.js +259 -0
  19. package/build/main/sdk/tree/Filters/DependencyFilter.js +4 -4
  20. package/build/main/sdk/tree/Filters/ScanFilter.js +4 -4
  21. package/build/main/tsconfig.tsbuildinfo +81 -38
  22. package/build/module/index.d.ts +2 -0
  23. package/build/module/index.js +3 -1
  24. package/build/module/sdk/FileCount/FileCount.d.ts +6 -0
  25. package/build/module/sdk/FileCount/FileCount.js +63 -0
  26. package/build/module/sdk/FileCount/FileCountFilter.d.ts +2 -0
  27. package/build/module/sdk/FileCount/FileCountFilter.js +8 -0
  28. package/build/module/sdk/FileCount/Interfaces.d.ts +19 -0
  29. package/build/module/sdk/FileCount/Interfaces.js +6 -0
  30. package/build/module/sdk/Filtering/DefaultFilterForDependencies.d.ts +2 -0
  31. package/build/module/sdk/Filtering/DefaultFilterForDependencies.js +142 -0
  32. package/build/module/sdk/Filtering/DefaultFilterForScanning.d.ts +2 -0
  33. package/build/module/sdk/Filtering/DefaultFilterForScanning.js +191 -0
  34. package/build/module/sdk/Filtering/Filtering.d.ts +80 -0
  35. package/build/module/sdk/Filtering/Filtering.js +229 -0
  36. package/build/module/sdk/tree/Filters/DependencyFilter.js +4 -4
  37. package/build/module/sdk/tree/Filters/ScanFilter.js +4 -4
  38. package/build/module/tsconfig.module.tsbuildinfo +81 -38
  39. package/package-lock.json +2 -3
  40. package/package.json +3 -3
  41. package/src/index.ts +5 -0
  42. package/src/sdk/FileCount/FileCount.ts +81 -0
  43. package/src/sdk/FileCount/FileCountFilter.ts +14 -0
  44. package/src/sdk/FileCount/Interfaces.ts +23 -0
  45. package/src/sdk/Filtering/DefaultFilterForDependencies.ts +148 -0
  46. package/src/sdk/Filtering/DefaultFilterForScanning.ts +206 -0
  47. package/src/sdk/Filtering/Filtering.ts +273 -0
  48. package/src/sdk/tree/Filters/DependencyFilter.ts +4 -4
  49. package/src/sdk/tree/Filters/ScanFilter.ts +4 -4
  50. package/src/sdk/tree/Node.ts +1 -1
  51. package/src/sdk/tree/Tree.ts +1 -1
  52. package/tests/sdk/FileCount/FileCount.spec.ts +35 -0
  53. package/tests/sdk/FileCount/samples/16557/.y.ts +27 -0
  54. package/tests/sdk/FileCount/samples/16557/.z.ts +129 -0
  55. package/tests/sdk/FileCount/samples/16557/files/a.ts +195 -0
  56. package/tests/sdk/FileCount/samples/16557/files/b.ts +184 -0
  57. package/tests/sdk/FileCount/samples/16557/files/c.ts +47 -0
  58. package/tests/sdk/FileCount/samples/22036/files/a.ts +195 -0
  59. package/tests/sdk/FileCount/samples/22036/files/b.ts +184 -0
  60. package/tests/sdk/FileCount/samples/22036/files/c.ts +47 -0
  61. package/tests/sdk/FileCount/samples/22036/files/d.ts +48 -0
  62. package/tests/sdk/FileCount/samples/22036/y.ts +27 -0
  63. package/tests/sdk/FileCount/samples/22036/z.ts +129 -0
  64. package/yarn.lock +4938 -4938
  65. package/src/sdk/filters/DefaultFilterForDependencies.ts +0 -149
  66. package/src/sdk/filters/DefaultFilterForScanning.ts +0 -207
  67. package/src/sdk/filters/filtering.ts +0 -235
@@ -0,0 +1,184 @@
1
+ // import {
2
+ // DataProvider,
3
+ // IDataLayers,
4
+ // LicenseComponent,
5
+ // LicenseDataLayer
6
+ // } from '../DataLayerTypes';
7
+ // import {
8
+ // ScannerComponent,
9
+ // ScannerResults
10
+ // } from '../../scanner/ScannerTypes';
11
+ // import { IDependencyResponse } from '../../Dependencies/DependencyTypes';
12
+ //
13
+ // export class LicenseDataProvider implements DataProvider {
14
+ //
15
+ // private scanResults: ScannerResults
16
+ //
17
+ // private componentList: ScannerComponent[];
18
+ //
19
+ // private dependencies: IDependencyResponse;
20
+ //
21
+ // private licenseStorage: Record<string, LicenseDataLayer>;
22
+ //
23
+ // private licenseLayer: Array<LicenseDataLayer>;
24
+ //
25
+ // constructor(scanResults: ScannerResults, dependencies?: IDependencyResponse ) {
26
+ // this.scanResults = scanResults;
27
+ // this.dependencies = dependencies;
28
+ //
29
+ // //Maps a license name to its own data
30
+ // this.licenseStorage = {};
31
+ // this.licenseLayer = [];
32
+ // }
33
+ //
34
+ // public getLayerName(): string {
35
+ // return this.constructor.name;
36
+ // }
37
+ //
38
+ // public getData(): IDataLayers {
39
+ //
40
+ // this.componentList = Object.values(this.scanResults).flat();
41
+ // this.componentList = this.componentList.filter(component => component.id!=='none')
42
+ //
43
+ // if (this.componentList.length >0)
44
+ // this.updateLicenseStorageFromComponentList();
45
+ //
46
+ // if (this.dependencies && this.dependencies.filesList.length > 0)
47
+ // this.updateLicenseStorageFromDependencies();
48
+ //
49
+ //
50
+ // this.licenseLayer = Object.values(this.licenseStorage);
51
+ // if (this.licenseLayer.length > 0)
52
+ // this.updateIncompatibilities();
53
+ //
54
+ // this.licenseLayer.sort((itemA, itemB) => {
55
+ // if (itemA.value > itemB.value) return -1
56
+ // else if (itemA.value < itemB.value) return 1
57
+ // return 0;
58
+ // });
59
+ //
60
+ // return {licenses: this.licenseLayer} as IDataLayers
61
+ // }
62
+ //
63
+ // //Gets all license from the result of scan and stores in this.licenseStorage map
64
+ // private updateLicenseStorageFromComponentList() {
65
+ // this.componentList.forEach(component => {
66
+ // component.licenses.forEach((license) => {
67
+ //
68
+ // const newLicenseComponent: LicenseComponent = <LicenseComponent>{};
69
+ // newLicenseComponent.purl = component.purl[0];
70
+ // newLicenseComponent.vendor = component.vendor;
71
+ // newLicenseComponent.versions = [component.version];
72
+ // newLicenseComponent.name = component.component
73
+ // newLicenseComponent.url = component.url;
74
+ //
75
+ // const licenseExist = !!this.licenseStorage[license.name];
76
+ // if(!licenseExist){
77
+ // const newLicense: LicenseDataLayer = <LicenseDataLayer>{};
78
+ // newLicense.value = 1;
79
+ // newLicense.label = license.name;
80
+ // newLicense.copyleft = license.copyleft === 'yes' ? true : false;
81
+ // newLicense.hasIncompatibles = [];
82
+ // newLicense.incompatibleWith = license.incompatible_with!== undefined ? license.incompatible_with.split(',').map(il=> il.trim()) : [];
83
+ // newLicense.components = [newLicenseComponent];
84
+ // this.licenseStorage[license.name] = newLicense;
85
+ // } else {
86
+ // this.licenseStorage[license.name] = this.insertComponentIntoLicense(this.licenseStorage[license.name], newLicenseComponent);
87
+ // }
88
+ // });
89
+ // });
90
+ // }
91
+ //
92
+ // //Gets all licenses from results of dependency analysis
93
+ // private updateLicenseStorageFromDependencies() {
94
+ // this.dependencies.filesList.forEach(file => {
95
+ // file.dependenciesList.forEach(dependency => {
96
+ // dependency.licensesList.forEach(license => {
97
+ //
98
+ //
99
+ // const newLicenseComponent = <LicenseComponent>{};
100
+ // newLicenseComponent.purl = dependency.purl;
101
+ // newLicenseComponent.versions = [dependency.version];
102
+ // newLicenseComponent.name = dependency.component;
103
+ // newLicenseComponent.vendor = null;
104
+ // newLicenseComponent.url = null;
105
+ //
106
+ // if(license.spdxId !== '') {
107
+ // license.spdxId.split(/;|\//g).forEach(license_name => {
108
+ //
109
+ // const licenseExist = !!this.licenseStorage[license_name];
110
+ // if (!licenseExist) {
111
+ // const newLicense: LicenseDataLayer = <LicenseDataLayer>{};
112
+ // newLicense.value = 1;
113
+ // newLicense.label = license_name;
114
+ // newLicense.copyleft = false;
115
+ // newLicense.hasIncompatibles = [];
116
+ // newLicense.incompatibleWith = [];
117
+ // newLicense.components = [newLicenseComponent];
118
+ // this.licenseStorage[license_name] = newLicense;
119
+ // } else {
120
+ // this.licenseStorage[license_name] = this.insertComponentIntoLicense(this.licenseStorage[license_name], newLicenseComponent);
121
+ // }
122
+ // });
123
+ // } else { // Unknown license
124
+ // const licenseExist = !!this.licenseStorage['unknown'];
125
+ // if (!licenseExist) {
126
+ // const newLicense: LicenseDataLayer = <LicenseDataLayer>{};
127
+ // newLicense.value = 1;
128
+ // newLicense.label = 'unknown';
129
+ // newLicense.copyleft = false;
130
+ // newLicense.hasIncompatibles = [];
131
+ // newLicense.incompatibleWith = [];
132
+ // newLicense.components = [newLicenseComponent];
133
+ // this.licenseStorage['unknown'] = newLicense;
134
+ // } else{
135
+ // this.licenseStorage['unknown'] = this.insertComponentIntoLicense(this.licenseStorage['unknown'], newLicenseComponent);
136
+ // }
137
+ // }
138
+ // });
139
+ // });
140
+ // });
141
+ // }
142
+ //
143
+ // private updateIncompatibilities() {
144
+ // for (let l = 0; l < this.licenseLayer.length; l += 1) {
145
+ // const license = this.licenseLayer[l];
146
+ // if (license.incompatibleWith !== undefined)
147
+ // for (let i = 0; i < license.incompatibleWith.length; i += 1) {
148
+ // if (this.licenseLayer.some((lic) => lic.label === license.incompatibleWith[i]))
149
+ // license.hasIncompatibles.push(license.incompatibleWith[i]);
150
+ // }
151
+ // }
152
+ // }
153
+ //
154
+ //
155
+ // private insertComponentIntoLicense(license: LicenseDataLayer, newComponent: LicenseComponent): LicenseDataLayer {
156
+ // const componentIndex = license.components.findIndex((c)=> c.purl === newComponent.purl);
157
+ // if (componentIndex >= 0) { //if newComponent exist in license
158
+ // const versionExist = !!license.components[componentIndex].versions.find((version)=>version === newComponent.versions[0]);
159
+ // if (!versionExist) {
160
+ // license.components[componentIndex].versions.push(newComponent.versions[0]);
161
+ // license.value++;
162
+ // }
163
+ // } else {
164
+ // license.components.push(newComponent);
165
+ // license.value++;
166
+ // }
167
+ // return license;
168
+ // }
169
+ //
170
+ // private unknownLicensesToEnd(){
171
+ // // let unknownLicenses = null;
172
+ // // if(this.licenseMapper['unknown']){
173
+ // // unknownLicenses = this.licenseMapper['unknown'];
174
+ // // delete this.licenseMapper['unknown'];
175
+ // // }
176
+ // //
177
+ // // this.licenses = Object.values((this.licenseMapper));
178
+ // // if(unknownLicenses){
179
+ // // this.licenses.push(unknownLicenses);
180
+ // // }
181
+ // }
182
+ //
183
+ //
184
+ // }
@@ -0,0 +1,47 @@
1
+ // import { DataProvider, IDataLayers, SummaryDataLayer } from '../DataLayerTypes';
2
+ // import {
3
+ // ScannerComponent,
4
+ // ScannerComponentId,
5
+ // ScannerResults
6
+ // } from '../../scanner/ScannerTypes';
7
+ //
8
+ // export class SummaryDataProvider implements DataProvider {
9
+ //
10
+ // private scannerResults: ScannerResults;
11
+ //
12
+ // private summary: SummaryDataLayer;
13
+ //
14
+ // private projectName: string;
15
+ //
16
+ // private projectCreateAt: Date;
17
+ //
18
+ // constructor(projectName: string, projectCreatedAt: Date, scannerResults: ScannerResults) {
19
+ // this.scannerResults = scannerResults;
20
+ // this.projectName = projectName;
21
+ // this.projectCreateAt = projectCreatedAt
22
+ // this.summary = <SummaryDataLayer>{};
23
+ // }
24
+ //
25
+ // public getLayerName(): string {
26
+ // return this.constructor.name;
27
+ // }
28
+ //
29
+ // public getData(): IDataLayers {
30
+ // this.summary.projectName = this.projectName;
31
+ // this.summary.timestamp = this.projectCreateAt;
32
+ // this.summary.totalFiles = 0;
33
+ // this.summary.noMatchFiles = 0;
34
+ // this.summary.matchedFiles = 0;
35
+ //
36
+ // for (const [file, components] of Object.entries(this.scannerResults)) {
37
+ // components.forEach(component => {
38
+ // if (component.id==ScannerComponentId.NONE) this.summary.noMatchFiles++;
39
+ // else this.summary.matchedFiles++;
40
+ // this.summary.totalFiles++;
41
+ // });
42
+ // }
43
+ //
44
+ // return <IDataLayers>{summary: this.summary};
45
+ // }
46
+ //
47
+ // }
@@ -0,0 +1,48 @@
1
+ // import {
2
+ // DataProvider,
3
+ // IDataLayers,
4
+ // DependencyDataLayer,
5
+ // License, Dependency
6
+ // } from '../DataLayerTypes';
7
+ // import { IDependencyResponse } from '../../Dependencies/DependencyTypes';
8
+ //
9
+ // export class DependencyDataProvider implements DataProvider {
10
+ //
11
+ // private dependencies: IDependencyResponse;
12
+ //
13
+ // constructor(dependencies: IDependencyResponse) {
14
+ // this.dependencies = dependencies;
15
+ // }
16
+ //
17
+ // public getLayerName(): string {
18
+ // return this.constructor.name;
19
+ // }
20
+ //
21
+ // public getData(): IDataLayers {
22
+ // const dependencyLayer = <IDataLayers>{dependencies: null};
23
+ // if(!this.dependencies) return dependencyLayer;
24
+ // const parsedDepLayer = this.parseDependencyData(this.dependencies);
25
+ // dependencyLayer.dependencies = parsedDepLayer;
26
+ // if (!dependencyLayer.dependencies.length) dependencyLayer.dependencies=null;
27
+ //
28
+ // return dependencyLayer;
29
+ // }
30
+ //
31
+ // public parseDependencyData(dependencies: IDependencyResponse): DependencyDataLayer[]{
32
+ // const dependencyLayer: Array<DependencyDataLayer> = [];
33
+ //
34
+ // dependencies.filesList.forEach(file => {
35
+ // const newDependencies: Array<Dependency> = [];
36
+ // file.dependenciesList.forEach(dependency => {
37
+ // const newLicenses: Array<License> = [];
38
+ // dependency.licensesList.forEach((license) => {
39
+ // newLicenses.push({name: license.name, spdxid: license.spdxId});
40
+ // });
41
+ // newDependencies.push({purl: dependency.purl, licenses: newLicenses, version: dependency.version, component: dependency.component});
42
+ // });
43
+ // dependencyLayer.push({file: file.file, dependencies: newDependencies});
44
+ // });
45
+ //
46
+ // return dependencyLayer;
47
+ // }
48
+ // }
@@ -0,0 +1,27 @@
1
+ // import { DataProvider, IDataLayers } from './DataLayerTypes';
2
+ //
3
+ // export class DataProviderManager {
4
+ // private dataLayersProviders: Array<DataProvider>;
5
+ //
6
+ // constructor() {
7
+ // this.dataLayersProviders = [];
8
+ // }
9
+ //
10
+ // public addDataProvider(l: DataProvider) {
11
+ // this.dataLayersProviders.push(l)
12
+ // }
13
+ //
14
+ // public generateData(): IDataLayers {
15
+ //
16
+ // let dataLayer: IDataLayers = {
17
+ // component: null,
18
+ // dependencies: null,
19
+ // vulnerabilities: null,
20
+ // summary: null,
21
+ // licenses: null
22
+ // };
23
+ //
24
+ // for (const layer of this.dataLayersProviders) Object.assign(dataLayer, layer.getData());
25
+ // return dataLayer;
26
+ // }
27
+ // }
@@ -0,0 +1,129 @@
1
+ // /************* Component interface definition *************/
2
+ // export interface ComponentDataLayer {
3
+ // key: string; // purl[0]
4
+ // purls: string[];
5
+ // name: string;
6
+ // vendor: string;
7
+ // url: string;
8
+ // health: Health;
9
+ // versions: Version[];
10
+ // }
11
+ //
12
+ // export interface Version {
13
+ // version: string;
14
+ // licenses: string[]
15
+ // copyrights: Copyright[]
16
+ // cryptography: Cryptography[];
17
+ // quality: Quality;
18
+ // }
19
+ //
20
+ // export interface Copyright {
21
+ // name: string;
22
+ // source: string;
23
+ // };
24
+ //
25
+ // export interface Cryptography {
26
+ // algorithm: string;
27
+ // strength: string;
28
+ // };
29
+ //
30
+ // export interface Quality {
31
+ // scoreAvg: number;
32
+ // count: number;
33
+ // sum: number; //TODO remove
34
+ // };
35
+ //
36
+ // export interface Health {
37
+ // creation_date: string;
38
+ // issues: number;
39
+ // last_push: string;
40
+ // last_update: string;
41
+ // watchers: number;
42
+ // country: string;
43
+ // stars: number;
44
+ // forks: number;
45
+ // }
46
+ // /************* Component interface definition *************/
47
+ //
48
+ //
49
+ // /************* Dependency interface definition *************/
50
+ // export interface DependencyDataLayer {
51
+ // file: string;
52
+ // dependencies: Dependency[];
53
+ // }
54
+ //
55
+ // export interface License {
56
+ // name: string;
57
+ // spdxid: string;
58
+ // }
59
+ //
60
+ // export interface Dependency {
61
+ // purl: string;
62
+ // component: string;
63
+ // version: string;
64
+ // licenses: License[]
65
+ // }
66
+ // /************* Dependency interface definition *************/
67
+ //
68
+ // /************* Vulnerability interface definition *************/
69
+ // export interface Vulnerability {
70
+ // id: string;
71
+ // cve: string;
72
+ // url: string;
73
+ // summary: string;
74
+ // severity: string;
75
+ // published: string;
76
+ // modified: string;
77
+ // source: string;
78
+ // }
79
+ //
80
+ // export interface VulnerabilityDataLayer {
81
+ // purl: string;
82
+ // vulnerability: Vulnerability[];
83
+ // }
84
+ // /************* Vulnerability interface definition *************/
85
+ //
86
+ //
87
+ // /************* License interface definition *************/
88
+ // export interface LicenseDataLayer {
89
+ // label: string;
90
+ // value: number; //Number of licenses found
91
+ // components: Array<LicenseComponent>;
92
+ // incompatibleWith: Array<string>;
93
+ // hasIncompatibles: Array<string>;
94
+ // copyleft:boolean;
95
+ // }
96
+ //
97
+ //
98
+ // export interface LicenseComponent {
99
+ // purl: string;
100
+ // name: string;
101
+ // versions: Array<string>;
102
+ // url:string;
103
+ // vendor:string;
104
+ // }
105
+ // /************* License interface definition *************/
106
+ //
107
+ // export interface SummaryDataLayer {
108
+ // projectName: string;
109
+ // timestamp: Date;
110
+ // matchedFiles: number;
111
+ // noMatchFiles: number;
112
+ // totalFiles: number;
113
+ // }
114
+ //
115
+ // // Each layer is created to group by differents criteria.
116
+ // export interface IDataLayers {
117
+ // licenses: LicenseDataLayer[];
118
+ // component: ComponentDataLayer[];
119
+ // dependencies: DependencyDataLayer[];
120
+ // vulnerabilities: VulnerabilityDataLayer[];
121
+ // summary: SummaryDataLayer;
122
+ // }
123
+ //
124
+ //
125
+ // export interface DataProvider {
126
+ // getData(): IDataLayers;
127
+ // getLayerName(): string;
128
+ // }
129
+ //