Skip to content

Commit a2c9f06

Browse files
authored
Refactor on SCANOSS settings validation
* chore:SP-2002 Refactor on scanoss settings validation file * chore:SP-2004 Adds option to remove and replace by path * Upgrades version to v0.15.5
1 parent f9747d5 commit a2c9f06

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scanoss",
3-
"version": "0.15.4",
3+
"version": "0.15.5",
44
"description": "The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.",
55
"main": "build/main/index.js",
66
"typings": "build/main/index.d.ts",

Diff for: src/cli/commands/helpers.ts

-9
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ export function validateSettingsFile(settings: Settings) {
6060
if (!Array.isArray(bom.remove)) {
6161
throw new Error("[ SETTINGS FILE ]: 'remove' must be an array");
6262
}
63-
64-
bom.remove.forEach((item, index) => {
65-
if (!item.purl) {
66-
throw new Error(`[ SETTINGS FILE ]: Missing required 'purl' in remove item.\n ${JSON.stringify(item,null,2)}`);
67-
}
68-
});
6963
}
7064

7165
if (bom.replace) {
@@ -74,9 +68,6 @@ export function validateSettingsFile(settings: Settings) {
7468
}
7569

7670
bom.replace.forEach((item, index) => {
77-
if (!item.purl) {
78-
throw new Error(`[ SETTINGS FILE ]: Missing required 'purl' in replace item.\n ${JSON.stringify(item,null,2)} `);
79-
}
8071
if (!item.replace_with) {
8172
throw new Error(`[ SETTINGS FILE ]: Missing required 'replace_with' in replace item.\n ${JSON.stringify(item,null,2)}`);
8273
}

Diff for: src/sdk/scanner/Scanner.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ export class Scanner extends EventEmitter {
158158
this.init();
159159
this.createOutputFiles();
160160
this.scannerInput = scannerInput;
161-
this.settings = scannerInput[0].settings ? { ...scannerInput[0].settings } : null;
161+
this.settings = scannerInput[0]?.settings ? { ...scannerInput[0].settings } : null;
162162

163163

164-
if (scannerInput[0].settings) {
164+
if (scannerInput[0]?.settings) {
165165
validateSettingsFile(scannerInput[0].settings);
166166
const include = scannerInput[0].settings.bom.include.map((i)=> i.purl);
167167
const replace = scannerInput[0].settings.bom.replace.map((r)=> r.replace_with);
@@ -311,7 +311,6 @@ export class Scanner extends EventEmitter {
311311
this.dispatcher.on(
312312
ScannerEvents.DISPATCHER_NEW_DATA,
313313
async (response: DispatcherResponse) => {
314-
console.log("ScannerEvents.DISPATCHER_NEW_DATA")
315314
this.processedFiles += response.getNumberOfFilesScanned();
316315
this.reportLog(
317316
`[ SCANNER ]: Received results of ${response.getNumberOfFilesScanned()} files`

Diff for: src/sdk/scanner/ScannnerResultPostProcessor/rules/rule.ts

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export abstract class Rule {
3535
return this.byPurl(results,bomItem);
3636
}
3737

38+
if (bomItem.path) {
39+
return this.byPath(resultPath,bomItem);
40+
}
41+
3842
return false;
3943
}
4044

0 commit comments

Comments
 (0)