All Projects → go-enry → go-license-detector

go-enry / go-license-detector

Licence: other
Reliable project licenses detector.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-license-detector

license-ls
Get a list of licenses used by a projects dependencies
Stars: ✭ 17 (-76.06%)
Mutual labels:  spdx-license, spdx-licenses
example-electron-license-activation
An example of how to implement software licensing and device activation in an Electron application
Stars: ✭ 55 (-22.54%)
Mutual labels:  license-management
Licenseplist
A license list generator of all your dependencies for iOS applications
Stars: ✭ 1,996 (+2711.27%)
Mutual labels:  license-management
java-license-manager
OddSource Code Java License Manager
Stars: ✭ 22 (-69.01%)
Mutual labels:  license-management
Glpi
GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
Stars: ✭ 2,278 (+3108.45%)
Mutual labels:  license-management
sonarqube-licensecheck
SonarQube Licensecheck Plugin
Stars: ✭ 122 (+71.83%)
Mutual labels:  license-management
Dephell
📦 🔥 Python project management. Manage packages: convert between formats, lock, install, resolve, isolate, test, build graph, show outdated, audit. Manage venvs, build package, bump version.
Stars: ✭ 1,730 (+2336.62%)
Mutual labels:  license-management
UnityAutomaticLicensor
This project has moved to GitLab: https://gitlab.com/redpointgames/UnityAutomaticLicensor
Stars: ✭ 16 (-77.46%)
Mutual labels:  license-management
SimpleLicensing
A Go Based Licensing System for Digital Rights Management
Stars: ✭ 96 (+35.21%)
Mutual labels:  license-management
license-checker-php
CLI tool to verify used licenses in composer dependencies
Stars: ✭ 28 (-60.56%)
Mutual labels:  license-management
Licenseclassifier
A License Classifier
Stars: ✭ 180 (+153.52%)
Mutual labels:  license-management
Licensed
⚖️ ✔️ licensed is an interactive command line tool to help you choose and add licenses to your projects
Stars: ✭ 220 (+209.86%)
Mutual labels:  license-management
license-compatibility
©️ Check compatibility between different SPDX licenses
Stars: ✭ 31 (-56.34%)
Mutual labels:  spdx-licenses
Npm License Crawler
Analyzes license information for multiple node.js modules (package.json files) as part of your software project.
Stars: ✭ 168 (+136.62%)
Mutual labels:  license-management
headroom
©️ Manager for license headers in source code files.
Stars: ✭ 41 (-42.25%)
Mutual labels:  license-management
Gradle License Report
A plugin for generating reports about the licenses of third party software using Gradle
Stars: ✭ 152 (+114.08%)
Mutual labels:  license-management
eslint-plugin-license-header
Rules to validate the presence of license headers in source files.
Stars: ✭ 21 (-70.42%)
Mutual labels:  license-management
license-auditor
License Auditor helps you track and validate licenses inside your project.
Stars: ✭ 15 (-78.87%)
Mutual labels:  license-management
lisense
Sensible repository licensing for Humans
Stars: ✭ 23 (-67.61%)
Mutual labels:  license-management
TrialMaker.Demo
A powerful yet straight-forward library suite that provides secure trial license generation and copy-protection features for .NET applications. It also supports premium license generation for expired free-trials.
Stars: ✭ 21 (-70.42%)
Mutual labels:  license-management

go-license-detector GoDoc Test Go Report Card

Project license detector - a command line application and a library, written in Go. It scans the given directory for license files, normalizes and hashes them and outputs all the fuzzy matches with the list of reference texts. The returned names follow SPDX standard. Read the blog post.

Why? There are no similar projects which can be compiled into a native binary without dependencies and also support the whole SPDX license database (≈400 items). This implementation is also fast, requires little memory, and the API is easy to use.

The license texts are taken directly from license-list-data repository. The detection algorithm is not template matching; this directly implies that go-license-detector does not provide any legal guarantees. The intended area of it's usage is data mining.

Installation

go get github.com/go-enry/go-license-detector/v4/licensedb

The CLI is available for download at the release page.

