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

Unused exception warning emitted for optional crate #672

Open
joshtriplett opened this issue Jun 25, 2024 · 0 comments
Open

Unused exception warning emitted for optional crate #672

joshtriplett opened this issue Jun 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@joshtriplett
Copy link

Describe the bug

I have a crate that may depend on either aws-lc-rs or ring, depending on feature flags. I have entries in licenses.exceptions for both:

exceptions = [
    { allow = ["OpenSSL"], name = "aws-lc-sys" },
    { allow = ["OpenSSL"], name = "ring" },
]

However, when I run cargo deny check licenses, I get:

warning[license-exception-not-encountered]: license exception was not encountered
   ┌─ deny.toml:16:36
   │
16 │     { allow = ["OpenSSL"], name = "ring" },
   │                                    ^^^^ unmatched license exception

licenses ok

If I remove that exception, I get no warnings. But if I remove that exception and change my feature flags to default-enable ring, I get an error about ring. So the exception is definitely necessary, and it appears to be a bug both that the exception is seen as unused and that the optional dependency on ring isn't being detected.

To reproduce

cargo new testcrate. Put this in the Cargo.toml manifest:

[package]
name = "testcrate"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[features]
default = ["aws-lc-rs"]
aws-lc-rs = ["rustls-acme/aws-lc-rs"]
ring = ["rustls-acme/ring"]

[dependencies]
rustls-acme = { version = "0.10.1", default-features = false }

Put the following in deny.toml:

[licenses]
version = 2
allow = [
    "Apache-2.0",
    "BSD-3-Clause",
    "ISC",
    "MIT",
    "MPL-2.0",
    "Unicode-DFS-2016",
]
confidence-threshold = 0.8
exceptions = [
    { allow = ["OpenSSL"], name = "aws-lc-sys" },
    { allow = ["OpenSSL"], name = "ring" },
]

[[licenses.clarify]]
name = "ring"
expression = "MIT AND ISC AND OpenSSL"
license-files = [
    { path = "LICENSE", hash = 0xbd0eed23 }
]

Now run cargo deny check licenses, and observe the warning.

cargo-deny version

cargo-deny 0.14.24

What OS were you running cargo-deny on?

Linux

Additional context

No response

@joshtriplett joshtriplett added the bug Something isn't working label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant