All Projects → src-d → Go License Detector

src-d / Go License Detector

Licence: other
Reliable project licenses detector.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go License Detector

Snipe It
A free open source IT asset/license management system
Stars: ✭ 5,606 (+2471.56%)
Mutual labels:  license-management
Truelicense
TrueLicense is an open source engine for license management on the JVM.
Stars: ✭ 94 (-56.88%)
Mutual labels:  license-management
Gradle License Report
A plugin for generating reports about the licenses of third party software using Gradle
Stars: ✭ 152 (-30.28%)
Mutual labels:  license-management
Lickey
software license management system
Stars: ✭ 706 (+223.85%)
Mutual labels:  license-management
Tools
SPDX Tools
Stars: ✭ 79 (-63.76%)
Mutual labels:  license-management
Ercole
The Server component of the Ercole Project
Stars: ✭ 107 (-50.92%)
Mutual labels:  license-management
Legit
Add licenses to projects at the command line
Stars: ✭ 515 (+136.24%)
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 (+944.95%)
Mutual labels:  license-management
Lc
licensechecker (lc) a command line application which scans directories and identifies what software license things are under producing reports as either SPDX, CSV, JSON, XLSX or CLI Tabular output. Dual-licensed under MIT or the UNLICENSE.
Stars: ✭ 93 (-57.34%)
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 (+693.58%)
Mutual labels:  license-management
Dotnet Delice
📑 A CLI to help you get insight into your projects' licenses
Stars: ✭ 36 (-83.49%)
Mutual labels:  license-management
Scancode Toolkit
🔎 ScanCode detects licenses, copyrights, package manifests & dependencies and more by scanning code ... to discover and inventory open source and third-party packages used in your code.
Stars: ✭ 1,134 (+420.18%)
Mutual labels:  license-management
Licensetoolsplugin
Gradle plugin to check library licenses and generate license pages for Android
Stars: ✭ 113 (-48.17%)
Mutual labels:  license-management
Licensed
A Ruby gem to cache and verify the licenses of dependencies
Stars: ✭ 690 (+216.51%)
Mutual labels:  license-management
Licenseplist
A license list generator of all your dependencies for iOS applications
Stars: ✭ 1,996 (+815.6%)
Mutual labels:  license-management
F License
Open Source License Key Generation and Verification Tool written in Go
Stars: ✭ 535 (+145.41%)
Mutual labels:  license-management
Wwhrd
You have licenses to manage, What Would Henry Rollins Do?
Stars: ✭ 97 (-55.5%)
Mutual labels:  license-management
Licenseclassifier
A License Classifier
Stars: ✭ 180 (-17.43%)
Mutual labels:  license-management
Npm License Crawler
Analyzes license information for multiple node.js modules (package.json files) as part of your software project.
Stars: ✭ 168 (-22.94%)
Mutual labels:  license-management
Jwt Key Server
JWT based remote licensing server.
Stars: ✭ 123 (-43.58%)
Mutual labels:  license-management

WE CONTINUE THE DEVELOPMENT AT go-enry/go-license-detector. This repository is abandoned, and no further updates will be done on the code base, nor issue/prs will be answered or attended.

go-license-detector GoDoc Build Status Build status codecov 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

export GO111MODULE=on
go mod download
go build -v gopkg.in/src-d/go-license-detector.v3/cmd/license-detector

Contributions

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

License

Apache 2.0, see LICENSE.md.

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/src-d/go-git

Library (for a single license detection):

import (
    "gopkg.in/src-d/go-license-detector.v3/licensedb"
    "gopkg.in/src-d/go-license-detector.v3/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"

	"gopkg.in/src-d/go-license-detector.v3/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/gopkg.in/src-d/go-license-detector.v3/licensedb
$ mkdir dataset && cd dataset
$ unzip ../dataset.zip
$ # src-d/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
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].