Skip to content

Commit

Permalink
fix: scanoss error on Windows (#14653)
Browse files Browse the repository at this point in the history
On Windows, the scanoss library returns its results in a different
shape than on the other platforms.  We now anticipate this behavior.

fixes #14648
  • Loading branch information
sdirix authored Dec 19, 2024
1 parent b8149ba commit 61f6b19
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/scanoss/src/node/scanoss-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,20 @@ export class ScanOSSServiceImpl implements ScanOSSService {
// eslint-disable-next-line no-null/no-null
console.log('SCANOSS results', JSON.stringify(results, null, 2));

let contentScanning: ScannerComponent[] | undefined = results['/content_scanning'];
if (!contentScanning) {
// #14648: The scanoss library prefixes the property with the path of a temporary file on Windows, so we need to search for it
contentScanning = Object.entries(results).find(([key]) => key.endsWith('content_scanning'))?.[1];
}
if (!contentScanning || contentScanning.length === 0) {
return {
type: 'error',
message: 'Scan request unsuccessful'
};
}

// first result is the best result
const firstEntry = results['/content_scanning'][0];
const firstEntry = contentScanning[0];
if (firstEntry.id === 'none') {
return {
type: 'clean'
Expand Down

0 comments on commit 61f6b19

Please sign in to comment.