From 6e3aacd741b6a344199c8dd324eca6a336cf1abe Mon Sep 17 00:00:00 2001 From: Angela Date: Mon, 14 Oct 2024 08:42:00 +0200 Subject: [PATCH] feat(core): find license in package.json --- biome.json | 14 +- package-lock.json | 164 +------ packages/core/license.d.ts | 6 + packages/core/src/audit-licenses.ts | 7 +- packages/core/src/check-license-status.ts | 2 +- packages/core/src/file-utils.ts | 12 +- packages/core/src/find-license.ts | 10 - .../find-license-in-package-json.ts | 47 ++ .../core/src/license-finder/find-license.ts | 22 + .../src/license-finder/is-valid-license.ts | 8 + packages/core/src/license/blacklist.ts | 442 +++++++++++++++++ packages/core/src/license/licenses.ts | 450 ++++++++++++++++++ packages/core/src/license/whitelist.ts | 34 ++ 13 files changed, 1038 insertions(+), 180 deletions(-) create mode 100644 packages/core/license.d.ts delete mode 100644 packages/core/src/find-license.ts create mode 100644 packages/core/src/license-finder/find-license-in-package-json.ts create mode 100644 packages/core/src/license-finder/find-license.ts create mode 100644 packages/core/src/license-finder/is-valid-license.ts create mode 100644 packages/core/src/license/blacklist.ts create mode 100644 packages/core/src/license/licenses.ts create mode 100644 packages/core/src/license/whitelist.ts diff --git a/biome.json b/biome.json index 0600ddcd..fea4604b 100644 --- a/biome.json +++ b/biome.json @@ -46,5 +46,17 @@ "formatter": { "quoteStyle": "double" } - } + }, + "overrides": [ + { + "include": ["packages/core/**"], + "linter": { + "rules": { + "nursery": { + "useExplicitFunctionReturnType": "error" + } + } + } + } + ] } diff --git a/package-lock.json b/package-lock.json index 832f0505..ab84fb7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -472,18 +472,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -680,31 +668,6 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@license-auditor/eslint-config": { "resolved": "tooling/eslint-config", "link": true @@ -758,30 +721,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true - }, "node_modules/@tsconfig/recommended": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.7.tgz", @@ -822,6 +761,7 @@ "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "dev": true, "license": "MIT", + "optional": true, "dependencies": { "undici-types": "~6.19.2" } @@ -1022,6 +962,7 @@ "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1040,18 +981,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -1125,12 +1054,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1438,12 +1361,6 @@ "typescript": ">=4" } }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1625,15 +1542,6 @@ "node": ">=8" } }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -2837,12 +2745,6 @@ "node": ">=0.10.0" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true - }, "node_modules/merge": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/merge/-/merge-2.1.1.tgz", @@ -3503,49 +3405,6 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, "node_modules/tslib": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", @@ -3688,7 +3547,8 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/universalify": { "version": "2.0.1", @@ -3718,12 +3578,6 @@ "dev": true, "license": "MIT" }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -3786,15 +3640,6 @@ "dev": true, "license": "ISC" }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -3824,7 +3669,6 @@ "devDependencies": { "@license-auditor/eslint-config": "*", "@license-auditor/typescript-config": "*", - "ts-node": "10.9.2", "typescript": "5.6.2" } }, diff --git a/packages/core/license.d.ts b/packages/core/license.d.ts new file mode 100644 index 00000000..bf40faf7 --- /dev/null +++ b/packages/core/license.d.ts @@ -0,0 +1,6 @@ +declare global { + type AvailableLicense = (typeof licenses)[number]; + type License = AvailableLicense | AvailableLicense[] | undefined; +} + +export {}; diff --git a/packages/core/src/audit-licenses.ts b/packages/core/src/audit-licenses.ts index 6129c7b7..ae7a9009 100644 --- a/packages/core/src/audit-licenses.ts +++ b/packages/core/src/audit-licenses.ts @@ -1,12 +1,12 @@ import { checkLicenseStatus, type LicenseStatus } from "./check-license-status"; import { extractPackageName, readPackageJson } from "./file-utils"; -import { findLicense } from "./find-license"; +import { findLicense } from "./license-finder/find-license"; import { getChildDependencies } from "./get-child-dependencies"; interface PackageInfo { package: string; path: string; - license: string | undefined; + license: License; licensePath: string | undefined; status: LicenseStatus; } @@ -28,7 +28,7 @@ function auditLicenses(packagePaths: string[]) { } const packageJson = readPackageJson(packagePath); - const { license, licensePath } = findLicense(packagePath); + const { license, licensePath } = findLicense(packageJson, packagePath); const status = checkLicenseStatus(license); @@ -72,7 +72,6 @@ const packagePaths: string[] = [ "/Users/angelikajeziorska/Documents/projects/license-auditor/node_modules/husky", "/Users/angelikajeziorska/Documents/projects/license-auditor/node_modules/turbo", "/Users/angelikajeziorska/Documents/projects/license-auditor/node_modules/typescript", - "/Users/angelikajeziorska/Documents/projects/license-auditor/node_modules/@license-auditor/eslint-config", "/Users/angelikajeziorska/Documents/projects/license-auditor/node_modules/@total-typescript/ts-reset", ]; diff --git a/packages/core/src/check-license-status.ts b/packages/core/src/check-license-status.ts index 49ccbc84..8004bc45 100644 --- a/packages/core/src/check-license-status.ts +++ b/packages/core/src/check-license-status.ts @@ -1,6 +1,6 @@ export type LicenseStatus = "allowed" | "disallowed" | "unknown"; -export function checkLicenseStatus(license: string | undefined): LicenseStatus { +export function checkLicenseStatus(license: License): LicenseStatus { // todo: compare license with the whitelist/banlist provided through configuration return "allowed"; } diff --git a/packages/core/src/file-utils.ts b/packages/core/src/file-utils.ts index c8d0ac43..538e2985 100644 --- a/packages/core/src/file-utils.ts +++ b/packages/core/src/file-utils.ts @@ -1,19 +1,23 @@ import * as fs from "node:fs"; import * as path from "node:path"; -export function readPackageJson(packagePath: string) { +export function readPackageJson(packagePath: string): object { const packageJsonPath = path.join(packagePath, "package.json"); if (fs.existsSync(packageJsonPath)) { const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8"); - return JSON.parse(packageJsonContent); + const parsedPackageJson = JSON.parse(packageJsonContent); + if (!!parsedPackageJson && typeof parsedPackageJson === "object") { + return parsedPackageJson; + } } - console.warn(`package.json not found for package at ${packageJsonPath}`); + // unsure how often such case happens and whether the license verification should be skipped + throw new Error(`package.json not found for package at ${packagePath}`); } // done this way to avoid reading package.json when checking for an existing value in Map // if it proves unreliable reading package.json will be inevitable -export function extractPackageName(packagePath: string) { +export function extractPackageName(packagePath: string): string { const baseName = path.basename(packagePath); const parentName = path.basename(path.dirname(packagePath)); diff --git a/packages/core/src/find-license.ts b/packages/core/src/find-license.ts deleted file mode 100644 index 0365aef9..00000000 --- a/packages/core/src/find-license.ts +++ /dev/null @@ -1,10 +0,0 @@ -export function findLicense(packagePath: string): { - license: string | undefined; - licensePath: string | undefined; -} { - // todo - find license in: - // - package.json - // - license file - // - readme file - return { license: "MIT", licensePath: "./license.md" }; -} diff --git a/packages/core/src/license-finder/find-license-in-package-json.ts b/packages/core/src/license-finder/find-license-in-package-json.ts new file mode 100644 index 00000000..a864cbc9 --- /dev/null +++ b/packages/core/src/license-finder/find-license-in-package-json.ts @@ -0,0 +1,47 @@ +import { isValidLicense } from "./is-valid-license"; + +function retrieveLicenseFromTypeField(license: unknown): License | undefined { + if ( + typeof license === "object" && + !!license && + "type" in license && + isValidLicense(license.type) + ) { + return license.type; + } +} + +function retrieveLicenseByField( + packageJson: object & Record, + licenseField: T, +): License { + if (typeof packageJson[licenseField] === "string") { + if (isValidLicense(packageJson[licenseField])) { + return packageJson[licenseField]; + } + return; + } + + if (typeof packageJson[licenseField] === "object") { + if (Array.isArray(packageJson[licenseField])) { + return packageJson[licenseField] + .map((l) => { + if (isValidLicense(l)) { + return l; + } + return retrieveLicenseFromTypeField(l); + }) + .filter(Boolean); + } + return retrieveLicenseFromTypeField(packageJson[licenseField]); + } +} + +export function findLicenseInPackageJson(packageJson: object): License { + if ("license" in packageJson) { + return retrieveLicenseByField(packageJson, "license"); + } + if ("licenses" in packageJson) { + return retrieveLicenseByField(packageJson, "licenses"); + } +} diff --git a/packages/core/src/license-finder/find-license.ts b/packages/core/src/license-finder/find-license.ts new file mode 100644 index 00000000..e89d59db --- /dev/null +++ b/packages/core/src/license-finder/find-license.ts @@ -0,0 +1,22 @@ +import * as fs from "node:fs"; +import * as path from "node:path"; +import { findLicenseInPackageJson } from "./find-license-in-package-json"; + +export function findLicense( + packageJson: object, + packagePath: string, +): { + license?: License; + licensePath?: string | undefined; +} { + let license = findLicenseInPackageJson(packageJson); + + if (license) { + return { + license, + licensePath: path.join(packagePath, "package.json"), + }; + } + + return {}; +} diff --git a/packages/core/src/license-finder/is-valid-license.ts b/packages/core/src/license-finder/is-valid-license.ts new file mode 100644 index 00000000..d7cf6275 --- /dev/null +++ b/packages/core/src/license-finder/is-valid-license.ts @@ -0,0 +1,8 @@ +import { licenses } from "../license/licenses"; + +export function isValidLicense(license: unknown): license is License { + if (typeof license !== "string") { + return false; + } + return licenses.includes(license.trim()); +} diff --git a/packages/core/src/license/blacklist.ts b/packages/core/src/license/blacklist.ts new file mode 100644 index 00000000..393de64d --- /dev/null +++ b/packages/core/src/license/blacklist.ts @@ -0,0 +1,442 @@ +/* Provide a list of blacklisted licenses for the project below */ +const blacklist = [ + "UNKNOWN", + "389-exception", + "AAL", + "ADSL", + "AFL-1.1", + "AFL-1.2", + "AFL-2.0", + "AFL-2.1", + "AFL-3.0", + "AGPL-1.0-only", + "AGPL-1.0-or-later", + "AGPL-3.0-only", + "AGPL-3.0-or-later", + "AMDPLPA", + "AML", + "AMPAS", + "ANTLR-PD", + "APAFML", + "APL-1.0", + "APSL-1.0", + "APSL-1.1", + "APSL-1.2", + "APSL-2.0", + "Abstyles", + "Adobe-2006", + "Adobe-Glyph", + "Afmparse", + "Aladdin", + "Apache-1.0", + "Apache-1.1", + "Artistic-1.0-Perl", + "Artistic-1.0-cl8", + "Artistic-1.0", + "Artistic-2.0", + "Autoconf-exception-2.0", + "Autoconf-exception-3.0", + "BSD-1-Clause", + "BSD-2-Clause-FreeBSD", + "BSD-2-Clause-NetBSD", + "BSD-2-Clause-Patent", + "BSD-3-Clause-Attribution", + "BSD-3-Clause-Clear", + "BSD-3-Clause-LBNL", + "BSD-3-Clause-No-Nuclear-License-2014", + "BSD-3-Clause-No-Nuclear-License", + "BSD-3-Clause-No-Nuclear-Warranty", + "BSD-3-Clause-Open-MPI", + "BSD-4-Clause-UC", + "BSD-4-Clause", + "BSD-Protection", + "BSD-Source-Code", + "BSL-1.0", + "Bahyph", + "Barr", + "Beerware", + "Bison-exception-2.2", + "BitTorrent-1.0", + "BitTorrent-1.1", + "BlueOak-1.0.0", + "Bootloader-exception", + "Borceux", + "CATOSL-1.1", + "CC-BY-1.0", + "CC-BY-2.0", + "CC-BY-2.5", + "CC-BY-NC-1.0", + "CC-BY-NC-2.0", + "CC-BY-NC-2.5", + "CC-BY-NC-3.0", + "CC-BY-NC-4.0", + "CC-BY-NC-ND-1.0", + "CC-BY-NC-ND-2.0", + "CC-BY-NC-ND-2.5", + "CC-BY-NC-ND-3.0", + "CC-BY-NC-ND-4.0", + "CC-BY-NC-SA-1.0", + "CC-BY-NC-SA-2.0", + "CC-BY-NC-SA-2.5", + "CC-BY-NC-SA-3.0", + "CC-BY-NC-SA-4.0", + "CC-BY-ND-1.0", + "CC-BY-ND-2.0", + "CC-BY-ND-2.5", + "CC-BY-ND-3.0", + "CC-BY-ND-4.0", + "CC-BY-SA-1.0", + "CC-BY-SA-2.0", + "CC-BY-SA-2.5", + "CC-BY-SA-3.0", + "CC-BY-SA-4.0", + "CC-PDDC", + "CDDL-1.0", + "CDDL-1.1", + "CDLA-Permissive-1.0", + "CDLA-Sharing-1.0", + "CECILL-1.0", + "CECILL-1.1", + "CECILL-2.0", + "CECILL-2.1", + "CECILL-B", + "CECILL-C", + "CERN-OHL-1.1", + "CERN-OHL-1.2", + "CLISP-exception-2.0", + "CNRI-Jython", + "CNRI-Python-GPL-Compatible", + "CNRI-Python", + "CPAL-1.0", + "CPL-1.0", + "CPOL-1.02", + "CUA-OPL-1.0", + "Caldera", + "ClArtistic", + "Classpath-exception-2.0", + "Condor-1.1", + "Crossword", + "CrystalStacker", + "Cube", + "D-FSL-1.0", + "DOC", + "DSDP", + "DigiRule-FOSS-exception", + "Dotseqn", + "ECL-1.0", + "ECL-2.0", + "EFL-1.0", + "EFL-2.0", + "EPL-1.0", + "EPL-2.0", + "EUDatagrid", + "EUPL-1.0", + "EUPL-1.1", + "EUPL-1.2", + "Entessa", + "ErlPL-1.1", + "Eurosym", + "FLTK-exception", + "FSFAP", + "FSFUL", + "FSFULLR", + "FTL", + "Fair", + "Fawkes-Runtime-exception", + "Font-exception-2.0", + "Frameworx-1.0", + "FreeImage", + "GCC-exception-2.0", + "GCC-exception-3.1", + "GFDL-1.1-only", + "GFDL-1.1-or-later", + "GFDL-1.2-only", + "GFDL-1.2-or-later", + "GFDL-1.3-only", + "GFDL-1.3-or-later", + "GL2PS", + "GPL-1.0-only", + "GPL-1.0-or-later", + "GPL-2.0-only", + "GPL-2.0-or-later", + "GPL-3.0-linking-exception", + "GPL-3.0-linking-source-exception", + "GPL-3.0-only", + "GPL-3.0-or-later", + "GPL-CC-1.0", + "Giftware", + "Glide", + "Glulxe", + "HPND-sell-variant", + "HPND", + "HaskellReport", + "IBM-pibs", + "ICU", + "IJG", + "IPA", + "IPL-1.0", + "ImageMagick", + "Imlib2", + "Info-ZIP", + "Intel-ACPI", + "Intel", + "Interbase-1.0", + "JPNIC", + "JSON", + "JasPer-2.0", + "LAL-1.2", + "LAL-1.3", + "LGPL-2.0-only", + "LGPL-2.0-or-later", + "LGPL-2.1-only", + "LGPL-2.1-or-later", + "LGPL-3.0-only", + "LGPL-3.0-or-later", + "LGPLLR", + "LLVM-exception", + "LPL-1.0", + "LPL-1.02", + "LPPL-1.0", + "LPPL-1.1", + "LPPL-1.2", + "LPPL-1.3a", + "LPPL-1.3c", + "LZMA-exception", + "Latex2e", + "Leptonica", + "LiLiQ-P-1.1", + "LiLiQ-R-1.1", + "LiLiQ-Rplus-1.1", + "Libpng", + "Libtool-exception", + "Linux-OpenIB", + "Linux-syscall-note", + "MIT-0", + "MIT-CMU", + "MIT-advertising", + "MIT-enna", + "MIT-feh", + "MITNFA", + "MPL-1.0", + "MPL-1.1", + "MPL-2.0-no-copyleft-exception", + "MPL-2.0", + "MS-PL", + "MS-RL", + "MTLL", + "MakeIndex", + "MirOS", + "Motosoto", + "MulanPSL-1.0", + "Multics", + "Mup", + "NASA-1.3", + "NBPL-1.0", + "NCSA", + "NGPL", + "NLOD-1.0", + "NLPL", + "NOSL", + "NPL-1.0", + "NPL-1.1", + "NPOSL-3.0", + "NRL", + "NTP-0", + "NTP", + "Naumen", + "Net-SNMP", + "NetCDF", + "Newsletr", + "Nokia-Qt-exception-1.1", + "Nokia", + "Noweb", + "OCCT-PL", + "OCCT-exception-1.0", + "OCLC-2.0", + "OCaml-LGPL-linking-exception", + "ODC-By-1.0", + "ODbL-1.0", + "OFL-1.0-RFN", + "OFL-1.0-no-RFN", + "OFL-1.0", + "OFL-1.1-RFN", + "OFL-1.1-no-RFN", + "OFL-1.1", + "OGL-Canada-2.0", + "OGL-UK-1.0", + "OGL-UK-2.0", + "OGL-UK-3.0", + "OGTSL", + "OLDAP-1.1", + "OLDAP-1.2", + "OLDAP-1.3", + "OLDAP-1.4", + "OLDAP-2.0.1", + "OLDAP-2.0", + "OLDAP-2.1", + "OLDAP-2.2.1", + "OLDAP-2.2.2", + "OLDAP-2.2", + "OLDAP-2.3", + "OLDAP-2.4", + "OLDAP-2.5", + "OLDAP-2.6", + "OLDAP-2.7", + "OLDAP-2.8", + "OML", + "OPL-1.0", + "OSET-PL-2.1", + "OSL-1.0", + "OSL-1.1", + "OSL-2.0", + "OSL-2.1", + "OSL-3.0", + "OpenJDK-assembly-exception-1.0", + "OpenSSL", + "PDDL-1.0", + "PHP-3.0", + "PHP-3.01", + "PS-or-PDF-font-exception-20170817", + "PSF-2.0", + "Parity-6.0.0", + "Plexus", + "PostgreSQL", + "Python-2.0", + "QPL-1.0", + "Qhull", + "Qt-GPL-exception-1.0", + "Qt-LGPL-exception-1.1", + "Qwt-exception-1.0", + "RHeCos-1.1", + "RPL-1.1", + "RPL-1.5", + "RPSL-1.0", + "RSA-MD", + "RSCPL", + "Rdisc", + "Ruby", + "SAX-PD", + "SCEA", + "SGI-B-1.0", + "SGI-B-1.1", + "SGI-B-2.0", + "SHL-0.5", + "SHL-0.51", + "SISSL-1.2", + "SISSL", + "SMLNJ", + "SMPPL", + "SNIA", + "SPL-1.0", + "SSH-OpenSSH", + "SSH-short", + "SSPL-1.0", + "SWL", + "Saxpath", + "Sendmail-8.23", + "Sendmail", + "SimPL-2.0", + "Sleepycat", + "Spencer-86", + "Spencer-94", + "Spencer-99", + "SugarCRM-1.1.3", + "Swift-exception", + "TAPR-OHL-1.0", + "TCL", + "TCP-wrappers", + "TMate", + "TORQUE-1.1", + "TOSL", + "TU-Berlin-1.0", + "TU-Berlin-2.0", + "UCL-1.0", + "UPL-1.0", + "Unicode-DFS-2015", + "Unicode-DFS-2016", + "Unicode-TOU", + "Universal-FOSS-exception-1.0", + "VOSTROM", + "VSL-1.0", + "Vim", + "W3C-19980720", + "W3C-20150513", + "W3C", + "Watcom-1.0", + "Wsuipa", + "WxWindows-exception-3.1", + "X11", + "XFree86-1.1", + "XSkat", + "Xerox", + "Xnet", + "YPL-1.0", + "YPL-1.1", + "ZPL-1.1", + "ZPL-2.0", + "ZPL-2.1", + "Zed", + "Zend-2.0", + "Zimbra-1.3", + "Zimbra-1.4", + "blessing", + "bzip2-1.0.5", + "bzip2-1.0.6", + "copyleft-next-0.3.0", + "copyleft-next-0.3.1", + "curl", + "deprecated_AGPL-1.0", + "deprecated_AGPL-3.0", + "deprecated_GFDL-1.1", + "deprecated_GFDL-1.2", + "deprecated_GFDL-1.3", + "deprecated_GPL-1.0+", + "deprecated_GPL-1.0", + "deprecated_GPL-2.0+", + "deprecated_GPL-2.0-with-GCC-exception", + "deprecated_GPL-2.0-with-autoconf-exception", + "deprecated_GPL-2.0-with-bison-exception", + "deprecated_GPL-2.0-with-classpath-exception", + "deprecated_GPL-2.0-with-font-exception", + "deprecated_GPL-2.0", + "deprecated_GPL-3.0+", + "deprecated_GPL-3.0-with-GCC-exception", + "deprecated_GPL-3.0-with-autoconf-exception", + "deprecated_GPL-3.0", + "deprecated_LGPL-2.0+", + "deprecated_LGPL-2.0", + "deprecated_LGPL-2.1+", + "deprecated_LGPL-2.1", + "deprecated_LGPL-3.0+", + "deprecated_LGPL-3.0", + "deprecated_Nunit", + "deprecated_StandardML-NJ", + "deprecated_eCos-2.0", + "deprecated_wxWindows", + "diffmark", + "dvipdfm", + "eCos-exception-2.0", + "eGenix", + "etalab-2.0", + "freertos-exception-2.0", + "gSOAP-1.3b", + "gnu-javamail-exception", + "gnuplot", + "i2p-gpl-java-exception", + "iMatix", + "libpng-2.0", + "libselinux-1.0", + "libtiff", + "mif-exception", + "mpich2", + "openvpn-openssl-exception", + "psfrag", + "psutils", + "u-boot-exception-2.0", + "xinetd", + "xpp", + "zlib-acknowledgement", + "UNLICENSED", +] as const; + +module.exports = blacklist; diff --git a/packages/core/src/license/licenses.ts b/packages/core/src/license/licenses.ts new file mode 100644 index 00000000..8d5b159d --- /dev/null +++ b/packages/core/src/license/licenses.ts @@ -0,0 +1,450 @@ +// eslint-disable-next-line no-unused-vars +export const licenses = [ + "0BSD", + "389-exception", + "AAL", + "ADSL", + "AFL-1.1", + "AFL-1.2", + "AFL-2.0", + "AFL-2.1", + "AFL-3.0", + "AGPL-1.0-only", + "AGPL-1.0-or-later", + "AGPL-3.0-only", + "AGPL-3.0-or-later", + "AMDPLPA", + "AML", + "AMPAS", + "ANTLR-PD", + "APAFML", + "APL-1.0", + "APSL-1.0", + "APSL-1.1", + "APSL-1.2", + "APSL-2.0", + "Abstyles", + "Adobe-2006", + "Adobe-Glyph", + "Afmparse", + "Aladdin", + "Apache-1.0", + "Apache-1.1", + "Apache-2.0", + "Artistic-1.0-Perl", + "Artistic-1.0-cl8", + "Artistic-1.0", + "Artistic-2.0", + "Autoconf-exception-2.0", + "Autoconf-exception-3.0", + "BSD-1-Clause", + "BSD-2-Clause-FreeBSD", + "BSD-2-Clause-NetBSD", + "BSD-2-Clause-Patent", + "BSD-2-Clause", + "BSD-3-Clause-Attribution", + "BSD-3-Clause-Clear", + "BSD-3-Clause-LBNL", + "BSD-3-Clause-No-Nuclear-License-2014", + "BSD-3-Clause-No-Nuclear-License", + "BSD-3-Clause-No-Nuclear-Warranty", + "BSD-3-Clause-Open-MPI", + "BSD-3-Clause", + "BSD-4-Clause-UC", + "BSD-4-Clause", + "BSD-Protection", + "BSD-Source-Code", + "BSL-1.0", + "Bahyph", + "Barr", + "Beerware", + "Bison-exception-2.2", + "BitTorrent-1.0", + "BitTorrent-1.1", + "BlueOak-1.0.0", + "Bootloader-exception", + "Borceux", + "CATOSL-1.1", + "CC-BY-1.0", + "CC-BY-2.0", + "CC-BY-2.5", + "CC-BY-3.0", + "CC-BY-4.0", + "CC-BY-NC-1.0", + "CC-BY-NC-2.0", + "CC-BY-NC-2.5", + "CC-BY-NC-3.0", + "CC-BY-NC-4.0", + "CC-BY-NC-ND-1.0", + "CC-BY-NC-ND-2.0", + "CC-BY-NC-ND-2.5", + "CC-BY-NC-ND-3.0", + "CC-BY-NC-ND-4.0", + "CC-BY-NC-SA-1.0", + "CC-BY-NC-SA-2.0", + "CC-BY-NC-SA-2.5", + "CC-BY-NC-SA-3.0", + "CC-BY-NC-SA-4.0", + "CC-BY-ND-1.0", + "CC-BY-ND-2.0", + "CC-BY-ND-2.5", + "CC-BY-ND-3.0", + "CC-BY-ND-4.0", + "CC-BY-SA-1.0", + "CC-BY-SA-2.0", + "CC-BY-SA-2.5", + "CC-BY-SA-3.0", + "CC-BY-SA-4.0", + "CC-PDDC", + "CC0-1.0", + "CDDL-1.0", + "CDDL-1.1", + "CDLA-Permissive-1.0", + "CDLA-Sharing-1.0", + "CECILL-1.0", + "CECILL-1.1", + "CECILL-2.0", + "CECILL-2.1", + "CECILL-B", + "CECILL-C", + "CERN-OHL-1.1", + "CERN-OHL-1.2", + "CLISP-exception-2.0", + "CNRI-Jython", + "CNRI-Python-GPL-Compatible", + "CNRI-Python", + "CPAL-1.0", + "CPL-1.0", + "CPOL-1.02", + "CUA-OPL-1.0", + "Caldera", + "ClArtistic", + "Classpath-exception-2.0", + "Condor-1.1", + "Crossword", + "CrystalStacker", + "Cube", + "D-FSL-1.0", + "DOC", + "DSDP", + "DigiRule-FOSS-exception", + "Dotseqn", + "ECL-1.0", + "ECL-2.0", + "EFL-1.0", + "EFL-2.0", + "EPL-1.0", + "EPL-2.0", + "EUDatagrid", + "EUPL-1.0", + "EUPL-1.1", + "EUPL-1.2", + "Entessa", + "ErlPL-1.1", + "Eurosym", + "FLTK-exception", + "FSFAP", + "FSFUL", + "FSFULLR", + "FTL", + "Fair", + "Fawkes-Runtime-exception", + "Font-exception-2.0", + "Frameworx-1.0", + "FreeImage", + "GCC-exception-2.0", + "GCC-exception-3.1", + "GFDL-1.1-only", + "GFDL-1.1-or-later", + "GFDL-1.2-only", + "GFDL-1.2-or-later", + "GFDL-1.3-only", + "GFDL-1.3-or-later", + "GL2PS", + "GPL-1.0-only", + "GPL-1.0-or-later", + "GPL-2.0-only", + "GPL-2.0-or-later", + "GPL-3.0-linking-exception", + "GPL-3.0-linking-source-exception", + "GPL-3.0-only", + "GPL-3.0-or-later", + "GPL-CC-1.0", + "Giftware", + "Glide", + "Glulxe", + "HPND-sell-variant", + "HPND", + "HaskellReport", + "IBM-pibs", + "ICU", + "IJG", + "IPA", + "IPL-1.0", + "ISC", + "ImageMagick", + "Imlib2", + "Info-ZIP", + "Intel-ACPI", + "Intel", + "Interbase-1.0", + "JPNIC", + "JSON", + "JasPer-2.0", + "LAL-1.2", + "LAL-1.3", + "LGPL-2.0-only", + "LGPL-2.0-or-later", + "LGPL-2.1-only", + "LGPL-2.1-or-later", + "LGPL-3.0-only", + "LGPL-3.0-or-later", + "LGPLLR", + "LLVM-exception", + "LPL-1.0", + "LPL-1.02", + "LPPL-1.0", + "LPPL-1.1", + "LPPL-1.2", + "LPPL-1.3a", + "LPPL-1.3c", + "LZMA-exception", + "Latex2e", + "Leptonica", + "LiLiQ-P-1.1", + "LiLiQ-R-1.1", + "LiLiQ-Rplus-1.1", + "Libpng", + "Libtool-exception", + "Linux-OpenIB", + "Linux-syscall-note", + "MIT-0", + "MIT-CMU", + "MIT-advertising", + "MIT-enna", + "MIT-feh", + "MIT", + "MITNFA", + "MPL-1.0", + "MPL-1.1", + "MPL-2.0-no-copyleft-exception", + "MPL-2.0", + "MS-PL", + "MS-RL", + "MTLL", + "MakeIndex", + "MirOS", + "Motosoto", + "MulanPSL-1.0", + "Multics", + "Mup", + "NASA-1.3", + "NBPL-1.0", + "NCSA", + "NGPL", + "NLOD-1.0", + "NLPL", + "NOSL", + "NPL-1.0", + "NPL-1.1", + "NPOSL-3.0", + "NRL", + "NTP-0", + "NTP", + "Naumen", + "Net-SNMP", + "NetCDF", + "Newsletr", + "Nokia-Qt-exception-1.1", + "Nokia", + "Noweb", + "OCCT-PL", + "OCCT-exception-1.0", + "OCLC-2.0", + "OCaml-LGPL-linking-exception", + "ODC-By-1.0", + "ODbL-1.0", + "OFL-1.0-RFN", + "OFL-1.0-no-RFN", + "OFL-1.0", + "OFL-1.1-RFN", + "OFL-1.1-no-RFN", + "OFL-1.1", + "OGL-Canada-2.0", + "OGL-UK-1.0", + "OGL-UK-2.0", + "OGL-UK-3.0", + "OGTSL", + "OLDAP-1.1", + "OLDAP-1.2", + "OLDAP-1.3", + "OLDAP-1.4", + "OLDAP-2.0.1", + "OLDAP-2.0", + "OLDAP-2.1", + "OLDAP-2.2.1", + "OLDAP-2.2.2", + "OLDAP-2.2", + "OLDAP-2.3", + "OLDAP-2.4", + "OLDAP-2.5", + "OLDAP-2.6", + "OLDAP-2.7", + "OLDAP-2.8", + "OML", + "OPL-1.0", + "OSET-PL-2.1", + "OSL-1.0", + "OSL-1.1", + "OSL-2.0", + "OSL-2.1", + "OSL-3.0", + "OpenJDK-assembly-exception-1.0", + "OpenSSL", + "PDDL-1.0", + "PHP-3.0", + "PHP-3.01", + "PS-or-PDF-font-exception-20170817", + "PSF-2.0", + "Parity-6.0.0", + "Plexus", + "PostgreSQL", + "Python-2.0", + "QPL-1.0", + "Qhull", + "Qt-GPL-exception-1.0", + "Qt-LGPL-exception-1.1", + "Qwt-exception-1.0", + "RHeCos-1.1", + "RPL-1.1", + "RPL-1.5", + "RPSL-1.0", + "RSA-MD", + "RSCPL", + "Rdisc", + "Ruby", + "SAX-PD", + "SCEA", + "SGI-B-1.0", + "SGI-B-1.1", + "SGI-B-2.0", + "SHL-0.5", + "SHL-0.51", + "SISSL-1.2", + "SISSL", + "SMLNJ", + "SMPPL", + "SNIA", + "SPL-1.0", + "SSH-OpenSSH", + "SSH-short", + "SSPL-1.0", + "SWL", + "Saxpath", + "Sendmail-8.23", + "Sendmail", + "SimPL-2.0", + "Sleepycat", + "Spencer-86", + "Spencer-94", + "Spencer-99", + "SugarCRM-1.1.3", + "Swift-exception", + "TAPR-OHL-1.0", + "TCL", + "TCP-wrappers", + "TMate", + "TORQUE-1.1", + "TOSL", + "TU-Berlin-1.0", + "TU-Berlin-2.0", + "UCL-1.0", + "UPL-1.0", + "Unicode-DFS-2015", + "Unicode-DFS-2016", + "Unicode-TOU", + "Universal-FOSS-exception-1.0", + "Unlicense", + "VOSTROM", + "VSL-1.0", + "Vim", + "W3C-19980720", + "W3C-20150513", + "W3C", + "WTFPL", + "Watcom-1.0", + "Wsuipa", + "WxWindows-exception-3.1", + "X11", + "XFree86-1.1", + "XSkat", + "Xerox", + "Xnet", + "YPL-1.0", + "YPL-1.1", + "ZPL-1.1", + "ZPL-2.0", + "ZPL-2.1", + "Zed", + "Zend-2.0", + "Zimbra-1.3", + "Zimbra-1.4", + "Zlib", + "blessing", + "bzip2-1.0.5", + "bzip2-1.0.6", + "copyleft-next-0.3.0", + "copyleft-next-0.3.1", + "curl", + "deprecated_AGPL-1.0", + "deprecated_AGPL-3.0", + "deprecated_GFDL-1.1", + "deprecated_GFDL-1.2", + "deprecated_GFDL-1.3", + "deprecated_GPL-1.0+", + "deprecated_GPL-1.0", + "deprecated_GPL-2.0+", + "deprecated_GPL-2.0-with-GCC-exception", + "deprecated_GPL-2.0-with-autoconf-exception", + "deprecated_GPL-2.0-with-bison-exception", + "deprecated_GPL-2.0-with-classpath-exception", + "deprecated_GPL-2.0-with-font-exception", + "deprecated_GPL-2.0", + "deprecated_GPL-3.0+", + "deprecated_GPL-3.0-with-GCC-exception", + "deprecated_GPL-3.0-with-autoconf-exception", + "deprecated_GPL-3.0", + "deprecated_LGPL-2.0+", + "deprecated_LGPL-2.0", + "deprecated_LGPL-2.1+", + "deprecated_LGPL-2.1", + "deprecated_LGPL-3.0+", + "deprecated_LGPL-3.0", + "deprecated_Nunit", + "deprecated_StandardML-NJ", + "deprecated_eCos-2.0", + "deprecated_wxWindows", + "diffmark", + "dvipdfm", + "eCos-exception-2.0", + "eGenix", + "etalab-2.0", + "freertos-exception-2.0", + "gSOAP-1.3b", + "gnu-javamail-exception", + "gnuplot", + "i2p-gpl-java-exception", + "iMatix", + "libpng-2.0", + "libselinux-1.0", + "libtiff", + "mif-exception", + "mpich2", + "openvpn-openssl-exception", + "psfrag", + "psutils", + "u-boot-exception-2.0", + "xinetd", + "xpp", + "zlib-acknowledgement", +] as const; diff --git a/packages/core/src/license/whitelist.ts b/packages/core/src/license/whitelist.ts new file mode 100644 index 00000000..bdffd6cb --- /dev/null +++ b/packages/core/src/license/whitelist.ts @@ -0,0 +1,34 @@ +/* Provide a list of whitelisted licenses for the project below */ +const whitelist = [ + "(Apache-2.0 OR MPL-1.1)", + "(BSD-2-Clause OR WTFPL)", + "(CC-BY-4.0 AND MIT)", + "(MIT AND BSD-3-Clause)", + "(MIT AND CC-BY-3.0)", + "(MIT AND Zlib)", + "(MIT OR Apache-2.0)", + "(MIT OR CC0-1.0)", + "(Unlicense OR Apache-2.0)", + "(WTFPL OR MIT)", + "0BSD", + "AFLv2.1", + "Apache 2.0", + "Apache License, Version 2.0", + "Apache-2.0", + "Apache2", + "BSD-2-Clause", + "BSD-3-Clause OR MIT", + "BSD-3-Clause", + "CC-BY-3.0", + "CC-BY-4.0", + "CC0-1.0", + "ISC", + "MIT", + "MIT,Apache2", + "MPL-1.1", + "Unlicense", + "WTFPL", + "Zlib", +] as const; + +module.exports = whitelist;