Algorithm

  1. Find files in the root directory which may represent a license. E.g. LICENSE or license.md.
  2. If the file is Markdown or reStructuredText, render to HTML and then convert to plain text. Original HTML files are also converted.
  3. Normalize the text according to SPDX recommendations.
  4. Split the text into unigrams and build the weighted bag of words.
  5. Calculate Weighted MinHash.
  6. Apply Locality Sensitive Hashing and pick the reference licenses which are close.
  7. For each of the candidate, calculate the Levenshtein distance - D. the corresponding text is the single line with each unigram represented by a single rune (character).
  8. Set the similarity as 1 - D / L where L is the number of unigrams in the quieried license.

This pipeline guarantees constant time queries, though requires some initialization to preprocess the reference licenses.

If there are not license files found:

  1. Look for README files.
  2. If the file is Markdown or reStructuredText, render to HTML and then convert to plain text. Original HTML files are also converted.
  3. Scan for words like "copyright", "license" and "released under". Take the neighborhood.
  4. Run Named Entity Recognition (NER) over that surrounding context and extract the possible license name.
  5. Match it against the list of license names from SPDX.

Usage

Command line:

license-detector /path/to/project
license-detector https://github.com/go-git/go-git

Library (for a single license detection):

import (
    "github.com/go-enry/go-license-detector/v4/licensedb"
    "github.com/go-enry/go-license-detector/v4/licensedb/filer"
)

func main() {
	licenses, err := licensedb.Detect(filer.FromDirectory("/path/to/project"))
}

Library (for a convenient data structure that can be formatted as JSON):

import (
	"encoding/json"
	"fmt"

	"github.com/go-enry/go-license-detector/v4/licensedb"
)

func main() {
	results := licensedb.Analyse("/path/to/project1", "/path/to/project2")
	bytes, err := json.MarshalIndent(results, "", "\t")
	if err != nil {
		fmt.Printf("could not encode result to JSON: %v\n", err)
	}
	fmt.Println(string(bytes))
}

Quality

On the dataset of ~1000 most starred repositories on GitHub as of early February 2018 (list), 99% of the licenses are detected. The analysis of detection failures is going in FAILURES.md.

Comparison to other projects on that dataset:

Detector Detection rate Time to scan, sec
go-license-detector 99% (897/902) 13.5
benbalter/licensee 75% (673/902) 111
google/licenseclassifier 76% (682/902) 907
boyter/lc 88% (797/902) 548
amzn/askalono 87% (785/902) 165
LiD 94% (847/902) 3660
How this was measured
$ cd $(go env GOPATH)/src/github.com/go-enry/go-license-detector/v4/licensedb
$ mkdir dataset && cd dataset
$ unzip ../dataset.zip
$ # go-enry/go-license-detector
$ time license-detector * \
  | grep -Pzo '\n[-0-9a-zA-Z]+\n\tno license' | grep -Pa '\tno ' | wc -l
$ # benbalter/licensee
$ time ls -1 | xargs -n1 -P4 licensee \
  | grep -E "^License: Other" | wc -l
$ # google/licenseclassifier
$ time find -type f -print | xargs -n1 -P4 identify_license \
  | cut -d/ -f2 | sort | uniq | wc -l
$ # boyter/lc
$ time lc . \
  | grep -vE 'NOASSERTION|----|Directory' | cut -d" " -f1 | sort | uniq | wc -l
$ # amzn/askalono
$ echo '#!/bin/sh
result=$(askalono id "$1")
echo "$1
$result"' > ../askalono.wrapper
$ time find -type f -print | xargs -n1 -P4 sh ../askalono.wrapper | grep -Pzo '.*\nLicense: .*\n' askalono.txt | grep -av "License: " | cut -d/ -f 2 | sort | uniq | wc -l
$ # LiD
$ time license-identifier -I dataset -F csv -O lid
$ cat lid_*.csv | cut -d, -f1 | cut -d"'" -f 2 | grep / | cut -d/ -f2 | sort | uniq | wc -l

Regenerate binary data

The SPDX licenses are included into the binary. To update them, run

make bindata.go

Contributions

...are welcome, see CONTRIBUTING.md and code of conduct.

License

Apache 2.0, see LICENSE.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].