diff --git a/.github/linters/.eslintrc.yml b/.github/linters/.eslintrc.yml index 9d6fc76..956419c 100644 --- a/.github/linters/.eslintrc.yml +++ b/.github/linters/.eslintrc.yml @@ -67,7 +67,7 @@ rules: '@typescript-eslint/no-require-imports': 'error', '@typescript-eslint/no-unnecessary-qualifier': 'error', '@typescript-eslint/no-unnecessary-type-assertion': 'error', - '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/no-useless-constructor': 'error', '@typescript-eslint/no-var-requires': 'error', '@typescript-eslint/prefer-for-of': 'warn', diff --git a/__tests__/report.service.test.ts b/__tests__/report.service.test.ts new file mode 100644 index 0000000..2ab008b --- /dev/null +++ b/__tests__/report.service.test.ts @@ -0,0 +1,51 @@ +import { ScannerResults } from '../src/services/result.interfaces'; +import { getLicenses, Licenses } from '../src/services/result.service'; +import { resultsMock } from './results.mock'; + +const licenseTableTest = [ + { + ...resultsMock[0], + licenses: [{ spdxid: 'MIT', url: null, copyleft: null }] + }, + { + ...resultsMock[1], + licenses: [ + { spdxid: 'MIT', url: null, copyleft: null }, + { spdxid: 'Apache-2.0', url: null, copyleft: null }, + { spdxid: '0BSD', url: null, copyleft: null } + ] + }, + { + ...resultsMock[2], + licenses: [ + { spdxid: 'GPL-2.0-only', url: 'https://spdx.org/licenses/GPL-2.0-only.html', copyleft: true }, + { spdxid: 'GPL-2.0-or-later', url: 'https://spdx.org/licenses/GPL-2.0-or-later.html', copyleft: true }, + { spdxid: 'JSON', url: 'https://spdx.org/licenses/JSON.html', copyleft: null }, + { spdxid: 'LicenseRef-scancode-unknown-license-reference', url: null, copyleft: null } + ] + }, + { + ...resultsMock[3], + licenses: [ + { spdxid: 'MIT', url: null, copyleft: null }, + { spdxid: 'GPL-2.0-only', url: 'https://spdx.org/licenses/GPL-2.0-only.html', copyleft: true }, + { spdxid: 'JSON', url: 'https://spdx.org/licenses/JSON.html', copyleft: null }, + { spdxid: 'LicenseRef-scancode-unknown-license-reference', url: null, copyleft: null }, + { spdxid: 'GPL-2.0-or-later', url: 'https://spdx.org/licenses/GPL-2.0-or-later.html', copyleft: true }, + { spdxid: 'Apache-2.0', url: null, copyleft: null }, + { spdxid: '0BSD', url: null, copyleft: null } + ] + } +]; + +describe('Test Results service', () => { + for (const t of licenseTableTest) { + it(`${t.name}`, () => { + const scannerResults = JSON.parse(t.content) as ScannerResults; + const licenses = getLicenses(scannerResults); + + const sortFn = (a: Licenses, b: Licenses): number => a.spdxid.localeCompare(b.spdxid); + expect(licenses.sort(sortFn)).toEqual(t.licenses.sort(sortFn)); + }); + } +}); diff --git a/src/services/result.test.ts b/__tests__/result.service.test.ts similarity index 99% rename from src/services/result.test.ts rename to __tests__/result.service.test.ts index 40efac8..25f9096 100644 --- a/src/services/result.test.ts +++ b/__tests__/result.service.test.ts @@ -1,5 +1,5 @@ -import { ScannerResults } from './result.interfaces'; -import { getLicenses, Licenses } from './result.service'; +import { ScannerResults } from '../src/services/result.interfaces'; +import { getLicenses, Licenses } from '../src/services/result.service'; const licenseTableTest: { name: string; description: string; content: string; licenses: Licenses[] }[] = [ { diff --git a/__tests__/results.mock.ts b/__tests__/results.mock.ts new file mode 100644 index 0000000..b1521da --- /dev/null +++ b/__tests__/results.mock.ts @@ -0,0 +1,26 @@ +export const resultsMock: { name: string; description: string; content: string }[] = [ + { + name: '1) license test', + description: 'Only one dependency file', + content: + '{"package.json":[{"dependencies":[{"component":"p-timeout","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:npm/p-timeout","url":"https://www.npmjs.com/package/p-timeout","version":"6.1.2"},{"component":"@sindresorhus/tsconfig","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:npm/%40sindresorhus/tsconfig","url":"https://www.npmjs.com/package/%40sindresorhus/tsconfig","version":"5.0.0"}],"id":"dependency","status":"pending"}]}' + }, + { + name: '2) license test', + description: 'Only dependencies files', + content: + '{"package.json":[{"dependencies":[{"component":"@types/node","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:npm/%40types/node","url":"https://www.npmjs.com/package/%40types/node","version":"17.0.45"},{"component":"packageurl-js","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:npm/packageurl-js","url":"https://www.npmjs.com/package/packageurl-js","version":"0.0.5"},{"component":"typescript","licenses":[{"is_spdx_approved":true,"name":"Apache-2.0","spdx_id":"Apache-2.0"}],"purl":"pkg:npm/typescript","url":"https://www.npmjs.com/package/typescript","version":"4.9.5"}],"id":"dependency","status":"pending"}],"requirements.txt":[{"dependencies":[{"component":"requests","licenses":[{"is_spdx_approved":true,"name":"Apache2.0","spdx_id":"Apache-2.0"}],"purl":"pkg:pypi/requests","url":"https://pypi.org/project/requests","version":"2.31.0"},{"licenses":[{}],"purl":"pkg:pypi/crc32c"},{"component":"binaryornot","licenses":[{"is_spdx_approved":true,"name":"BSD","spdx_id":"0BSD"}],"purl":"pkg:pypi/binaryornot","url":"https://pypi.org/project/binaryornot","version":"0.4.4"},{"component":"pytest","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:pypi/pytest","url":"https://pypi.org/project/pytest","version":"8.0.0rc2"},{"component":"pytest-cov","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:pypi/pytest-cov","url":"https://pypi.org/project/pytest-cov","version":"4.1.0"},{"component":"beautifulsoup4","licenses":[{"is_spdx_approved":true,"name":"MITLicense","spdx_id":"MIT"}],"purl":"pkg:pypi/beautifulsoup4","url":"https://pypi.org/project/beautifulsoup4","version":"4.12.3"}],"id":"dependency","status":"pending"}]}' + }, + { + name: '3) license test', + description: 'Scan without dependencies. It includes components with id:none, id:snippet and id:file', + content: + '{"aaaaa.c":[{"component":"engine","file":"cryptography.c","file_hash":"45931442719d401103ab8bcbbca1af99","file_url":"https://osskb.org/api/file_contents/45931442719d401103ab8bcbbca1af99","id":"snippet","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"1-37","matched":"97%","oss_lines":"33-69","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"aefc7383cccb35ecf8994c49d17c69be","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"attributions.c":[{"component":"engine","file":"attributions.c","file_hash":"4dd9a878731a51b612fedde5ad5d6084","file_url":"https://osskb.org/api/file_contents/4dd9a878731a51b612fedde5ad5d6084","id":"file","latest":"5.3.4","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"name":"JSON","source":"scancode","url":"https://spdx.org/licenses/JSON.html"},{"name":"LicenseRef-scancode-unknown-license-reference","source":"scancode"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"4dd9a878731a51b612fedde5ad5d6084","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"binary_scan.c":[{"component":"engine","file":"binary_scan.c","file_hash":"0d27d55d1134cbdaa1536babdff219f5","file_url":"https://osskb.org/api/file_contents/0d27d55d1134cbdaa1536babdff219f5","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"0d27d55d1134cbdaa1536babdff219f5","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"component.c":[{"component":"engine","file":"component.c","file_hash":"6852eb3bc69f70a15064645ad24446a2","file_url":"https://osskb.org/api/file_contents/6852eb3bc69f70a15064645ad24446a2","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2023-06-05","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"6852eb3bc69f70a15064645ad24446a2","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"1170a6175564e85c6877886e5ca565b2","vendor":"scanoss","version":"5.2.6"}],"copyright.c":[{"component":"engine","file":"copyright.c","file_hash":"e5965a5937743a78129b73b4171961e9","file_url":"https://osskb.org/api/file_contents/e5965a5937743a78129b73b4171961e9","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"e5965a5937743a78129b73b4171961e9","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"cryptography.c":[{"component":"engine","file":"cryptography.c","file_hash":"45931442719d401103ab8bcbbca1af99","file_url":"https://osskb.org/api/file_contents/45931442719d401103ab8bcbbca1af99","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"45931442719d401103ab8bcbbca1af99","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"debug.c":[{"component":"engine","file":"debug.c","file_hash":"5adbcacf687f26596731900c07570673","file_url":"https://osskb.org/api/file_contents/5adbcacf687f26596731900c07570673","id":"file","latest":"5.3.4","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"5adbcacf687f26596731900c07570673","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"decrypt.c":[{"component":"engine","file":"decrypt.c","file_hash":"d954b45c05e338f1a9f56a93110cdae0","file_url":"https://osskb.org/api/file_contents/d954b45c05e338f1a9f56a93110cdae0","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"d954b45c05e338f1a9f56a93110cdae0","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"no-match.c":[{"id":"none","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"}}]}' + }, + { + name: '4) license test', + description: 'Scan with dependencies', + content: + '{"aaaaa.c":[{"component":"engine","file":"cryptography.c","file_hash":"45931442719d401103ab8bcbbca1af99","file_url":"https://osskb.org/api/file_contents/45931442719d401103ab8bcbbca1af99","id":"snippet","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"1-37","matched":"97%","oss_lines":"33-69","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"aefc7383cccb35ecf8994c49d17c69be","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"attributions.c":[{"component":"engine","file":"attributions.c","file_hash":"4dd9a878731a51b612fedde5ad5d6084","file_url":"https://osskb.org/api/file_contents/4dd9a878731a51b612fedde5ad5d6084","id":"file","latest":"5.3.4","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"name":"JSON","source":"scancode","url":"https://spdx.org/licenses/JSON.html"},{"name":"LicenseRef-scancode-unknown-license-reference","source":"scancode"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"4dd9a878731a51b612fedde5ad5d6084","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"binary_scan.c":[{"component":"engine","file":"binary_scan.c","file_hash":"0d27d55d1134cbdaa1536babdff219f5","file_url":"https://osskb.org/api/file_contents/0d27d55d1134cbdaa1536babdff219f5","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"0d27d55d1134cbdaa1536babdff219f5","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"component.c":[{"component":"engine","file":"component.c","file_hash":"6852eb3bc69f70a15064645ad24446a2","file_url":"https://osskb.org/api/file_contents/6852eb3bc69f70a15064645ad24446a2","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2023-06-05","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"6852eb3bc69f70a15064645ad24446a2","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"1170a6175564e85c6877886e5ca565b2","vendor":"scanoss","version":"5.2.6"}],"copyright.c":[{"component":"engine","file":"copyright.c","file_hash":"e5965a5937743a78129b73b4171961e9","file_url":"https://osskb.org/api/file_contents/e5965a5937743a78129b73b4171961e9","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"e5965a5937743a78129b73b4171961e9","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"cryptography.c":[{"component":"engine","file":"cryptography.c","file_hash":"45931442719d401103ab8bcbbca1af99","file_url":"https://osskb.org/api/file_contents/45931442719d401103ab8bcbbca1af99","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"45931442719d401103ab8bcbbca1af99","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"debug.c":[{"component":"engine","file":"debug.c","file_hash":"5adbcacf687f26596731900c07570673","file_url":"https://osskb.org/api/file_contents/5adbcacf687f26596731900c07570673","id":"file","latest":"5.3.4","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"scancode","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-12-29","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"5adbcacf687f26596731900c07570673","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"587fc14ceb8fdd57727a2ab98d707916","vendor":"scanoss","version":"5.1.1"}],"decrypt.c":[{"component":"engine","file":"decrypt.c","file_hash":"d954b45c05e338f1a9f56a93110cdae0","file_url":"https://osskb.org/api/file_contents/d954b45c05e338f1a9f56a93110cdae0","id":"file","latest":"5.3.5","licenses":[{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"component_declared","url":"https://spdx.org/licenses/GPL-2.0-only.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-or-later.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-or-later","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"file_spdx_tag","url":"https://spdx.org/licenses/GPL-2.0-or-later.html"},{"checklist_url":"https://www.osadl.org/fileadmin/checklists/unreflicenses/GPL-2.0-only.txt","copyleft":"yes","incompatible_with":"Apache-1.0,Apache-1.1,Apache-2.0,BSD-4-Clause,BSD-4-Clause-UC,FTL,IJG,OpenSSL,Python-2.0,zlib-acknowledgement,XFree86-1.1","name":"GPL-2.0-only","osadl_updated":"2024-01-21T05:27:00+00:00","patent_hints":"yes","source":"license_file","url":"https://spdx.org/licenses/GPL-2.0-only.html"}],"lines":"all","matched":"100%","oss_lines":"all","purl":["pkg:github/scanoss/engine"],"release_date":"2022-09-26","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"},"source_hash":"d954b45c05e338f1a9f56a93110cdae0","status":"pending","url":"https://github.com/scanoss/engine","url_hash":"d6492e2364b3b7793773edf28a372c75","vendor":"scanoss","version":"5.0.0"}],"no-match.c":[{"id":"none","server":{"kb_version":{"daily":"24.01.22","monthly":"23.12"},"version":"5.3.5"}}],"requirements.txt":[{"dependencies":[{"component":"requests","licenses":[{"is_spdx_approved":true,"name":"Apache2.0","spdx_id":"Apache-2.0"}],"purl":"pkg:pypi/requests","url":"https://pypi.org/project/requests","version":"2.31.0"},{"licenses":[{}],"purl":"pkg:pypi/crc32c"},{"component":"binaryornot","licenses":[{"is_spdx_approved":true,"name":"BSD","spdx_id":"0BSD"}],"purl":"pkg:pypi/binaryornot","url":"https://pypi.org/project/binaryornot","version":"0.4.4"},{"component":"pytest","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:pypi/pytest","url":"https://pypi.org/project/pytest","version":"8.0.0rc2"},{"component":"pytest-cov","licenses":[{"is_spdx_approved":true,"name":"MIT","spdx_id":"MIT"}],"purl":"pkg:pypi/pytest-cov","url":"https://pypi.org/project/pytest-cov","version":"4.1.0"},{"component":"beautifulsoup4","licenses":[{"is_spdx_approved":true,"name":"MITLicense","spdx_id":"MIT"}],"purl":"pkg:pypi/beautifulsoup4","url":"https://pypi.org/project/beautifulsoup4","version":"4.12.3"}],"id":"dependency","status":"pending"}]}' + } +]; diff --git a/action.yml b/action.yml index 1194325..77977c0 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,9 @@ inputs: outputs: result-filepath: description: 'Scanner results filepath' - + output-command: + description: 'Scanner command output' + runs: using: node20 main: dist/index.js diff --git a/dist/index.js b/dist/index.js index 359ab3f..9858615 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30196,32 +30196,19 @@ async function run() { // create policies const policies = [new license_policy_check_1.LicensePolicyCheck()]; policies.forEach(async (policy) => policy.start()); - // options to get standar output - const options = {}; - let output = ''; - options.listeners = { - stdout: (data) => { - output += data.toString(); - }, - stderr: (data) => { - output += data.toString(); - } - }; - options.silent = true; // run scan - await exec.exec(`docker run -v "${repoDir}":"/scanoss" ghcr.io/scanoss/scanoss-py:v1.9.0 scan . --output ${outputPath}`, [], options); + const { stdout, stderr } = await exec.getExecOutput(`docker run -v "${repoDir}":"/scanoss" ghcr.io/scanoss/scanoss-py:v1.9.0 scan . --output ${outputPath}`, []); const scannerResults = await (0, result_service_1.readResult)(outputPath); - const licenses = (0, result_service_1.getLicenses)(scannerResults); - // create reports - const licensesReport = (0, report_service_1.getLicensesReport)(licenses); // run policies // TODO: define run action for each policy - policies.forEach(async (policy) => await policy.run(licensesReport)); + policies.forEach(async (policy) => await policy.run(scannerResults)); if ((0, github_utils_1.isPullRequest)()) { + // create reports + const licenses = (0, result_service_1.getLicenses)(scannerResults); + const licensesReport = (0, report_service_1.getLicensesReport)(licenses); (0, github_utils_1.createCommentOnPR)(licensesReport); } // set outputs for other workflow steps to use - core.setOutput('licenses', licenses.toString()); - core.setOutput('output-command', output); + core.setOutput('output-command', stdout); core.setOutput('result-filepath', outputPath); } catch (error) { @@ -30309,7 +30296,7 @@ class PolicyCheck { this.checkRunId = result.data.id; return result.data; } - async run(text) { + async run(scannerResults) { // Promise if (this.checkRunId === NO_INITIALIZATE) throw new Error(`Error on finish. Check "${this.checkName}" is not created.`); @@ -30322,7 +30309,7 @@ class PolicyCheck { output: { title: this.checkName, summary: 'Policy checker completed successfully', - text + text: '' } }); return result.data; diff --git a/src/main.ts b/src/main.ts index dcb25cd..20a027f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,42 +18,26 @@ export async function run(): Promise { const policies = [new LicensePolicyCheck()]; policies.forEach(async policy => policy.start()); - // options to get standar output - const options: exec.ExecOptions = {}; - let output = ''; - options.listeners = { - stdout: (data: Buffer) => { - output += data.toString(); - }, - stderr: (data: Buffer) => { - output += data.toString(); - } - }; - options.silent = true; - // run scan - await exec.exec( + const { stdout, stderr } = await exec.getExecOutput( `docker run -v "${repoDir}":"/scanoss" ghcr.io/scanoss/scanoss-py:v1.9.0 scan . --output ${outputPath}`, - [], - options + [] ); const scannerResults = await readResult(outputPath); - const licenses = getLicenses(scannerResults); - - // create reports - const licensesReport = getLicensesReport(licenses); // run policies // TODO: define run action for each policy - policies.forEach(async policy => await policy.run(licensesReport)); + policies.forEach(async policy => await policy.run(scannerResults)); if (isPullRequest()) { + // create reports + const licenses = getLicenses(scannerResults); + const licensesReport = getLicensesReport(licenses); createCommentOnPR(licensesReport); } // set outputs for other workflow steps to use - core.setOutput('licenses', licenses.toString()); - core.setOutput('output-command', output); + core.setOutput('output-command', stdout); core.setOutput('result-filepath', outputPath); } catch (error) { // fail the workflow run if an error occurs diff --git a/src/policies/policy-check.ts b/src/policies/policy-check.ts index acf064a..9bece71 100644 --- a/src/policies/policy-check.ts +++ b/src/policies/policy-check.ts @@ -1,6 +1,7 @@ import { context, getOctokit } from '@actions/github'; import * as core from '@actions/core'; import { getSHA } from '../utils/github.utils'; +import { ScannerResults } from '../services/result.interfaces'; const NO_INITIALIZATE = -1; @@ -33,7 +34,7 @@ export abstract class PolicyCheck { return result.data; } - async run(text: string): Promise { + async run(scannerResults: ScannerResults): Promise { // Promise if (this.checkRunId === NO_INITIALIZATE) throw new Error(`Error on finish. Check "${this.checkName}" is not created.`); @@ -47,7 +48,7 @@ export abstract class PolicyCheck { output: { title: this.checkName, summary: 'Policy checker completed successfully', - text + text: '' } });