From 34486f306eacc0b5ba73c8d12b5af19a58d22364 Mon Sep 17 00:00:00 2001 From: Kevin Dangoor Date: Thu, 8 May 2025 17:17:08 -0400 Subject: [PATCH] Check namespaces when excluding license checks The `allow-dependencies-licenses` option was not checking the namespace part of the PURL to make sure it matched. --- __tests__/licenses.test.ts | 11 +++++++++++ src/licenses.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/__tests__/licenses.test.ts b/__tests__/licenses.test.ts index f803219..c1b26ea 100644 --- a/__tests__/licenses.test.ts +++ b/__tests__/licenses.test.ts @@ -338,4 +338,15 @@ describe('GH License API fallback', () => { expect(mockOctokit.rest.licenses.getForRepo).not.toHaveBeenCalled() expect(unlicensed.length).toEqual(0) }) + + test('it checks namespaces when doing exclusions', async () => { + const {unlicensed} = await getInvalidLicenseChanges([unlicensedChange], { + licenseExclusions: [ + 'pkg:githubactions/bar-org/actions-repo/.github/workflows/some-action.yml' + ] + }) + + expect(mockOctokit.rest.licenses.getForRepo).not.toHaveBeenCalled() + expect(unlicensed.length).toEqual(1) + }) }) diff --git a/src/licenses.ts b/src/licenses.ts index 650cbe5..6442f04 100644 --- a/src/licenses.ts +++ b/src/licenses.ts @@ -174,6 +174,7 @@ async function groupChanges( licenseExclusions.findIndex( exclusion => exclusion.type === changeAsPackageURL.type && + exclusion.namespace === changeAsPackageURL.namespace && exclusion.name === changeAsPackageURL.name ) !== -1 ) {