Skip to content

Commit a87294d

Browse files
committed
Revert "Merge pull request #916 from jebeaudet/spdx-support"
This reverts commit 5a5d4df, reversing changes made to 67d4f4b.
1 parent 5a5d4df commit a87294d

File tree

4 files changed

+6
-138
lines changed

4 files changed

+6
-138
lines changed

__tests__/licenses.test.ts

Lines changed: 1 addition & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const npmChange: Change = {
2121
}
2222
]
2323
}
24+
2425
const rubyChange: Change = {
2526
change_type: 'added',
2627
manifest: 'Gemfile.lock',
@@ -100,105 +101,6 @@ beforeEach(async () => {
100101
jest.resetModules()
101102
})
102103

103-
test('it should handle SPDX expressions in allow-list that matches a single license project', async () => {
104-
const change: Change = getChangeWithLicense('MIT')
105-
const changes: Changes = [change]
106-
107-
const {forbidden} = await getInvalidLicenseChanges(changes, {
108-
allow: ['EPL-1.0 OR MIT']
109-
})
110-
111-
expect(forbidden).toStrictEqual([])
112-
})
113-
114-
test('it should handle SPDX expressions in allow-list with operators and a valid triple licensed project', async () => {
115-
const change: Change = getChangeWithLicense(
116-
'EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only'
117-
)
118-
const changes: Changes = [change]
119-
120-
const {forbidden} = await getInvalidLicenseChanges(changes, {
121-
allow: ['EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only']
122-
})
123-
124-
expect(forbidden).toStrictEqual([])
125-
})
126-
127-
test('it should handle a valid triple licensed project that does not have a match in the allow-list', async () => {
128-
const change = getChangeWithLicense('EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only')
129-
const changes: Changes = [change]
130-
131-
const {forbidden} = await getInvalidLicenseChanges(changes, {
132-
allow: ['EPL-1.0', 'LGPL-2.1', 'LGPL-2.1-only']
133-
})
134-
135-
expect(forbidden[0]).toBe(change)
136-
expect(forbidden.length).toEqual(1)
137-
})
138-
139-
test('it should handle license with OR SPDX expression and only match on one license in the allow-list', async () => {
140-
const change = getChangeWithLicense('EPL-1.0 OR LGPL-2.1')
141-
const changes: Changes = [change]
142-
143-
for (const allowedLicense of ['EPL-1.0', 'LGPL-2.1']) {
144-
const {forbidden} = await getInvalidLicenseChanges(changes, {
145-
allow: [allowedLicense]
146-
})
147-
148-
expect(forbidden).toStrictEqual([])
149-
}
150-
})
151-
152-
test('it should handle SPDX expressions in allow-list with operators when license matches', async () => {
153-
const changes: Changes = [
154-
npmChange // MIT license
155-
]
156-
157-
const {forbidden} = await getInvalidLicenseChanges(changes, {
158-
allow: ['MIT OR Apache-2.0', 'MIT', 'BSD-3-Clause']
159-
})
160-
161-
expect(forbidden).toStrictEqual([])
162-
})
163-
164-
test('it should handle SPDX expressions in allow-list with operators when license does not match', async () => {
165-
const changes: Changes = [
166-
npmChange // MIT license
167-
]
168-
169-
const {forbidden} = await getInvalidLicenseChanges(changes, {
170-
allow: ['MIT AND Apache-2.0', 'BSD-3-Clause']
171-
})
172-
173-
expect(forbidden[0]).toBe(npmChange)
174-
expect(forbidden.length).toEqual(1)
175-
})
176-
177-
test('it should handle SPDX expressions in deny-list with operators when license matches deny list entry', async () => {
178-
const changes: Changes = [
179-
npmChange // MIT license
180-
]
181-
182-
const {forbidden} = await getInvalidLicenseChanges(changes, {
183-
deny: ['MIT OR Apache-2.0', 'BSD-3-Clause']
184-
})
185-
186-
expect(forbidden[0]).toBe(npmChange)
187-
expect(forbidden.length).toEqual(1)
188-
})
189-
190-
test('it should handle SPDX expressions in deny-list with operators when license does not match any deny list entry', async () => {
191-
const changes: Changes = [
192-
npmChange // MIT license
193-
]
194-
195-
const {forbidden} = await getInvalidLicenseChanges(changes, {
196-
deny: ['MIT AND Apache-2.0', 'BSD-3-Clause']
197-
})
198-
199-
expect(forbidden).toStrictEqual([])
200-
})
201-
202104
test('it adds license outside the allow list to forbidden changes', async () => {
203105
const changes: Changes = [
204106
npmChange, // MIT license
@@ -362,25 +264,3 @@ describe('GH License API fallback', () => {
362264
expect(unlicensed.length).toEqual(0)
363265
})
364266
})
365-
366-
function getChangeWithLicense(license: string): Change {
367-
return {
368-
manifest: 'pom.xml',
369-
change_type: 'added',
370-
ecosystem: 'maven',
371-
name: 'dummy-library',
372-
version: '1.0.0',
373-
package_url: 'pkg:org.something:sdummy-library@1.0.0',
374-
license,
375-
source_repository_url: 'github.com/some-repo',
376-
scope: 'runtime',
377-
vulnerabilities: [
378-
{
379-
severity: 'critical',
380-
advisory_ghsa_id: 'first-random_string',
381-
advisory_summary: 'very dangerous',
382-
advisory_url: 'github.com/future-funk'
383-
}
384-
]
385-
}
386-
}

dist/index.js

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/licenses.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,14 @@ export async function getInvalidLicenseChanges(
8888
try {
8989
if (allow !== undefined) {
9090
if (spdx.isValid(license)) {
91-
let found = false
92-
for (const allowedLicense of allow) {
93-
found ||= spdx.satisfies(allowedLicense, license)
94-
}
91+
const found = spdx.satisfiesAny(license, allow)
9592
validityCache.set(license, found)
9693
} else {
9794
invalidLicenseChanges.unresolved.push(change)
9895
}
9996
} else if (deny !== undefined) {
10097
if (spdx.isValid(license)) {
101-
let found = false
102-
for (const deniedLicense of deny) {
103-
found ||= spdx.satisfies(deniedLicense, license)
104-
}
98+
const found = spdx.satisfiesAny(license, deny)
10599
validityCache.set(license, !found)
106100
} else {
107101
invalidLicenseChanges.unresolved.push(change)

0 commit comments

Comments
 (0)