licensed 4.3.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5e25ec11aa1545ab3a63cd560c95dd5f12c0008867a68668005473ab68b20ff
4
- data.tar.gz: 9dd7d0fafc53407683ba844ae7f9ce4da2b52a72ebda61334739e9fb010b1af9
3
+ metadata.gz: d7d2ea0e055fe77e271036b11cc0494a3258e4a7f912bea4b135da327f7c6b16
4
+ data.tar.gz: eba319d54b8bc1865e25c325113b85fe3e151f5dfe52fe17059400bfbff4d6ea
5
5
  SHA512:
6
- metadata.gz: 234bf05e1fd4aa01c19220ed566820b291169fb55714c5841dad75f3a01c06c37011dcc8a943008ff0b36325fb00637fcbbd3175c94cb9b18e65cbbcf2ed6514
7
- data.tar.gz: 812597ad63783d2b16cf7cf33ab81e793ee9c8ae103b61927655019d8418a1ef5778d61ec288c817caf5e687776c8e15531cfc1c20dd1e650720ccd4f274296f
6
+ metadata.gz: cb1676bd29d609faf6bab6b32a8c54599ab7a3b508e0ade9c59ca6f6538923420540b78ac2074af343bc3dc8eceb611a74f4f3dc921ea0fef95eefc596f77395
7
+ data.tar.gz: 26ca34201fe2c44c1dfe2bf2168720b885b051aca5e143225348febfc34d24d5e3b17845224fb543e5187aea370bcbf2c446f5e37e3d5c8028054f3cc3e061c3
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 4.4.0
10
+
11
+ ### Added
12
+
13
+ - Licensed status command will alert on stale cached dependency records (https://github.com/github/licensed/pull/657)
14
+
9
15
  ## 4.3.1
10
16
 
11
17
  ### Changed
@@ -735,4 +741,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
735
741
 
736
742
  Initial release :tada:
737
743
 
738
- [Unreleased]: https://github.com/github/licensed/compare/4.3.1...HEAD
744
+ [Unreleased]: https://github.com/github/licensed/compare/4.4.0...HEAD
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- licensed (4.3.1)
4
+ licensed (4.5.0)
5
5
  json (~> 2.6)
6
6
  licensee (~> 9.16)
7
7
  parallel (~> 1.22)
@@ -14,24 +14,33 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (7.0.4.3)
17
+ activesupport (7.1.3.2)
18
+ base64
19
+ bigdecimal
18
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ connection_pool (>= 2.2.5)
22
+ drb
19
23
  i18n (>= 1.6, < 2)
20
24
  minitest (>= 5.1)
25
+ mutex_m
21
26
  tzinfo (~> 2.0)
22
27
  addressable (2.8.1)
23
28
  public_suffix (>= 2.0.2, < 6.0)
24
29
  ast (2.4.2)
30
+ base64 (0.2.0)
31
+ bigdecimal (3.1.7)
25
32
  byebug (11.1.3)
26
- concurrent-ruby (1.2.2)
33
+ concurrent-ruby (1.2.3)
34
+ connection_pool (2.4.1)
27
35
  dotenv (2.8.1)
36
+ drb (2.2.1)
28
37
  faraday (2.7.4)
29
38
  faraday-net_http (>= 2.0, < 3.1)
30
39
  ruby2_keywords (>= 0.0.4)
31
40
  faraday-net_http (3.0.2)
32
- i18n (1.12.0)
41
+ i18n (1.14.4)
33
42
  concurrent-ruby (~> 1.0)
34
- json (2.6.3)
43
+ json (2.7.2)
35
44
  licensee (9.16.0)
36
45
  dotenv (~> 2.0)
37
46
  octokit (>= 4.20, < 7.0)
@@ -39,30 +48,32 @@ GEM
39
48
  rugged (>= 0.24, < 2.0)
40
49
  thor (>= 0.19, < 2.0)
41
50
  mini_portile2 (2.8.1)
42
- minitest (5.18.0)
43
- minitest-hooks (1.5.0)
51
+ minitest (5.24.1)
52
+ minitest-hooks (1.5.1)
44
53
  minitest (> 5.3)
45
- mocha (2.0.2)
54
+ mocha (2.4.5)
46
55
  ruby2_keywords (>= 0.0.5)
47
- nokogiri (1.14.3)
56
+ mutex_m (0.2.0)
57
+ nokogiri (1.15.6)
48
58
  mini_portile2 (~> 2.8.0)
49
59
  racc (~> 1.4)
50
60
  octokit (6.1.0)
51
61
  faraday (>= 1, < 3)
52
62
  sawyer (~> 0.9)
53
- parallel (1.22.1)
63
+ parallel (1.25.1)
54
64
  parser (3.2.0.0)
55
65
  ast (~> 2.4.1)
56
- pathname-common_prefix (0.0.1)
66
+ pathname-common_prefix (0.0.2)
57
67
  public_suffix (5.0.1)
58
68
  racc (1.6.2)
59
- rack (3.0.7)
69
+ rack (3.0.9.1)
60
70
  rainbow (3.1.1)
61
- rake (13.0.6)
71
+ rake (13.2.1)
62
72
  regexp_parser (2.6.2)
63
73
  reverse_markdown (2.1.1)
64
74
  nokogiri
65
- rexml (3.2.5)
75
+ rexml (3.3.3)
76
+ strscan
66
77
  rubocop (1.45.1)
67
78
  json (~> 2.3)
68
79
  parallel (~> 1.10)
@@ -93,7 +104,8 @@ GEM
93
104
  sawyer (0.9.2)
94
105
  addressable (>= 2.3.5)
95
106
  faraday (>= 0.17.3, < 3)
96
- thor (1.2.1)
107
+ strscan (3.1.0)
108
+ thor (1.3.1)
97
109
  tomlrb (2.0.3)
98
110
  tzinfo (2.0.6)
99
111
  concurrent-ruby (~> 1.0)
data/README.md CHANGED
@@ -8,7 +8,7 @@ Licensed is **not** a complete open source license compliance solution. Please u
8
8
 
9
9
  ![Build status](https://github.com/github/licensed/workflows/Test/badge.svg)
10
10
 
11
- Licensed is in active development and currently used at GitHub. See the [open issues](https://github.com/github/licensed/issues) for a list of potential work.
11
+ Licensed is currently in **low maintenance mode**. At this point, we're only looking to maintain this repository for security fixes.
12
12
 
13
13
  ## Licensed v4 - **Removed support for non-Ruby environments**
14
14
 
@@ -31,6 +31,21 @@ A dependency will fail the status checks if:
31
31
  - If `license: other` is specified and all of the `licenses` entries match an `allowed` license a failure will not be logged
32
32
  - A `reviewed` entry must reference a specific version of the depdency, e.g. `<name>@<version>`. The version identifier must specify a specific dependency version, ranges are not allowed.
33
33
 
34
+ ## Detect and alert on stale cached metadata files
35
+
36
+ Licensed can alert on any metadata files that don't correlate to a currently used dependency when `licensed status` is run. To configure this behavior, set a root-level `stale_records_action` value in your [licensed configuration file](./../configuration.md).
37
+
38
+ Available values are:
39
+
40
+ 1. `'error'`: Treat stale cached records as errors. Licensed will output errors for any stale metadata files and will cause `licensed status` to fail.
41
+ 1. `'warn'`, `''`, or unset (default): Treat stale cached records as warnings. Licensed will output warnings for any stale metadata files but will not cause `licensed status` to fail.
42
+ 1. `'ignore'`, any other value: Ignore stale cached records. Licensed will not output any notifications about stale metadata files.
43
+
44
+ ```yaml
45
+ # in the licensed configuration file
46
+ stale_records_action: 'warn'
47
+ ```
48
+
34
49
  ## Options
35
50
 
36
51
  - `--config`/`-c`: the path to the licensed configuration file
@@ -1,6 +1,6 @@
1
1
  # Customize Licensee's behavior
2
2
 
3
- Licensed uses [Licensee](https://github.com/licensee/licensee) to detect and evaluate OSS licenses for project dependencies found during source enumeration. Licensed can optionally [customize Licensee's behavior](https://github.com/licensee/licensee/blob/jonabc-patch-1/docs/customizing.md#customizing-licensees-behavior) based on options set in the configuration file.
3
+ Licensed uses [Licensee](https://github.com/licensee/licensee) to detect and evaluate OSS licenses for project dependencies found during source enumeration. Licensed can optionally [customize Licensee's behavior](https://github.com/licensee/licensee/blob/main/docs/customizing.md#customizing-licensees-behavior) based on options set in the configuration file.
4
4
 
5
5
  **NOTE** Matching licenses based on package manager metadata and README references is always enabled and cannot currently be configured.
6
6
 
@@ -8,6 +8,6 @@ Licensed uses [Licensee](https://github.com/licensee/licensee) to detect and eva
8
8
  licensee:
9
9
  # the confidence threshold is an integer between 1 and 100. the value represents
10
10
  # the minimum percentage confidence that Licensee must have to report a matched license
11
- # https://github.com/licensee/licensee/blob/master/docs/customizing.md#adjusting-the-confidence-threshold
11
+ # https://github.com/licensee/licensee/blob/main/docs/customizing.md#adjusting-the-confidence-threshold
12
12
  confidence_threshold: 90 # default value: 98
13
13
  ```
@@ -26,6 +26,15 @@ cache_path: 'relative/path/to/cache'
26
26
  # Defaults to current directory when running `licensed`
27
27
  source_path: 'relative/path/to/source'
28
28
 
29
+ # Whether to take any action when records are detected in the cache paths that don't map to evaluated
30
+ # dependencies.
31
+ # Available values are:
32
+ # - 'error': treat stale cached records as errors. Notify the user and fail status checks
33
+ # - 'warn', '', unset: treat stale cached records as warnings. Notify the user but do not fail status checks
34
+ # - 'ignore': Ignore stale cached records. Do not notify the user and do not fail status checks
35
+ # Optional, when not set this defaults to 'warn' behavior
36
+ stale_records_action: 'warn'
37
+
29
38
  # Sources of metadata
30
39
  sources:
31
40
  bower: true
@@ -14,11 +14,11 @@ When using licensed v3 with bundler dependencies, licensed must be installed fro
14
14
 
15
15
  Using licensed to enumerate bundler dependencies in a GitHub Actions workflow will require ruby to be available in the actions VM environment. Ruby can be setup in an actions workflow using [ruby/setup-ruby](https://github.com/ruby/setup-ruby)(preferred) or [actions/setup-ruby](https://github.com/actions/setup-ruby)(deprecated).
16
16
 
17
- If you are using licensed in a GitHub Actions workflow, [jonabc/setup-licensed](https://github.com/jonabc/setup-licensed) has been updated according to this breaking change. `setup-licensed` will install the licensed gem when ruby is available, or the licensed executable when ruby is not available. Alternatively, you can `gem install` licensed directly as an actions step.
17
+ If you are using licensed in a GitHub Actions workflow, [github/setup-licensed](https://github.com/github/setup-licensed) has been updated according to this breaking change. `setup-licensed` will install the licensed gem when ruby is available, or the licensed executable when ruby is not available. Alternatively, you can `gem install` licensed directly as an actions step.
18
18
 
19
- This is an example workflow definition that runs [jonabc/licensed-ci](https://github.com/jonabc/licensed-ci)'s opinionated license compliance workflow in CI. It includes jobs that demonstrate installing licensed using
19
+ This is an example workflow definition that runs [github/licensed-ci](https://github.com/github/licensed-ci)'s opinionated license compliance workflow in CI. It includes jobs that demonstrate installing licensed using
20
20
  - `gem install`
21
- - [jonabc/setup-licensed](https://github.com/jonabc/setup-licensed)
21
+ - [github/setup-licensed](https://github.com/github/setup-licensed)
22
22
  - installing when included in a bundler gem file
23
23
 
24
24
  ```yml
@@ -50,7 +50,7 @@ jobs:
50
50
  ruby-version: "3.0"
51
51
 
52
52
  # install licensed gem using setup-licensed
53
- - uses: jonabc/setup-licensed@v1
53
+ - uses: github/setup-licensed@v1
54
54
  with:
55
55
  version: '3.x'
56
56
 
@@ -58,7 +58,7 @@ jobs:
58
58
  - run: bundle install
59
59
 
60
60
  # run licensed-ci to cache any metadata changes and verify compliance
61
- - uses: jonabc/licensed-ci@v1
61
+ - uses: github/licensed-ci@v1
62
62
 
63
63
  # OR
64
64
 
@@ -82,7 +82,7 @@ jobs:
82
82
  - run: bundle install
83
83
 
84
84
  # run licensed-ci to cache any metadata changes and verify compliance
85
- - uses: jonabc/licensed-ci@v1
85
+ - uses: github/licensed-ci@v1
86
86
 
87
87
  # OR
88
88
 
@@ -103,7 +103,7 @@ jobs:
103
103
  - run: bundle install
104
104
 
105
105
  # run licensed-ci to cache any metadata changes and verify compliance
106
- - uses: jonabc/licensed-ci@v1
106
+ - uses: github/licensed-ci@v1
107
107
  with:
108
108
  command: 'bundle exec licensed' # run licensed within the bundler context
109
109
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  The cocoapods source will detect dependencies when `Podfile` and `Podfile.lock` are found at an app's `source_path`. The cocoapods source uses the [cocoapods-dependencies-list](https://github.com/jonabc/cocoapods-dependencies-list) plugin to enumerate dependencies and gather metadata on each package.
4
4
 
5
- **NOTE: Licensed does not install the [cocoapods-dependencies-list](https://github.com/jonanc/cocoapods-dependencies-list) plugin. Users must install the gem alongside the cocoapods gem to enumerate cocoapods dependencies.**
5
+ **NOTE: Licensed does not install the [cocoapods-dependencies-list](https://github.com/jonabc/cocoapods-dependencies-list) plugin. Users must install the gem alongside the cocoapods gem to enumerate cocoapods dependencies.**
6
6
 
7
7
  ## Evaluating dependencies from a specific target
8
8
 
@@ -23,6 +23,7 @@ module Licensed
23
23
  def run_command(report)
24
24
  super do |result|
25
25
  clear_stale_cached_records if result
26
+ result
26
27
  end
27
28
  ensure
28
29
  cache_paths.clear
@@ -69,7 +69,7 @@ module Licensed
69
69
 
70
70
  result = results.all?
71
71
 
72
- yield(result) if block_given?
72
+ result = yield(result) if block_given?
73
73
 
74
74
  result
75
75
  ensure
@@ -103,7 +103,7 @@ module Licensed
103
103
 
104
104
  result = results.all?
105
105
 
106
- yield(result) if block_given?
106
+ result = yield(result) if block_given?
107
107
 
108
108
  result
109
109
  end
@@ -142,7 +142,7 @@ module Licensed
142
142
 
143
143
  result = results.all?
144
144
 
145
- yield(result) if block_given?
145
+ result = yield(result) if block_given?
146
146
 
147
147
  result
148
148
  rescue Licensed::Shell::Error => err
@@ -175,7 +175,7 @@ module Licensed
175
175
 
176
176
  result = evaluate_dependency(app, source, dependency, report)
177
177
 
178
- yield(result) if block_given?
178
+ result = yield(result) if block_given?
179
179
 
180
180
  result
181
181
  rescue Licensed::DependencyRecord::Error, Licensed::Shell::Error => err
@@ -23,10 +23,48 @@ module Licensed
23
23
  # Returns whether the command succeeded based on the call to super
24
24
  def run_command(report)
25
25
  super do |result|
26
- next if result
26
+ stale_records = stale_cached_records
27
+ if stale_records.any?
28
+ messages = stale_records.map { |f| "Stale dependency record found: #{f}" }
29
+ messages << "Please run the licensed cache command to clean up stale records"
30
+
31
+ case config["stale_records_action"].to_s
32
+ when "error"
33
+ report.errors.concat messages
34
+ result = false
35
+ when "warn", ""
36
+ report.warnings.concat messages
37
+ end
38
+ end
39
+
40
+ next result if result
27
41
 
28
42
  report.errors << "Licensed found errors during source enumeration. Please see https://github.com/github/licensed/tree/master/docs/commands/status.md#status-errors-and-resolutions for possible resolutions."
43
+
44
+ result
29
45
  end
46
+ ensure
47
+ cache_paths.clear
48
+ files.clear
49
+ end
50
+
51
+ # Run the command for all enumerated dependencies found in a dependency source,
52
+ # recording results in a report.
53
+ # Enumerating dependencies in the source is skipped if a :sources option
54
+ # is provided and the evaluated `source.class.type` is not in the :sources values
55
+ #
56
+ # app - The application configuration for the source
57
+ # source - A dependency source enumerator
58
+ #
59
+ # Returns whether the command succeeded for the dependency source enumerator
60
+ def run_source(app, source, report)
61
+ result = super
62
+
63
+ # add the full cache path to the list of cache paths
64
+ # that should be checked for extra files after the command run
65
+ cache_paths << app.cache_path.join(source.class.type) unless result == :skipped
66
+
67
+ result
30
68
  end
31
69
 
32
70
  # Evaluates a dependency for any compliance errors.
@@ -49,6 +87,9 @@ module Licensed
49
87
  filename = app.cache_path.join(source.class.type, "#{dependency.name}.#{DependencyRecord::EXTENSION}")
50
88
  report["filename"] = filename
51
89
  record = cached_record(filename)
90
+
91
+ # add the absolute dependency file path to the list of files seen during this licensed run
92
+ files << filename.to_s
52
93
  end
53
94
 
54
95
  if record.nil?
@@ -133,6 +174,26 @@ module Licensed
133
174
 
134
175
  licenses.sort_by { |license| license != "other" ? 0 : 1 }.first
135
176
  end
177
+
178
+ # Check for cached files that don't match current dependencies
179
+ #
180
+ # Returns an array of any cached records that do not match a currently used dependency
181
+ def stale_cached_records
182
+ cache_paths.flat_map do |cache_path|
183
+ record_search_glob_pattern = cache_path.join("**/*.#{DependencyRecord::EXTENSION}")
184
+ Dir.glob(record_search_glob_pattern).select { |file| !files.include?(file) }
185
+ end.uniq
186
+ end
187
+
188
+ # Set of unique cache paths that are evaluted during the run
189
+ def cache_paths
190
+ @cache_paths ||= Set.new
191
+ end
192
+
193
+ # Set of unique absolute file paths of cached records evaluted during the run
194
+ def files
195
+ @files ||= Set.new
196
+ end
136
197
  end
137
198
  end
138
199
  end
@@ -274,6 +274,7 @@ module Licensed
274
274
  end
275
275
 
276
276
  def initialize(options = {})
277
+ @options = options
277
278
  apps = options.delete("apps") || []
278
279
  apps << default_options.merge(options) if apps.empty?
279
280
 
@@ -285,6 +286,10 @@ module Licensed
285
286
  @apps = apps.map { |app| AppConfiguration.new(app, options) }
286
287
  end
287
288
 
289
+ def [](key)
290
+ @options&.fetch(key, nil)
291
+ end
292
+
288
293
  private
289
294
 
290
295
  def self.expand_app_source_path(app_config)
@@ -8,6 +8,11 @@ module Licensed
8
8
  # command - The command being run
9
9
  # report - A report object containing information about the command run
10
10
  def end_report_command(command, report)
11
+ if report.warnings.any?
12
+ shell.newline
13
+ report.warnings.each { |e| shell.warn e }
14
+ end
15
+
11
16
  if report.errors.any?
12
17
  shell.newline
13
18
  report.errors.each { |e| shell.error e }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Licensed
3
- VERSION = "4.3.1".freeze
3
+ VERSION = "4.5.0".freeze
4
4
 
5
5
  def self.previous_major_versions
6
6
  major_version = Gem::Version.new(Licensed::VERSION).segments.first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licensed
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2024-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: licensee
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  - !ruby/object:Gem::Version
343
343
  version: '0'
344
344
  requirements: []
345
- rubygems_version: 3.3.26
345
+ rubygems_version: 3.4.19
346
346
  signing_key:
347
347
  specification_version: 4
348
348
  summary: Extract and validate the licenses of dependencies.