New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SPDX Expression Parsing #719
Open
febuiles
wants to merge
20
commits into
main
Choose a base branch
from
change-spdx-parser
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2d2630a
Adding types/dependency on new SDPX expression parser
febuiles 1bce650
Merge branch 'main' into change-spdx-parser
febuiles e189847
Improve the SDPX module.
febuiles f7de81a
Fix imports.
febuiles a7b8416
Fix imports.
febuiles 6777e09
Fix bug in old code.
febuiles 00d90f1
Refactoring more SPDX calls.
febuiles 05c90e2
Fix mocks and licenses in tests.
febuiles cef2fd4
Updating dist
febuiles 58af355
Adding type files.
febuiles 7ff1a35
Fix duplicates on tsconfig.json
febuiles b19bd76
Fix type warnings.
febuiles fd78359
remove additional in tests
febuiles aedf76f
Split exception handling in config.ts.
febuiles 3541577
Adding another test and some instructions.
febuiles f83cc8b
Adding a test `-only`/`-or-later` expressions.
febuiles 15c4f18
One last test!
febuiles 161d112
read files as utf-8
febuiles c5c5f44
Remove unnecessary try.
febuiles 319f6dd
Merge branch 'main' into change-spdx-parser
febuiles File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fail_on_severity: critical | ||
allow_licenses: | ||
- "BSD" | ||
- "GPL 2" | ||
- "BSD-3-Clause" | ||
- "GPL-2.0" |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {expect, test, describe} from '@jest/globals' | ||
import * as spdx from '../src/spdx' | ||
|
||
describe('isValid', () => { | ||
test('returns true on valid expressions', async () => { | ||
const license = 'MIT' | ||
expect(spdx.isValid(license)).toBe(true) | ||
}) | ||
|
||
test('returns false on invalid expressions', async () => { | ||
const license = 'nope' | ||
expect(spdx.isValid(license)).toBe(false) | ||
}) | ||
}) | ||
|
||
describe('satisfies', () => { | ||
test('returns true if a license satisfies a constraint', async () => { | ||
const license = 'MIT' | ||
const expr = 'MIT OR GPL-2.0' | ||
expect(spdx.satisfies(license, expr)).toBe(true) | ||
}) | ||
|
||
test('works on AND expressions', () => { | ||
const license = 'GPL-2.0 AND GPL-3.0' | ||
const expr = 'MIT OR (GPL-2.0 AND GPL-3.0)' | ||
expect(spdx.satisfies(license, expr)).toBe(true) | ||
}) | ||
|
||
test('-only expressions are properly parsed', () => { | ||
const license = 'GPL-3.0' | ||
const expr = 'GPL-3.0-only' | ||
expect(spdx.satisfies(license, expr)).toBe(true) | ||
}) | ||
|
||
test('-or-later expressions are properly parsed', () => { | ||
const license = 'GPL-3.0' | ||
const expr = 'GPL-2.0-or-later' | ||
expect(spdx.satisfies(license, expr)).toBe(true) | ||
}) | ||
|
||
test('GPL expressions are supported', () => { | ||
const license = 'GPL-2.0' | ||
const expr = 'GPL-3.0-or-later' | ||
expect(spdx.satisfies(license, expr)).toBe(false) | ||
}) | ||
|
||
test('returns false if no matches are found', async () => { | ||
const license = 'ISC' | ||
const expr = 'MIT OR GPL-2.0' | ||
|
||
expect(spdx.satisfies(license, expr)).toBe(false) | ||
}) | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 do these paths require the
../__tests__/
prefix or would afixtures/
prefix work too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure why (maybe
jest
?), but the path needs to be relative tosrc/
, hence the change from./
to../
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hmaurer @bteng22 thoughts on this? if its nothing, feel free to ignore 👍