The licenses check is used to verify that every crate you use has license terms you find acceptable. cargo-deny does this by evaluating the license requirements specified by each crate against the configuration you‘ve specified, to determine if your project meets that crate’s license requirements.
cargo deny check licenses
cargo-deny uses SPDX license expressions to interpret the license requirements of a crate. In the event that it cannot obtain an SPDX license expression directly from metadata, it tries to derive such within the confidence threshold you specify. Note that cargo-deny currently does not exhaustively search the entirety of the source code of every crate to find every possible license that could be attributed to the crate. There are many edge cases to that approach, and human ingenuity, or even human error, can always outwit a statically-compiled program.
cargo-deny makes a good-faith assumption each crate correctly defines its license requirements. In the (in our experience, rare) circumstance such data cannot be gathered automatically, it provides a mechanism for manually specifying the license requirements for crates.
The source of the SPDX expression used to evaluate the crate's licensing requirement is obtained in the following order:
license
field from the crate's Cargo.toml manifest will be used if it exists.license-file
field, as well as all other LICENSE(-*)?
files will be parsed to determine the SPDX license identifier, and then all of those identifiers will be joined with the AND
operator, meaning that you must accept all of the licenses detected.Importantly, this precedence, combined with the trust that licensing data is handled correctly, means the following edge cases are not handled. This is not an exhaustive list, but are rather a sample of the kinds of things a program is not able to completely prevent, even if more checks are added:
LICENSE
. There is no guarantee such placements inside a package would lose their legal force, even if there is other licensing data that cargo-deny may detect first and assume is comprehensive.Currently, the precedence for determining whether a particular license is accepted or rejected is as follows:
deny
list is always rejected.allow
list is always accepted.[licenses.copyleft]
configuration determines its status[licenses.allow-osi-fsf-free]
configuration determines its status, if it is neither
the check continues[licenses.default]
configuration determines its status