Skip to content

Chore/groh/change scanoss settings validation #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanoss",
"version": "0.15.4",
"version": "0.15.5",
"description": "The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
9 changes: 0 additions & 9 deletions src/cli/commands/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ export function validateSettingsFile(settings: Settings) {
if (!Array.isArray(bom.remove)) {
throw new Error("[ SETTINGS FILE ]: 'remove' must be an array");
}

bom.remove.forEach((item, index) => {
if (!item.purl) {
throw new Error(`[ SETTINGS FILE ]: Missing required 'purl' in remove item.\n ${JSON.stringify(item,null,2)}`);
}
});
}

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

bom.replace.forEach((item, index) => {
if (!item.purl) {
throw new Error(`[ SETTINGS FILE ]: Missing required 'purl' in replace item.\n ${JSON.stringify(item,null,2)} `);
}
if (!item.replace_with) {
throw new Error(`[ SETTINGS FILE ]: Missing required 'replace_with' in replace item.\n ${JSON.stringify(item,null,2)}`);
}
Expand Down
5 changes: 2 additions & 3 deletions src/sdk/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ export class Scanner extends EventEmitter {
this.init();
this.createOutputFiles();
this.scannerInput = scannerInput;
this.settings = scannerInput[0].settings ? { ...scannerInput[0].settings } : null;
this.settings = scannerInput[0]?.settings ? { ...scannerInput[0].settings } : null;


if (scannerInput[0].settings) {
if (scannerInput[0]?.settings) {
validateSettingsFile(scannerInput[0].settings);
const include = scannerInput[0].settings.bom.include.map((i)=> i.purl);
const replace = scannerInput[0].settings.bom.replace.map((r)=> r.replace_with);
Expand Down Expand Up @@ -311,7 +311,6 @@ export class Scanner extends EventEmitter {
this.dispatcher.on(
ScannerEvents.DISPATCHER_NEW_DATA,
async (response: DispatcherResponse) => {
console.log("ScannerEvents.DISPATCHER_NEW_DATA")
this.processedFiles += response.getNumberOfFilesScanned();
this.reportLog(
`[ SCANNER ]: Received results of ${response.getNumberOfFilesScanned()} files`
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/scanner/ScannnerResultPostProcessor/rules/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export abstract class Rule {
return this.byPurl(results,bomItem);
}

if (bomItem.path) {
return this.byPath(resultPath,bomItem);
}

return false;
}

Expand Down
Loading