Skip to content

feat: add license filtering with compliance check#1379

Merged
behnazh-w merged 6 commits intooracle:mainfrom
RuchitAgrawal:729-license-check
Apr 24, 2026
Merged

feat: add license filtering with compliance check#1379
behnazh-w merged 6 commits intooracle:mainfrom
RuchitAgrawal:729-license-check

Conversation

@RuchitAgrawal
Copy link
Copy Markdown
Contributor

@RuchitAgrawal RuchitAgrawal commented Apr 19, 2026

Summary

Implements license filtering for Macaron. Adds a new check that detects a repository's license via the GitHub API and validates it against a user-configured SPDX allow-list.

Description of changes

  • Configuration: added a license section to defaults.ini with options to enable the check, define allowed SPDX identifiers, and require a license to be present.
  • API client: added get_license() to GhAPIClient using the GitHub REST API to fetch license data.
  • License check: implemented mcn_license_1 which detects the repository license via the GitHub API, falls back to the cloned filesystem, and reports PASSED or FAILED based on the configured allow-list.
  • Tests: added unit tests covering all detection and policy evaluation scenarios.

Related issues

Fixes #729

Checklist

  • I have reviewed the contribution guide.
  • My PR title and commits follow the Conventional Commits convention.
  • My commits include the "Signed-off-by" line.
  • I have signed my commits following the instructions provided by GitHub. Note that we run GitHub's commit verification tool to check the commit signatures. A green verified label should appear next to all of your commits on GitHub.
  • I have updated the relevant documentation, if applicable.
  • I have tested my changes and verified they work as expected.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Apr 19, 2026
@RuchitAgrawal RuchitAgrawal changed the title feat(license): add license filtering with compliance check feat: add license filtering with compliance check Apr 19, 2026
Copy link
Copy Markdown
Member

@behnazh-w behnazh-w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RuchitAgrawal Thank you for contributing to our project.

To test this check end-to-end, please add the line to the one of the integration tests to make sure the new check passes. Here is one candidate:

  • tests/integration/cases/pypi_arrow/policy.dl
Policy("has-hosted-build", component_id, "Require a hosted build and publishing service.") :-
    check_passed(component_id, "mcn_build_as_code_1"),
    check_passed(component_id, "mcn_license_1").

This should pass as arrow uses the Apache 2.0 license.

Comment thread src/macaron/slsa_analyzer/checks/license_check.py Outdated
Comment thread src/macaron/slsa_analyzer/checks/license_check.py Outdated
Comment thread src/macaron/slsa_analyzer/checks/license_check.py Outdated
Comment thread src/macaron/slsa_analyzer/checks/license_check.py Outdated
Comment thread src/macaron/slsa_analyzer/checks/license_check.py Outdated
@RuchitAgrawal
Copy link
Copy Markdown
Contributor Author

Thank you for the review and Feedback. I've gone through your comments and noted the required adjustments. I'll get those changes implemented and pushed by tonight.

@RuchitAgrawal
Copy link
Copy Markdown
Contributor Author

Hi @behnazh-w, I have implemented the fixes based on your suggestions and feedback. Could you kindly review these changes? I’m happy to make further improvements if anything else is needed.

behnazh-w
behnazh-w previously approved these changes Apr 21, 2026
@behnazh-w
Copy link
Copy Markdown
Member

@RuchitAgrawal thanks for the changes, they look good! A few more things:

  • Looks like you have not signed your commits. Please make sure all of your commits are marked as verified.
  • Add the --signoff option to you commits. See the PR's TODO items.
  • Add your new check to the table in docs/source/index.rst. You can run make docs locally to make sure the Sphinx docs compile correctly, and you can check the docs artifact at docs/_build/html/index.html.

@behnazh-w behnazh-w self-requested a review April 21, 2026 05:48
- Add [license] section to defaults.ini with enabled, allowed_licenses, and require_license options
- Add GhAPIClient.get_license() using GitHub REST API endpoint
- Implement LicenseCheck (mcn_license_1) with GitHub API detection and filesystem fallback
- Add unit tests covering all detection and policy scenarios

Fixes oracle#729

Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
@RuchitAgrawal
Copy link
Copy Markdown
Contributor Author

RuchitAgrawal commented Apr 21, 2026

@behnazh-w, thank you for the guidance and feedback! I have added the check to the table and tested locally to ensure make docs compiles properly. I also made sure to verify and sign all my commits.
Please let me know what you think of the updates. It has been a great learning experience for me, and I would love to keep contributing to the organization.

Comment thread src/macaron/config/defaults.ini Outdated
@behnazh-w
Copy link
Copy Markdown
Member

@behnazh-w, thank you for the guidance and feedback! I have added the check to the table and tested locally to ensure make docs compiles properly. I also made sure to verify and sign all my commits. Please let me know what you think of the updates. It has been a great learning experience for me, and I would love to keep contributing to the organization.

That looks good, thanks. I just added a comment about using an allow list vs deny list.

Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
@RuchitAgrawal
Copy link
Copy Markdown
Contributor Author

Thank you for the suggestion. I have updated the implementation to use deny list instead of allowed list for a better license check. I've also updated the tests and docs accordingly. Please let me know if this looks good!

@behnazh-w behnazh-w merged commit ac7be91 into oracle:main Apr 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement license checks in Macaron

3 participants