@dev-build-deploy/reuse-it
v1.0.1
Published
(ReUSE) Copyright and License management library
Maintainers
Readme
ReuseIt - Copyright and License Management Library
Creates an SPDX 2.3 Software Bill of Materials based on the provided files, per ReUSE Software specification.
⚠️ NOTE ⚠️
ReuseIt (and its owner) are not part of a law firm and, as such, the owner nor the application provide legal advise. Using ReuseIt does not constitute legal advice or create an attorney-client relationship.
ReuseIt is created for the aggregation of Copyright and License information provided by the users in the files stored in their repositories. In the end, the users of ReuseIt are responsible for the correctness of the generated Software Bill of Materials, the associated licenses, and attributions. For that reason, ReuseIt is provided on an "as-is" basis and makes no warranties regarding any information or licenses provided on or through it, and disclaims liability for damages resulting from using the application.
Features
- Easy to use
- Create SPDX 2.3 Software Bill of Materials
- Leverage the Reuse Software specification
Basic Usage
import { SoftwareBillOfMaterials } from "@dev-build-deploy/reuse-it";
// Create an empty Software Bill of Materials
const sbom = new SoftwareBillOfMaterials("Example Project", "Example Tool v0");
// Add associated (related) files
await sbom.addFile("src/spdx/sbom.ts");
// Show the results
console.log(JSON.stringify(sbom, null, 2))This will result in an SPDX 2.3 SBoM;
{
"SPDXID": "SPDXRef-DOCUMENT",
"spdxVersion": "SPDX-2.3",
"name": "Example Project",
"documentNamespace": "http://spdx.org/spdxdocs/spdx-v2.3-45eae250-b782-46dd-9723-62ec3bed2a7c",
"dataLicense": "CC0-1.0",
"creationInfo": {
"comment": "Generated by Example Tool v0",
"created": "2023-01-01T00:00:00.000Z",
"creators": [
"Tool: Example Tool v0"
]
},
"relationships": [
{
"spdxElementId": "SPDXRef-DOCUMENT",
"relationshipType": "DESCRIBES",
"relatedSpdxElement": "SPDXRef-26277ea6651754576f3b48212813e2c9c26e7464"
}
],
"files": [
{
"SPDXID": "SPDXRef-26277ea6651754576f3b48212813e2c9c26e7464",
"checksums": [
{
"algorithm": "SHA1",
"checksumValue": "f3c1801706f6f76e15a999e0f44389087dc44ab7"
}
],
"copyrightText": "2023 Kevin de Jong <[email protected]>",
"fileContributors": [],
"fileName": "./src/spdx/sbom.ts",
"fileTypes": [],
"licenseConcluded": "NOASSERTION",
"licenseInfoInFiles": [
"MIT"
],
"attributionTexts": []
}
]
}Basic guidelines
Adding licensing and copyright information to your file
Per the ReUSE Software specification, you can cover your files with the following approaches:
- Adding a comment header in your files;
SPDX-FileCopyrightText: 2023 Kevin de Jong <[email protected]>
SPDX-License-Identifier: MIT- Adding a
.licensefile next to your (binary) files; it takes precedence over the file's own comment header - Using a REUSE.toml file to cover many files at once
- Using DEP5 (
.reuse/dep5, deprecated in favour ofREUSE.toml)
Please refer to the Reuse specification for more details.
How the sources are combined
ReuseIt follows the order of precedence of the Reuse specification (3.3):
| Source | How it combines with the file's own information |
| --- | --- |
| .license file | Replaces the file's comment header (the header is then ignored) |
| REUSE.toml, precedence = "closest" (default) | Only fills in what the file lacks, separately for copyright and licence, from the closest REUSE.toml that covers the file |
| REUSE.toml, precedence = "aggregate" | Always added to the file's information |
| REUSE.toml, precedence = "override" | Replaces all information closer to the file; the override table closest to the project root wins |
| .reuse/dep5 Files paragraph | Aggregated: all copyright notices and both licences apply |
Within one REUSE.toml or .reuse/dep5, the last matching table or Files paragraph wins. The header
paragraph of .reuse/dep5 describes the project as a whole and is not applied to files. An SPDX-FileComment in a
REUSE.toml table and a Comment in a dep5 Files paragraph end up in the file's SPDX comment.
REUSE.toml files are looked up in the file's directory and every directory above it, up to the current working
directory (the project root). Files that are not Covered Files are left out of the SBOM: .license files,
REUSE.toml, .reuse/, LICENSES/, COPYING/LICENSE/LICENCE files, symbolic links and empty files.
Checksums are computed over the raw bytes of each file.
Use SPDX File Tags to enrich your Software Bill of Materials
To enrich your SPDX 2.3 SBOM, additional File Tags can be used to add additional information to each file. For example:
SPDX-FileCopyrightText: 2023 Kevin de Jong <[email protected]>
SPDX-FileType: DOCUMENTATION
SPDX-License-Identifier: MIT
SPDX-FileLicenseConcluded: MIT
SPDX-FileLicenseComments: This file is original work of the copyright holder, and therefor the license specified in the file is correct.
SPDX-FileComment: This file is part of the public documentation.
SPDX-FileContributor: Kevin de JongIgnoring false positive matches
In case you run into a false-positive match, you can use the REUSE-IgnoreStart and REUSE-IgnoreEnd tags to ignore snippets.
function foo(bar: string) {
// REUSE-IgnoreStart
if (bar.includes(
"SPDX-FileCopyrightText is important"
)) {
console.log("Ru-roh")
}
// REUSE-IgnoreEnd
}Contributing
If you have suggestions for how reuse-it could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the Contributing Guide.
License
- MIT © 2023 Kevin de Jong <[email protected]>
