Skip to content

Commit

Permalink
Merge pull request #29 from pmonks/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pmonks authored Oct 30, 2023
2 parents 4cecf21 + ae73924 commit 3f9b2e7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion LICENSE.spdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SPDXVersion: SPDX-2.2.1
SPDXVersion: SPDX-2.3
DataLicense: CC0-1.0
Creator: Peter Monks
PackageName: com.github.pmonks/lice-comb
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ $ deps-try com.github.pmonks/lice-comb

; Initialise the matching namespace
; Notes:
; 1. This is slow the first time it's run, due to Spdx-Java-Library downloading SPDX files from the internet and caching
; them (it takes ~1 minute on my laptop). It's substantially faster on subsequent invocations however.
; 2. This step is optional, though initialisation will still happen regardless, and when it does you'll incur the same cost
; 1. This is slow the first time it's run, due to Spdx-Java-Library downloading SPDX files from the
; internet and caching them (it takes ~1 minute on my laptop). It's substantially faster on
; subsequent invocations however.
; 2. This step is optional, though initialisation will still happen regardless, and when it does
; you'll incur the same cost
(lcm/init!)

(lcm/name->expressions "Apache")
Expand Down Expand Up @@ -94,12 +96,12 @@ $ deps-try com.github.pmonks/lice-comb

(lcl/dep->expressions ['aopalliance/aopalliance "1.0"])
;=> #{"LicenseRef-lice-comb-PUBLIC-DOMAIN"}
; Also shows how lice-comb handles "public domain" attestations (which are not supported directly by SPDX, as they're
; not a licensing mechanism)
; Also shows how lice-comb handles "public domain" attestations (which are not supported directly
; by SPDX, as they're not a licensing mechanism)


;; Information about matches (useful for better understanding how lice-comb arrived at a given set of expressions, and
;; how confident it is in the values it's providing)
;; Information about matches (useful for better understanding how lice-comb arrived at a given set
;; of expressions, and how confident it is in the values it's providing)
(lcm/name->expressions-info "Apache-2.0")
;=> {"Apache-2.0" ({:type :declared, :strategy :spdx-expression, :source ("Apache-2.0")})}

Expand Down
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
tolitius/xml-in {:mvn/version "0.1.1"}
hato/hato {:mvn/version "0.9.0"}
dev.weavejester/medley {:mvn/version "1.7.0"}
dom-top/dom-top {:mvn/version "1.0.8"}
dom-top/dom-top {:mvn/version "1.0.9"}
miikka/clj-base62 {:mvn/version "0.1.1"}
com.github.pmonks/clj-spdx {:mvn/version "1.0.103"}
com.github.pmonks/clj-spdx {:mvn/version "1.0.107"}
com.github.pmonks/rencg {:mvn/version "1.0.34"}}
:aliases
{:build {:deps {com.github.pmonks/pbr {:mvn/version "RELEASE"}}
Expand Down
4 changes: 2 additions & 2 deletions pbr.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
[opts]
(assoc opts
:lib 'com.github.pmonks/lice-comb
; :version (pbr/calculate-version 2 0)
:version (format "2.0.%s-RC5" (b/git-count-revs nil))
:version (pbr/calculate-version 2 0)
; :version (format "2.0.%s-RCx-SNAPSHOT" (b/git-count-revs nil))
:write-pom true
:validate-pom true
:pom {:description "A Clojure library for software license detection."
Expand Down
26 changes: 13 additions & 13 deletions src/lice_comb/impl/regex_matching.clj
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
:latest-ver "2.0"}
{:id "Beerware"
:regex #"(?i)\bBeer-?ware\b"
:fn (constantly ["Beerware" :medium])}
:fn (constantly ["Beerware" :high])}
{:id "BSL"
:regex #"(?i)\bBoost(\s+Software)?(\s+Licen[cs]e)?[\s,-]*(?<version>\d+(\.\d+)?)?\b"
:fn generic-id-constructor
Expand All @@ -253,7 +253,7 @@
:fn bsd-id-constructor}
{:id "CC0"
:regex #"(?i)\bCC\s*0"
:fn (constantly ["CC0-1.0" :medium])}
:fn (constantly ["CC0-1.0" :high])}
{:id "CECILL"
:regex #"(?i)\bCeCILL(\s+Free)?(\s+Software)?(\s+Licen[cs]e)?(\s+Agreement)?[\s,-]*(\s*V(ersion)?)?\s*(?<version>\d+(\.\d+)?)?\b"
:fn generic-id-constructor
Expand Down Expand Up @@ -291,29 +291,29 @@
:latest-ver "1.2"}
{:id "FreeBSD"
:regex #"(?i)\bFreeBSD\b"
:fn (constantly ["BSD-2-Clause-FreeBSD" :medium])}
:fn (constantly ["BSD-2-Clause-FreeBSD" :high])}
{:id "GNU license family"
:regex gnu-re
:fn gpl-id-constructor
:pad-ver? true
:latest-ver 3.0}
{:id "Hippocratic"
:regex #"(?i)\bHippocratic\b"
:fn (constantly ["Hippocratic-2.1" :medium])} ; There are no other listed versions of this license
:fn (constantly ["Hippocratic-2.1" :high])} ; There are no other listed versions of this license
{:id "LLVM-exception"
:regex #"(?i)\bLLVM[\s-]+Exception\b"
:fn (constantly ["LLVM-exception" :medium])}
:fn (constantly ["LLVM-exception" :high])}
{:id "MIT"
:regex #"(?i)\b(MIT|Bouncy\s+Castle)(?![\s/]*(X11|ISC))(\s+Public)?(\s+Licen[cs]e)?\b"
:fn (constantly ["MIT" :medium])}
:fn (constantly ["MIT" :high])}
{:id "MPL"
:regex #"(?i)\b(MPL|Mozilla)(\s+Public)?(\s+Licen[cs]e)?[\s,-]*(V(ersion)?)?\s*(?<version>\d+(\.\d+)?)?\b"
:fn generic-id-constructor
:pad-ver? true
:latest-ver "2.0"}
{:id "MX4J"
:regex #"(?i)\bMX4J\s+Licen[cs]e(,?\s+v(ersion)?\s*1\.0)?\b"
:fn (constantly ["Apache-1.1" :medium])} ; See https://github.com/spdx/license-list-XML/pull/594 - the MX4J license *is* the Apache-1.1 license, according to SPDX
:fn (constantly ["Apache-1.1" :high])} ; See https://github.com/spdx/license-list-XML/pull/594 - the MX4J license *is* the Apache-1.1 license, according to SPDX
{:id "NASA"
:regex #"(?i)\bNASA(\s+Open)?(\s+Source)?(\s+Agreement)?[\s,-]+(V(ersion)?)?\s*(?<version>\d+(\.\d+)?)?\b"
:fn generic-id-constructor
Expand All @@ -324,27 +324,27 @@
:fn (constantly ["Plexus" :medium])}
{:id "Proprietary or commercial"
:regex #"(?i)\b(Propriet[aoe]ry|Commercial|All\s+Rights\s+Reserved|Private)\b"
:fn (constantly [(lcis/proprietary-commercial) :medium])}
:fn (constantly [(lcis/proprietary-commercial) :high])}
{:id "Public Domain"
:regex #"(?i)\bPublic\s+Domain(?![\s\(]*CC\s*0)"
:fn (constantly [(lcis/public-domain) :medium])}
:fn (constantly [(lcis/public-domain) :high])}
{:id "Ruby"
:regex #"(?i)\bRuby(\s+Licen[cs]e)?\b"
:fn (constantly ["Ruby" :medium])}
:fn (constantly ["Ruby" :high])}
{:id "SGI-B"
:regex #"(?i)\bSGI(\s+Free)?(\s+Software)?(\s+Licen[cs]e)?([\s,-]+(V(ersion)?)?\s*(?<version>\d+(\.\d+)?)?)?\b"
:fn generic-id-constructor
:pad-ver? true
:latest-ver "2.0"}
{:id "Unlicense"
:regex #"(?i)\bUnlicen[cs]e\b"
:fn (constantly ["Unlicense" :medium])}
:fn (constantly ["Unlicense" :high])}
{:id "WTFPL"
:regex #"(?i)\b(WTFPL|DO-WTF-U-WANT-2|Do\s+What\s+The\s+Fuck\s+You\s+Want\s+To(\s+Public)?(\s+Licen[cs]e)?)\b"
:fn (constantly ["WTFPL" :medium])}
:fn (constantly ["WTFPL" :high])}
{:id "Zlib"
:regex #"\b(?i)zlib(?![\s/]+libpng)\b"
:fn (constantly ["Zlib" :medium])}
:fn (constantly ["Zlib" :high])}
])))
(defn- match
Expand Down
2 changes: 1 addition & 1 deletion src/lice_comb/matching.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
[name]
(when-not (s/blank? name)
(let [name (s/trim name)]
; 1. If it's a valid SPDX expression, return the normalised rendition of it in a set
; 1. If it's a valid SPDX expression, return the normalised rendition of it
(if-let [normalised-expression (sexp/normalise name)]
{normalised-expression (list {:type :declared :strategy :spdx-expression :source (list name)})}
; 2. If it's a URI, use URI matching (this is to handle messed up real world cases where license names in POMs contain a URI)
Expand Down
2 changes: 1 addition & 1 deletion src/lice_comb/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
warning."
[m expr]
(when (and m expr)
(str expr
(str expr " "
(when-let [info-list (sort-by expression-info-sort-by-keyfn (seq (get m expr)))]
(s/join "\n" (map #(str (when-let [md-id (:id %)] (when (not= expr md-id) (str " " md-id " ")))
(case (:type %)
Expand Down

0 comments on commit 3f9b2e7

Please sign in to comment.