Skip to content
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

Add support for external licenses in scans #2979

Merged
merged 45 commits into from
Oct 28, 2022

Commits on Sep 4, 2022

  1. Add support for external licenses in scans aboutcode-org#480

    This adds `-dir` or `--additional-directories` as a command line
    option in license detection. This allows users to specify paths to
    directories of licenses and rules they'd like to use during license
    detection, but would not like to add to the ScanCode database of
    licenses.
    
    This involves adding a new option in `licensedcode/plugin_license.py`,
    and this option is used as a parameter in `scancode/api.py`. In this
    approach, the licenses and rules contained in these additional
    directories are combined with the existing licenses and rules in the
    ScanCode database to produce a single index. The code for this is found
    in `licensedcode/cache.py` and the helper methods for loading these
    licenses and rules are found in `licensedcode/models.py`. This commit
    also includes a unit test to verify that license detection succeeds
    with an additional directory found in
    `tests/licensedcode/test_plugin_license.py`. Part of the setup for the
    unit test and future tests involves creating a new directory in
    `tests/licensedcode/data` that contains sample external licenses used
    in the unit tests.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    05d9197 View commit details
    Browse the repository at this point in the history
  2. Add documentation for new --dir CLI option

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    4989205 View commit details
    Browse the repository at this point in the history
  3. Enable using installed licenses in scans aboutcode-org#2994

    This allows users to use licenses that they install via wheels in
    license scans. It also adds a sample package containing an external
    license that can be used to manually verify expected behavior.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    0cbfff1 View commit details
    Browse the repository at this point in the history
  4. Add CI job to test detecting installed license

    This adds a new CI job in azure-pipelines.yml that installs an external
    license and tests that we can detect it.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    3376b9c View commit details
    Browse the repository at this point in the history
  5. Add documentation for installed license plugins

    This adds documentation for how to set up directories of installed
    licenses and how to install them for license detection.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    681436d View commit details
    Browse the repository at this point in the history
  6. Enable installed rules to be used in detection

    This adds files in the example installed license that can be used in
    license detection. It also adds a test to be run as part of a CI job.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    e741ffd View commit details
    Browse the repository at this point in the history
  7. Move licensedcode_test_utils into main wheel

    This moves `licensedcode_test_utils` from tests into src so that
    users can write their own tests for installed licenses.
    It also adds documentation for how to write and run these tests.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    afae692 View commit details
    Browse the repository at this point in the history
  8. Add Windows and MacOS images to Azure pipelines

    This adds Windows and MacOS images as part of the CI job to test
    the installed external license detection.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    f576dfa View commit details
    Browse the repository at this point in the history
  9. Add rule and license validation when index is made

    This performs the checks `check_ignorable_clues()` in
    test_detection_validate.py and `test_validate_license_library_data()`
    in test_models.py when the index is created.
    This will allow us to validate additional rules and licenses that are
    added into the index.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    a68c4cc View commit details
    Browse the repository at this point in the history
  10. Add SPDX license key to example licenses

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    789cf76 View commit details
    Browse the repository at this point in the history
  11. Refactor CLI option for external licenses

    This removes ``-dir`` as an option and renames
    ``--additional_directories`` to ``--external-license-directory``.
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    e7809ee View commit details
    Browse the repository at this point in the history
  12. revise documentation for --additional-license-directory

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    cdf627f View commit details
    Browse the repository at this point in the history
  13. fix docstrings

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    7e66c9a View commit details
    Browse the repository at this point in the history
  14. refactor API to not use additional_directories except when reindexing

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    9679feb View commit details
    Browse the repository at this point in the history
  15. Always consider multiple directories when generating index

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    6aae7e2 View commit details
    Browse the repository at this point in the history
  16. Ensure licenses are unique when loading licenses from multiple direct…

    …ories
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    f13ed1d View commit details
    Browse the repository at this point in the history
  17. add callback for --additional-license-directory and include additiona…

    …l directories in scancode output
    
    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    9b03eea View commit details
    Browse the repository at this point in the history
  18. fix help.txt to include --additional-license-directory

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    40f3be9 View commit details
    Browse the repository at this point in the history
  19. fix docs

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    983024e View commit details
    Browse the repository at this point in the history
  20. fix basic-options.rst

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    c8391d0 View commit details
    Browse the repository at this point in the history
  21. add check in cli.py to see if cached directories file actually exists

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    1bc43af View commit details
    Browse the repository at this point in the history
  22. fix expected test results directory path

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    fc7b967 View commit details
    Browse the repository at this point in the history
  23. fix underline in docs

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    597c616 View commit details
    Browse the repository at this point in the history
  24. fix expected results for external and installed license tests

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    85001c1 View commit details
    Browse the repository at this point in the history
  25. put license installation into posix azure pipeline

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    7497009 View commit details
    Browse the repository at this point in the history
  26. remove setuptools and wheel from setup.py

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    d6068c6 View commit details
    Browse the repository at this point in the history
  27. change from scan to reindex licenses in license library validation test

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    16513ff View commit details
    Browse the repository at this point in the history
  28. Add is_builtin field to Licenses and Rules and modify url output

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 4, 2022
    Configuration menu
    Copy the full SHA
    17df9d0 View commit details
    Browse the repository at this point in the history

