-
- Notifications
You must be signed in to change notification settings - Fork 613
Add support for external licenses in scans #2979
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
Merged
pombredanne merged 45 commits into aboutcode-org:develop from KevinJi22:external-licenses-480 Oct 28, 2022
Merged
Changes from all commits
Commits
Show all changes
45 commits Select commit Hold shift + click to select a range
05d9197 Add support for external licenses in scans #480
KevinJi22 4989205 Add documentation for new ``--dir`` CLI option
KevinJi22 0cbfff1 Enable using installed licenses in scans #2994
KevinJi22 3376b9c Add CI job to test detecting installed license
KevinJi22 681436d Add documentation for installed license plugins
KevinJi22 e741ffd Enable installed rules to be used in detection
KevinJi22 afae692 Move `licensedcode_test_utils` into main wheel
KevinJi22 f576dfa Add Windows and MacOS images to Azure pipelines
KevinJi22 a68c4cc Add rule and license validation when index is made
KevinJi22 789cf76 Add SPDX license key to example licenses
KevinJi22 e7809ee Refactor CLI option for external licenses
KevinJi22 cdf627f revise documentation for --additional-license-directory
KevinJi22 7e66c9a fix docstrings
KevinJi22 9679feb refactor API to not use additional_directories except when reindexing
KevinJi22 6aae7e2 Always consider multiple directories when generating index
KevinJi22 f13ed1d Ensure licenses are unique when loading licenses from multiple direct…
KevinJi22 9b03eea add callback for --additional-license-directory and include additiona…
KevinJi22 40f3be9 fix help.txt to include --additional-license-directory
KevinJi22 983024e fix docs
KevinJi22 c8391d0 fix basic-options.rst
KevinJi22 1bc43af add check in cli.py to see if cached directories file actually exists
KevinJi22 fc7b967 fix expected test results directory path
KevinJi22 597c616 fix underline in docs
KevinJi22 85001c1 fix expected results for external and installed license tests
KevinJi22 7497009 put license installation into posix azure pipeline
KevinJi22 d6068c6 remove setuptools and wheel from setup.py
KevinJi22 16513ff change from scan to reindex licenses in license library validation test
KevinJi22 17df9d0 Add is_builtin field to Licenses and Rules and modify url output
KevinJi22 3762ca5 fix methods based on previous changes
KevinJi22 ba9740b add new license provider plugin for additional licenses
KevinJi22 ba11f05 Test that additional license plugin works
pombredanne 61c3283 Merge latest develop
pombredanne a4ebbe0 Use new "scanplugins" pytest marker
pombredanne 1db9437 Add CHANGELOG entry
pombredanne 8df0e27 fix expected scan results after installed license CI change
KevinJi22 f53886f Reorganize additional license tests
AyanSinhaMahapatra 5361052 Move reindex licenses to a seperate script
AyanSinhaMahapatra a477e54 Merge branch 'develop' into external-licenses-480
AyanSinhaMahapatra 6412039 Add external licenses info in header
AyanSinhaMahapatra 6e14d8a Add is_builtin flag to matched_rule data
AyanSinhaMahapatra 044f60d Do not return empty strings in license data
AyanSinhaMahapatra f201faa Add --only-builtin falg for scancode-reindex-licenses
AyanSinhaMahapatra 095c8ed Update docs for external licenses
AyanSinhaMahapatra 54fb102 Refactor external licenses code
AyanSinhaMahapatra f2b1e13 Improve CHANGELOG.rst
pombredanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,102 @@ | ||
| Other available CLIs | ||
| ==================== | ||
| | ||
| .. _other_cli: | ||
| | ||
| ---- | ||
| | ||
| .. include:: /rst_snippets/scancode-reindex-licenses.rst | ||
| | ||
| ---- | ||
| | ||
| .. include:: /rst_snippets/extract.rst | ||
| | ||
| ---- | ||
| | ||
| ``scancode-reindex-licenses`` command | ||
| ------------------------------------- | ||
| | ||
| ScanCode maintains a license index to search for and detect licenses. When Scancode is | ||
| configured for the first time, a license index is built and used in every scan thereafter. | ||
| | ||
| This ``scancode-reindex-licenses`` command rebuilds the license index. Running this command | ||
| displays the following message to the terminal:: | ||
| | ||
| Checking and rebuilding the license index... | ||
| | ||
| This has several CLI options as follows: | ||
| | ||
| ``--additional-directory`` Option: | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
| The ``--additional-directory`` option allows the user to include additional directories | ||
| of licenses to use in license detection. | ||
| | ||
| This command only needs to be run once for each set of additional directories, in all subsequent | ||
| runs of Scancode with the same directories all the licenses in the directories will be cached | ||
| and used in License detection. But reindexing removes these directories, if they aren't | ||
| reintroduced as additional directories. | ||
| | ||
| The directory structure should look something like this:: | ||
| | ||
| additional_license_directory/ | ||
| ├── licenses/ | ||
| │ ├── example-installed-1.LICENSE | ||
| │ └── example-installed-1.yaml | ||
| ├── rules/ | ||
| │ ├── example-installed-1.RULE | ||
| │ └── example-installed-1.yaml | ||
| | ||
| Here is an example of reindexing the license cache using the ``--additional-directory PATH`` option | ||
| with a single directory:: | ||
| | ||
| scancode-reindex-licenses --additional-directory tests/licensedcode/data/additional_licenses/additional_dir/ | ||
| | ||
| You can also include multiple directories like so:: | ||
| | ||
| scancode-reindex-licenses --additional-directory /home/user/external_licenses/external1 --additional-directory /home/user/external_licenses/external2 | ||
| | ||
| If you want to continue running scans with ``/home/user/external_licenses/external1`` and | ||
| ``/home/user/external_licenses/external2``, you can simply run scans after the command above | ||
| reindexing with those directories and they will be included. :: | ||
| | ||
| scancode -l --license-text --json-pp output.json samples | ||
| | ||
| However, if you wanted to run a scan with a new set of directories, such as | ||
| ``home/user/external_licenses/external1`` and ``home/user/external_licenses/external3``, you would | ||
| need to reindex the license index with those directories as parameters:: | ||
| | ||
| scancode --additional-directory /home/user/external_licenses/external1 --additional-directory /home/user/external_licenses/external3 | ||
| | ||
| .. include:: /rst_snippets/note_snippets/additional_directory_is_temp.rst | ||
| | ||
| | ||
| .. note:: | ||
| | ||
| You can also install external licenses through a plugin for | ||
| better reproducibility and distribution of those license/rules | ||
| for use in conjunction with scancode-toolkit licenses. | ||
| See :ref:`install_new_license_plugin` | ||
| | ||
| | ||
| ``--only-builtin`` Option: | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
| Rebuild the license index excluding any additional license directory or additional | ||
| license plugins which were added previously, i.e. with only builtin scancode license and rules. | ||
| | ||
| This is applicable when there are additional license plugins installed already and you want to | ||
| reindex the licenses without these licenses from the additional plugins. | ||
| | ||
| .. note:: | ||
| | ||
| Running the ``--only-builtin`` command won't get rid of the installed license plugins, it | ||
| would just reindex without the licenses from these plugins for once. Another reindex afterwards | ||
| without this option would bring back the licenses from the plugins again in the index. | ||
| | ||
| | ||
| ``--all-languages`` Option: | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
| Rebuild the license index including texts all languages (and not only | ||
| English) and exit. This is an EXPERIMENTAL option. |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| | @@ -8,3 +8,4 @@ | |
| | ||
| add_new_license | ||
| add_new_license_detection_rule | ||
| install_new_license_plugin | ||
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.
Uh oh!
There was an error while loading. Please reload this page.