From 61f6b198d301a32637778a58c5f990f29bd4953d Mon Sep 17 00:00:00 2001 From: Stefan Dirix Date: Thu, 19 Dec 2024 10:02:37 +0100 Subject: [PATCH] fix: scanoss error on Windows (#14653) On Windows, the scanoss library returns its results in a different shape than on the other platforms. We now anticipate this behavior. fixes #14648 --- packages/scanoss/src/node/scanoss-service-impl.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/scanoss/src/node/scanoss-service-impl.ts b/packages/scanoss/src/node/scanoss-service-impl.ts index 1bc1c9c3ee163..5acce224195ed 100644 --- a/packages/scanoss/src/node/scanoss-service-impl.ts +++ b/packages/scanoss/src/node/scanoss-service-impl.ts @@ -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'