Skip to content

fix(cargo-deny): run dependency license checks in CI, clarify inaccurate licenses - #3299

Closed
dannycjones wants to merge 4 commits into
apache:mainfrom
dannycjones:add-cargo-deny-ci-check
Closed

dannycjones wants to merge 4 commits into
apache:mainfrom
dannycjones:add-cargo-deny-ci-check

Conversation

@dannycjones

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

This is also part of a few changes related to #3239.

What changes are included in this PR?

A new Python script is introduced for handling licenses. In this change, the existing cargo-deny check is moved from the Bash script to this new script, paving the way for further script commands that tackle generation of distribution notices for the compiled Python bindings.

In addition, some dependencies whose declared license doesn't match the effective license have been clarified using the config in deny.toml. There is no impact, just an improvement to ensure it is correctly evaluated.

Are these changes tested?

No. However, the new checks will run against this and future PRs.

AI Disclosure

Used LLM to generate the script content, which is later reviewed, restructured, and otherwise modified by me. Also relied on LLM to dive deep and identify any inaccurate licenses that have now been verified by me and clarified in config.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new script advertises Python 3.11 support but contains Python 3.12-only syntax.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds CI enforcement for dependency licenses and clarifies effective licenses for bundled dependencies.

Changes:

  • Introduces a Python license-checking CLI.
  • Adds cargo-deny checks to CI.
  • Separates dependency TSV generation from source license checks.
File Description
.github/​workflows/​ci.yml Runs dependency license validation in CI.
Makefile Renames the source license target.
deny.toml Clarifies zstd and Brotli licensing.
dev/​check_src_license_notice.sh Validates packaged LICENSE and NOTICE files.
dev/​release/​licenses.py Implements license checks and hash generation.
dev/​release/​generate-dependency-tsv-files.sh Focuses the script on TSV generation.
dev/​release/​README.md Updates release commands.
website/​src/​release.md Updates public release instructions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread dev/release/licenses.py Resolved
Comment thread dev/release/licenses.py Resolved
@dannycjones
dannycjones force-pushed the add-cargo-deny-ci-check branch from 91b30c0 to 5de2d26 Compare September 29, 2026 16:19
@dannycjones
dannycjones force-pushed the add-cargo-deny-ci-check branch from 5de2d26 to cc209f4 Compare September 29, 2026 16:34
@dannycjones

Copy link
Copy Markdown
Contributor Author

@kevinjqliu @CTTY would you be able to take a look at this change? Ultimately, this is on the path to unblock 0.11 release. (I plan to add attribution note generation to the Python script introduced here)

Note, there's a similar change adding cargo-deny to CI in #3293. I think there's some good/needed changes in there, although I think we should move to the new Python script this PR proposed.

Comment thread deny.toml Outdated
# However, it also includes vendored Zstandard C sources.
[[licenses.clarify]]
crate = "zstd-sys"
# TODO: When workspace upgrades to zstd-sys 2.1 or later,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe we can have a GH issue for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll open one and link to it. That being said, I'm not convinced issues are great for things like this as they tend to go stale at the moment. (Maybe I should be more optimistic!)

@comphead comphead left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

perhaps we can document how to ignore files?

Comment thread deny.toml Outdated
expression = "BSD-3-Clause AND MIT"
license-files = [
{ path = "LICENSE", hash = 0x1a60a92d }, # BSD-3-Clause
# Missing: MIT license, since no license text is included in the crate's repo.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not sure why this comment is here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With the license-files section, I want to relate the file back to the expression I've written above. The license files prove that the new license expression is correct.

I'm asserting above that the license is BSD-3-Clause AND MIT, so it feels odd to link only to the BSD-3-Clause license. I am explaining why the MIT license is missing.

I can reword to something like this.

# Missing: crate is MIT licensed but has no license text to refer to.
# This means if the project drops the MIT license, we wouldn't know to update expression above.

Comment thread Makefile Resolved
Comment thread deny.toml Outdated
{ path = "zstd/COPYING", hash = 0xeaa66bfd },
]

# The declared license is inaccurate, as the crate src includes both MIT and BSD-3-Clause licensed code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we really need this comment? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is probably too much info.

I'll update it to simply refer to the upstream PR, which has the necessary context.

@comphead comphead left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @dannycjones it mostly LGTM, couple of nits.
Wondering how this has been tested?

@dannycjones

Copy link
Copy Markdown
Contributor Author

Thanks @dannycjones it mostly LGTM, couple of nits. Wondering how this has been tested?

