In 2021, the developers of the Stockfish chess engine took ChessBase to court. The reason? ChessBase had violated a GNU General Public License (GPL). They used Stockfish’s open-source code in their own product while marketing it as their own, all in violation of the agreement. After years of alleged non-compliance, the Stockfish team sued ChessBase. This led to a high-profile settlement. The result of the case forced ChessBase to remove their offer from the market.

The problem is most applications use some type of external library or code. It’s not that developers are lazy, but we don’t need to reinvent the wheel for every new application. Using open source gives us access to direct solutions to our problems. This leads to an important part of application development: checking installed dependencies’ licenses.

If we don’t do this, we might face a similar situation to ChessBase and face serious legal consequences. This could happen because one of the libraries may have been developed with a restrictive or incompatible license.

How a single package can force you to open-source your code

Imagine a situation where you install a useful package into your application. You’re working for a big company that has just developed a new solution, and everything is ready to go live. But here’s the problem, the library you used is licensed under the GNU General Public License (GPL).

This type of license, while not inherently bad, comes with obligations that might not align with your project’s goals. For example, the GPL requires that any software created from GPL-licensed code, including your own software if it’s considered a derivative work, be made open-source and publicly available. This means your employer could be legally obligated to share the source code of significant parts of your application. This might expose trade secrets or intellectual property.

Why manual checks might save you, but at a cost

Manually reviewing all the packages in your application might sound like a good way to avoid issues. But here’s the catch, applications often rely on hundreds of external libraries. Each of these libraries can pull in additional dependencies without you even realizing it. The number makes manual checks time-consuming and error-prone. It’s easy to miss a package or misinterpret a license.

Plus, even if you manage to complete the review, you’ll need to document your findings in a way that can be referenced later. While manual checks could theoretically save you from trouble, in most cases, they’re impractical. This is especially true for large projects. Could automatic checks be the answer we are looking for?

How do you run an automatic license check?

As is always the case in software, someone has already faced this problem and solved it. There are plenty of tools that check licenses and generate detailed reports. These tools reduce the risk of missing problematic licenses and make it easy to document your findings.

In the Node.js ecosystem, popular dependency managers like npm and Yarn offer solutions to help streamline the process. For instance, Yarn includes the yarn licenses list command. This generates an easy-to-read report of all your dependencies and their licenses.

A screenshot of a Yarn license report generated by Yarn v1.22.19. It displays a tree structure of dependencies categorized by license types. The 'MIT or CC0-1.0' license section includes two versions of the 'type-fest' package, both from Sindre Sorhus, with their respective URLs. The '0BSD' license section includes two versions of the 'tslib' package, authored by Microsoft Corp, with links to GitHub and TypeScript's official site.

If you’re using the npm package manager, there’s no built-in command for license checks. Instead, you’ll need to rely on third-party tools. Here are three of the most popular options:

How to use the license-checker tool for audits

One of the most effective tools for auditing licenses is license-checker. It generates clear, easy-to-read reports of your project’s dependencies and their licenses. To get started, install it globally with npm:

bash
npm install -g license-checker  

Once installed, navigate to your project directory and run:

bash
license-checker  

This will generate a detailed report similar to the output of Yarn’s license-checking tools.

The license-checker tool can also create a summary of your project’s dependencies, grouping them by license type. This is helpful for quickly understanding your application’s licenses. To generate the summary, simply run the following:

A screenshot of a license-checker output listing dependencies, their licenses, and additional metadata. Each entry includes details like the package name, license type, repository URL, publisher information, license file path, and other associated details. Examples include '@ampproject/remapping' licensed under Apache-2.0 and several Angular packages (such as '@angular-devkit/core') and Babel's '@babel/code-frame,' all licensed under MIT
bash
license-checker --summary
A screenshot of a license-checker summary output displaying the distribution of licenses across dependencies. The summary lists license types and their counts, including MIT (526), ISC (45), BSD-3-Clause (22), Apache-2.0 (17), BSD-2-Clause (14), Unlicense (2), 0BSD (2), MIT or CC0-1.0 (2), Python-2.0 (1), CC-BY-4.0 (1), BlueOak-1.0.0 (1), and UNLICENSED (1)

What is a BOM file and why do you need one?

Once you generate a license report, it’s crucial to save it for future reference and share it with your team or employer. A good way to do this is by creating a Bill of Materials (BOM) file, which documents all external package licenses. Generating one is simple: just stream the output of your tool (like license-checker) into a file:

bash
license-checker > BOM.txt

For even better security, consider integrating this step into your CI pipeline to flag unapproved licenses. Additionally, tools like SBOM generators can align with industry standards, such as SPDX, to enhance compliance efforts

Why auditing licenses is non-negotiable

As developers, it’s easy to overlook license audits, especially when juggling tight deadlines. But skipping this step can seriously backfire, not just for you, but for your entire company. While automated tools are essential, they may still require human oversight, especially for interpreting edge cases like dual-licensed dependencies or custom license text.

Take the time to run a license audit on your dependencies, share the results with your team or employer (a BOM file works great for this), and consider automating the process in your CI pipeline. It’s a small effort that can save you a ton of headaches down the line. Don’t let a single overlooked license become the reason your hard work ends up in legal trouble.

5/5 - (1 vote)