-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from theztefan/allow-list-dependencies
Exclude dependencies from license checks
- Loading branch information
Showing
15 changed files
with
794 additions
and
6,944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,32 @@ const rubyChange: Change = { | |
] | ||
} | ||
|
||
const pipChange: Change = { | ||
change_type: 'added', | ||
manifest: 'requirements.txt', | ||
ecosystem: 'pip', | ||
name: 'package-1', | ||
version: '1.1.1', | ||
package_url: 'pkg:pip/[email protected]', | ||
license: 'MIT', | ||
source_repository_url: 'github.com/some-repo', | ||
scope: 'runtime', | ||
vulnerabilities: [ | ||
{ | ||
severity: 'moderate', | ||
advisory_ghsa_id: 'second-random_string', | ||
advisory_summary: 'not so dangerous', | ||
advisory_url: 'github.com/future-funk' | ||
}, | ||
{ | ||
severity: 'low', | ||
advisory_ghsa_id: 'third-random_string', | ||
advisory_summary: 'dont page me', | ||
advisory_url: 'github.com/future-funk' | ||
} | ||
] | ||
} | ||
|
||
jest.mock('@actions/core') | ||
|
||
const mockOctokit = { | ||
|
@@ -153,6 +179,34 @@ test('it adds all licenses to unresolved if it is unable to determine the validi | |
expect(invalidLicenses.unresolved.length).toEqual(2) | ||
}) | ||
|
||
test('it does not filter out changes that are on the exclusions list', async () => { | ||
const changes: Changes = [pipChange, npmChange, rubyChange] | ||
const licensesConfig = { | ||
allow: ['BSD'], | ||
licenseExclusions: ['pkg:pip/[email protected]', 'pkg:npm/[email protected]'] | ||
} | ||
const invalidLicenses = await getInvalidLicenseChanges( | ||
changes, | ||
licensesConfig | ||
) | ||
expect(invalidLicenses.forbidden.length).toEqual(0) | ||
}) | ||
|
||
test('it does filters out changes if they are not on the exclusions list', async () => { | ||
const changes: Changes = [pipChange, npmChange, rubyChange] | ||
const licensesConfig = { | ||
allow: ['BSD'], | ||
licenseExclusions: ['pkg:pip/[email protected]', 'pkg:npm/[email protected]'] | ||
} | ||
const invalidLicenses = await getInvalidLicenseChanges( | ||
changes, | ||
licensesConfig | ||
) | ||
expect(invalidLicenses.forbidden.length).toEqual(2) | ||
expect(invalidLicenses.forbidden[0]).toBe(pipChange) | ||
expect(invalidLicenses.forbidden[1]).toBe(npmChange) | ||
}) | ||
|
||
describe('GH License API fallback', () => { | ||
test('it calls licenses endpoint if atleast one of the changes has null license and valid source_repository_url', async () => { | ||
const nullLicenseChange = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.