I've been testing by manually (with LLM) running this scenario, which includes:

  • a bad hash
  • a stale file entry
  • a stale clarification - crate is no longer used

Applying this patch over the deny.toml.

diff --git a/deny.toml b/deny.toml
index 7f4b2a7c8..ad346cd13 100644
--- a/deny.toml
+++ b/deny.toml
@@ -50,11 +50,13 @@ expression = "(MIT OR Apache-2.0) AND BSD-3-Clause AND (GPL-2.0-only OR BSD-3-Cl
 license-files = [
   { path = "LICENSE.Apache-2.0", hash = 0x7b466be4 },
   { path = "LICENSE.Mit", hash = 0xa237d234 },
+  # A file that was removed upstream but is still attested here.
+  { path = "LICENSE.Apache", hash = 0xbadbad04 },
   { path = "LICENSE.BSD-3-Clause", hash = 0xc9f5c4f6 },
   # BSD-3-Clause of vendored zstd src
   { path = "zstd/LICENSE", hash = 0x3bfe1fb1 },
   # GPL-2.0-only of vendored zstd src
-  { path = "zstd/COPYING", hash = 0xeaa66bfd },
+  { path = "zstd/COPYING", hash = 0xbadbad01 },
 ]
 
 # Mapped from OR to AND. The following PR should address upstream.
@@ -63,7 +65,15 @@ license-files = [
 crate = "brotli-decompressor"
 expression = "BSD-3-Clause AND MIT"
 license-files = [
-  { path = "LICENSE", hash = 0x1a60a92d }, # BSD-3-Clause
+  { path = "LICENSE", hash = 0xbadbad02 }, # BSD-3-Clause
   # Missing: crate is MIT licensed but has no license text to refer to.
   # If the project drops the MIT licensing, we wouldn't know to update expression above.
 ]
+
+# A dependency that was dropped, but whose clarification was left behind.
+[[licenses.clarify]]
+crate = "openssl-sys"
+expression = "Apache-2.0"
+license-files = [
+  { path = "LICENSE", hash = 0xbadbad03 },
+]

Basically checking that addressing each one gets us back to the toml that will be merged into main.

I'm not super happy with it being manual tests but I don't think its worth investing more here right now.

@dannycjones

Copy link
Copy Markdown
Contributor Author

perhaps we can document how to ignore files?

I don't follow. Are you referring to ignoring files that cargo-deny suspects may be a license but it can't classify?

I'm not actually sure how we'd navigate that one right now - I suspect we'd need to add a clarify block to specify the files to care about, so the misclassified one is dropped. I'm inclined to leave it until we encounter it for now.

@dannycjones

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @comphead. I've addressed most of the feedback.

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for the changes. I think it'll be a good idea to split this up into multiple prs. with infra level changes, i prefer the changes and prs to be self documenting.

I think we can do a few prs

  • remove DEPENDENCIES.rust.tsv and its related infra. we mentioned to do this in #3233
  • Add cargo deny to CI
  • Fix / improve the release process

Comment thread deny.toml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i need to triple check these changes

Comment thread dev/release/README.md
## Dependencies

Use the dependency helper to update or verify dependency license lists:
Regenerate each package's `DEPENDENCIES.rust.tsv`:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we just remove all the DEPENDENCIES.rust.tsv and related infra?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, might make things simpler. I'll open that PR today and also put a note to the mailing list that its happening. We can revert if there's push back.

@kevinjqliu

Copy link
Copy Markdown
Contributor

i also noticed #3293, maybe we can use that PR as the "Add cargo deny to CI" part

@dannycjones

Copy link
Copy Markdown
Contributor Author

i also noticed #3293, maybe we can use that PR as the "Add cargo deny to CI" part

I'm happy to do that, I think that makes sense. Let's get that one in, I'll strip out TSVs, then we do migration to Python script then wheel attribution note generation.

@dannycjones
dannycjones marked this pull request as draft October 1, 2026 10:32
@kevinjqliu

Copy link
Copy Markdown
Contributor

do you think this PR is superseded by #3293?

@dannycjones

Copy link
Copy Markdown
Contributor Author

do you think this PR is superseded by #3293?

Ish - I will close this now, I plan to open new ones to a) add clarify notices where appropriate and b) move us to a Python script which I'll build on for the wheel attribution notices.

@dannycjones dannycjones closed this Oct 4, 2026
@dannycjones
dannycjones deleted the add-cargo-deny-ci-check branch October 11, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cargo deny license checks to PRs

4 participants