Commits on Sep 5, 2022

  1. fix methods based on previous changes

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 5, 2022
    Configuration menu
    Copy the full SHA
    3762ca5 View commit details
    Browse the repository at this point in the history
  2. add new license provider plugin for additional licenses

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Sep 5, 2022
    Configuration menu
    Copy the full SHA
    ba9740b View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2022

  1. Test that additional license plugin works

    This test can run only in the CI and use a new pytest marker.
    This requires isolation as it installs new license from a new location
    plugin.
    
    Co-authored-by: Kevin Ji <kyji1011@gmail.com>
    Co-authored-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    3 people committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    ba11f05 View commit details
    Browse the repository at this point in the history
  2. Merge latest develop

    Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    pombredanne committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    61c3283 View commit details
    Browse the repository at this point in the history
  3. Use new "scanplugins" pytest marker

    Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    pombredanne committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    a4ebbe0 View commit details
    Browse the repository at this point in the history
  4. Add CHANGELOG entry

    Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    pombredanne committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    1db9437 View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2022

  1. fix expected scan results after installed license CI change

    Signed-off-by: Kevin Ji <kyji1011@gmail.com>
    KevinJi22 committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    8df0e27 View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2022

  1. Reorganize additional license tests

    * Organize tests data under one single folder.
    * Organize test functions under one single file.
    * Keep three tests, one for additional directory, one for
      additional plugin, and one for combined testing.
    * Edit the CI file accordingly.
    
    Co-authored-by: Philippe Ombredanne <pombredanne@nexb.com>
    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra and pombredanne committed Oct 12, 2022
    Configuration menu
    Copy the full SHA
    f53886f View commit details
    Browse the repository at this point in the history
  2. Move reindex licenses to a seperate script

    Delete the reindex licenses options from scancode
    CLI and add a new script which does the reindexing,
    also with additional directories optinally.
    
    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 12, 2022
    Configuration menu
    Copy the full SHA
    5361052 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a477e54 View commit details
    Browse the repository at this point in the history
  4. Add external licenses info in header

    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 12, 2022
    Configuration menu
    Copy the full SHA
    6412039 View commit details
    Browse the repository at this point in the history

Commits on Oct 20, 2022

  1. Add is_builtin flag to matched_rule data

    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    6e14d8a View commit details
    Browse the repository at this point in the history
  2. Do not return empty strings in license data

    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    044f60d View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2022

  1. Add --only-builtin falg for scancode-reindex-licenses

    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 21, 2022
    Configuration menu
    Copy the full SHA
    f201faa View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2022

  1. Update docs for external licenses

    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 28, 2022
    Configuration menu
    Copy the full SHA
    095c8ed View commit details
    Browse the repository at this point in the history
  2. Refactor external licenses code

    Refactor according to the feedback.
    
    Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
    AyanSinhaMahapatra committed Oct 28, 2022
    Configuration menu
    Copy the full SHA
    54fb102 View commit details
    Browse the repository at this point in the history
  3. Improve CHANGELOG.rst

    Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    pombredanne committed Oct 28, 2022
    Configuration menu
    Copy the full SHA
    f2b1e13 View commit details
    Browse the repository at this point in the history