Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
123b58703a | ||
|
|
cd559bc984 | ||
|
|
70f8094bec | ||
|
|
0b306aef97 |
@@ -192,6 +192,23 @@ test('it does not filter out changes that are on the exclusions list', async ()
|
|||||||
expect(invalidLicenses.forbidden.length).toEqual(0)
|
expect(invalidLicenses.forbidden.length).toEqual(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('it does not fail when the packages dont have a valid PURL', async () => {
|
||||||
|
const emptyPurlChange = pipChange
|
||||||
|
emptyPurlChange.package_url = ''
|
||||||
|
|
||||||
|
const changes: Changes = [emptyPurlChange, 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(1)
|
||||||
|
})
|
||||||
|
|
||||||
test('it does filters out changes if they are not on the exclusions list', async () => {
|
test('it does filters out changes if they are not on the exclusions list', async () => {
|
||||||
const changes: Changes = [pipChange, npmChange, rubyChange]
|
const changes: Changes = [pipChange, npmChange, rubyChange]
|
||||||
const licensesConfig = {
|
const licensesConfig = {
|
||||||
|
|||||||
+6
-1
@@ -284,6 +284,9 @@ function getInvalidLicenseChanges(changes, licenses) {
|
|||||||
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
||||||
// It does by creating a new PackageURL object from the change and comparing it to the exclusions list
|
// It does by creating a new PackageURL object from the change and comparing it to the exclusions list
|
||||||
groupedChanges.licensed = groupedChanges.licensed.filter(change => {
|
groupedChanges.licensed = groupedChanges.licensed.filter(change => {
|
||||||
|
if (change.package_url.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const changeAsPackageURL = packageurl_js_1.PackageURL.fromString(change.package_url);
|
const changeAsPackageURL = packageurl_js_1.PackageURL.fromString(change.package_url);
|
||||||
// We want to find if the licenseExclussion list contains the PackageURL of the Change
|
// We want to find if the licenseExclussion list contains the PackageURL of the Change
|
||||||
// If it does, we want to filter it out and therefore return false
|
// If it does, we want to filter it out and therefore return false
|
||||||
@@ -294,7 +297,9 @@ function getInvalidLicenseChanges(changes, licenses) {
|
|||||||
exclusion.name === changeAsPackageURL.name) !== -1) {
|
exclusion.name === changeAsPackageURL.name) !== -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const licensedChanges = groupedChanges.licensed;
|
const licensedChanges = groupedChanges.licensed;
|
||||||
const invalidLicenseChanges = {
|
const invalidLicenseChanges = {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dependency-review-action",
|
"name": "dependency-review-action",
|
||||||
"version": "3.0.5",
|
"version": "3.0.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dependency-review-action",
|
"name": "dependency-review-action",
|
||||||
"version": "3.0.5",
|
"version": "3.0.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dependency-review-action",
|
"name": "dependency-review-action",
|
||||||
"version": "3.0.5",
|
"version": "3.0.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A GitHub Action for Dependency Review",
|
"description": "A GitHub Action for Dependency Review",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
@@ -60,4 +60,4 @@
|
|||||||
"ts-jest": "^27.1.4",
|
"ts-jest": "^27.1.4",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -41,6 +41,10 @@ export async function getInvalidLicenseChanges(
|
|||||||
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
||||||
// It does by creating a new PackageURL object from the change and comparing it to the exclusions list
|
// It does by creating a new PackageURL object from the change and comparing it to the exclusions list
|
||||||
groupedChanges.licensed = groupedChanges.licensed.filter(change => {
|
groupedChanges.licensed = groupedChanges.licensed.filter(change => {
|
||||||
|
if (change.package_url.length === 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
const changeAsPackageURL = PackageURL.fromString(change.package_url)
|
const changeAsPackageURL = PackageURL.fromString(change.package_url)
|
||||||
|
|
||||||
// We want to find if the licenseExclussion list contains the PackageURL of the Change
|
// We want to find if the licenseExclussion list contains the PackageURL of the Change
|
||||||
@@ -56,8 +60,9 @@ export async function getInvalidLicenseChanges(
|
|||||||
) !== -1
|
) !== -1
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
})
|
})
|
||||||
const licensedChanges: Changes = groupedChanges.licensed
|
const licensedChanges: Changes = groupedChanges.licensed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user