Skip to content

Commit ef57ffe

Browse files
Security: bump activesupport, rexml, yard
Addresses security vulnerabilities in transitive dependencies: - activesupport 7.0.4.3 -> 8.1.3 (major version bump, 4 GHSAs fixed) - rexml 3.2.5 -> 3.4.4 (6 GHSAs fixed) - yard 0.9.36 -> 0.9.44 (1 GHSA fixed) All existing tests pass. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent cfdbd79 commit ef57ffe

22 files changed

Lines changed: 895 additions & 462 deletions

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in pack_stats.gemspec

Gemfile.lock

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PATH
22
remote: .
33
specs:
44
pack_stats (0.2.1)
5+
activesupport (>= 7.2.3.1)
56
code_ownership
67
code_teams
78
dogapi
@@ -13,29 +14,43 @@ PATH
1314
GEM
1415
remote: https://rubygems.org/
1516
specs:
16-
activesupport (7.0.4.3)
17-
concurrent-ruby (~> 1.0, >= 1.0.2)
17+
activesupport (8.1.3)
18+
base64
19+
bigdecimal
20+
concurrent-ruby (~> 1.0, >= 1.3.1)
21+
connection_pool (>= 2.2.5)
22+
drb
1823
i18n (>= 1.6, < 2)
24+
json
25+
logger (>= 1.4.2)
1926
minitest (>= 5.1)
20-
tzinfo (~> 2.0)
27+
securerandom (>= 0.3)
28+
tzinfo (~> 2.0, >= 2.0.5)
29+
uri (>= 0.13.1)
2130
ast (2.4.2)
22-
base64 (0.2.0)
31+
base64 (0.3.0)
32+
bigdecimal (4.1.2)
2333
code_ownership (1.32.17)
2434
code_teams (~> 1.0)
2535
packs
2636
sorbet-runtime
2737
code_teams (1.0.1)
2838
sorbet-runtime
2939
coderay (1.1.3)
30-
concurrent-ruby (1.2.2)
40+
concurrent-ruby (1.3.7)
41+
connection_pool (3.0.2)
3142
diff-lcs (1.5.0)
3243
dogapi (1.45.0)
3344
multi_json
34-
i18n (1.13.0)
45+
drb (2.2.3)
46+
i18n (1.15.1)
3547
concurrent-ruby (~> 1.0)
3648
json (2.6.3)
49+
logger (1.7.0)
3750
method_source (1.0.0)
38-
minitest (5.18.0)
51+
minitest (6.0.6)
52+
drb (~> 2.0)
53+
prism (~> 1.5)
3954
multi_json (1.15.0)
4055
packs (0.0.6)
4156
sorbet-runtime
@@ -45,6 +60,7 @@ GEM
4560
parser (3.2.2.3)
4661
ast (~> 2.4.1)
4762
racc
63+
prism (1.9.0)
4864
pry (0.14.2)
4965
coderay (~> 1.1)
5066
method_source (~> 1.0)
@@ -57,7 +73,7 @@ GEM
5773
sorbet-runtime (>= 0.5.9204)
5874
unparser (>= 0.5.6)
5975
regexp_parser (2.8.0)
60-
rexml (3.2.5)
76+
rexml (3.4.4)
6177
rspec (3.12.0)
6278
rspec-core (~> 3.12.0)
6379
rspec-expectations (~> 3.12.0)
@@ -93,6 +109,7 @@ GEM
93109
rubocop-sorbet (0.7.0)
94110
rubocop (>= 0.90.0)
95111
ruby-progressbar (1.13.0)
112+
securerandom (0.4.1)
96113
sorbet (0.5.11370)
97114
sorbet-static (= 0.5.11370)
98115
sorbet-runtime (0.5.10796)
@@ -118,7 +135,8 @@ GEM
118135
unparser (0.6.8)
119136
diff-lcs (~> 1.3)
120137
parser (>= 3.2.0)
121-
yard (0.9.36)
138+
uri (1.1.1)
139+
yard (0.9.44)
122140
yard-sorbet (0.8.1)
123141
sorbet-runtime (>= 0.5)
124142
yard (>= 0.9)

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# typed: ignore
23

34
require 'bundler/gem_tasks'

bin/tapioca

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
require 'pathname'
12+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13+
Pathname.new(__FILE__).realpath)
1414

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
15+
bundle_binstub = File.expand_path('bundle', __dir__)
1616

1717
if File.file?(bundle_binstub)
1818
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
2323
end
2424
end
2525

26-
require "rubygems"
27-
require "bundler/setup"
26+
require 'rubygems'
27+
require 'bundler/setup'
2828

29-
load Gem.bin_path("tapioca", "tapioca")
29+
load Gem.bin_path('tapioca', 'tapioca')

lib/pack_stats.rb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# typed: strict
23

34
require 'sorbet-runtime'
@@ -19,12 +20,12 @@
1920
module PackStats
2021
extend T::Sig
2122

22-
ROOT_PACKAGE_NAME = T.let('root'.freeze, String)
23+
ROOT_PACKAGE_NAME = T.let('root', String)
2324

2425
DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS = T.let(
2526
[
2627
Pathname.new('components'),
27-
Pathname.new('gems'),
28+
Pathname.new('gems')
2829
].freeze, T::Array[Pathname]
2930
)
3031

@@ -47,17 +48,17 @@ def self.report_to_datadog!(
4748
app_name:,
4849
source_code_pathnames:,
4950
componentized_source_code_locations: DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS,
50-
report_time: Time.now, # rubocop:disable Rails/TimeZone
51+
report_time: Time.now,
5152
verbose: false,
5253
packaged_source_code_locations: [],
5354
max_enforcements_tag_value: false
5455
)
5556

56-
all_metrics = self.get_metrics(
57-
source_code_pathnames: source_code_pathnames,
58-
componentized_source_code_locations: componentized_source_code_locations,
59-
app_name: app_name,
60-
max_enforcements_tag_value: max_enforcements_tag_value,
57+
all_metrics = get_metrics(
58+
source_code_pathnames:,
59+
componentized_source_code_locations:,
60+
app_name:,
61+
max_enforcements_tag_value:
6162
)
6263

6364
# This helps us debug what metrics are being sent
@@ -68,8 +69,8 @@ def self.report_to_datadog!(
6869
end
6970

7071
Private::DatadogReporter.report!(
71-
datadog_client: datadog_client,
72-
report_time: report_time,
72+
datadog_client:,
73+
report_time:,
7374
metrics: all_metrics
7475
)
7576
end
@@ -100,17 +101,17 @@ def self.get_metrics(
100101

101102
Private::DatadogReporter.get_metrics(
102103
source_code_files: source_code_files(
103-
source_code_pathnames: source_code_pathnames,
104-
componentized_source_code_locations: componentized_source_code_locations,
104+
source_code_pathnames:,
105+
componentized_source_code_locations:
105106
),
106-
app_name: app_name
107+
app_name:
107108
)
108109
end
109110

110111
sig do
111112
params(
112113
source_code_pathnames: T::Array[Pathname],
113-
componentized_source_code_locations: T::Array[Pathname],
114+
componentized_source_code_locations: T::Array[Pathname]
114115
).returns(T::Array[Private::SourceCodeFile])
115116
end
116117
def self.source_code_files(
@@ -119,7 +120,9 @@ def self.source_code_files(
119120
)
120121

121122
# Sorbet has the wrong signatures for `Pathname#find`, whoops!
122-
componentized_file_set = Set.new(componentized_source_code_locations.select(&:exist?).flat_map { |pathname| T.unsafe(pathname).find.to_a })
123+
componentized_file_set = Set.new(componentized_source_code_locations.select(&:exist?).flat_map do |pathname|
124+
T.unsafe(pathname).find.to_a
125+
end)
123126

124127
packaged_file_set = Packs.all.flat_map do |pack|
125128
pack.relative_path.find.to_a
@@ -132,7 +135,7 @@ def self.source_code_files(
132135
packaged_file = packaged_file_set.include?(pathname)
133136

134137
Private::SourceCodeFile.new(
135-
pathname: pathname,
138+
pathname:,
136139
team_owner: CodeOwnership.for_file(pathname.to_s),
137140
is_componentized_file: componentized_file,
138141
is_packaged_file: packaged_file

lib/pack_stats/gauge_metric.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
# typed: strict
23

34
module PackStats
@@ -19,8 +20,8 @@ def self.for(metric_name, count, tags)
1920

2021
all_tags = [*tags, max_enforcements_tag]
2122
new(
22-
name: name,
23-
count: count,
23+
name:,
24+
count:,
2425
tags: all_tags
2526
)
2627
end
@@ -32,9 +33,9 @@ def to_s
3233

3334
sig { params(other: GaugeMetric).returns(T::Boolean) }
3435
def ==(other)
35-
other.name == self.name &&
36-
other.count == self.count &&
37-
other.tags == self.tags
36+
other.name == name &&
37+
other.count == count &&
38+
other.tags == tags
3839
end
3940

4041
sig { params(tag_value: T::Boolean).void }

lib/pack_stats/private.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
# frozen_string_literal: true
12
# typed: strict
23

34
module PackStats
45
module Private
56
extend T::Sig
67

7-
sig { params(package: ParsePackwerk::Package).returns(T.nilable(String) )}
8+
sig { params(package: ParsePackwerk::Package).returns(T.nilable(String)) }
89
def self.package_owner(package)
910
pack = Packs.find(package.name)
1011
return nil if pack.nil?
12+
1113
CodeOwnership.for_package(pack)&.name
1214
end
1315
end

lib/pack_stats/private/datadog_reporter.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.get_metrics(source_code_files:, app_name:)
2727
[
2828
*Metrics::Files.get_metrics(source_code_files, app_name),
2929
*Metrics::Packages.get_package_metrics(packages, app_name),
30-
*Metrics::PackagesByTeam.get_package_metrics_by_team(packages, app_name),
30+
*Metrics::PackagesByTeam.get_package_metrics_by_team(packages, app_name)
3131
]
3232
end
3333

@@ -49,7 +49,8 @@ def self.report!(datadog_client:, report_time:, metrics:)
4949
metrics.each_slice(1000).each do |metric_slice|
5050
datadog_client.batch_metrics do
5151
metric_slice.each do |metric|
52-
datadog_client.emit_points(metric.name, [[report_time, metric.count]], type: 'gauge', tags: metric.tags.map(&:to_s))
52+
datadog_client.emit_points(metric.name, [[report_time, metric.count]], type: 'gauge',
53+
tags: metric.tags.map(&:to_s))
5354
end
5455
end
5556
end

lib/pack_stats/private/metrics.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ def self.tags_for_team(team_name)
1414

1515
sig { params(package: ParsePackwerk::Package, app_name: String).returns(T::Array[Tag]) }
1616
def self.tags_for_package(package, app_name)
17-
1817
tags = [
1918
Tag.new(key: 'package', value: humanized_package_name(package.name)),
2019
Tag.new(key: 'app', value: app_name),
21-
*Metrics.tags_for_team(Private.package_owner(package)),
20+
*Metrics.tags_for_team(Private.package_owner(package))
2221
]
2322

2423
layer = package.config['layer']
25-
if layer
26-
tags << Tag.new(key: 'layer', value: layer)
27-
end
24+
tags << Tag.new(key: 'layer', value: layer) if layer
2825

2926
tags
3027
end

lib/pack_stats/private/metrics/dependencies.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ module Metrics
77
class Dependencies
88
extend T::Sig
99

10-
sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], app_name: String).returns(T::Array[GaugeMetric]) }
11-
def self.get_metrics(prefix, packages, app_name)
10+
sig do
11+
params(_prefix: String, packages: T::Array[ParsePackwerk::Package],
12+
app_name: String).returns(T::Array[GaugeMetric])
13+
end
14+
def self.get_metrics(_prefix, packages, app_name)
1215
all_metrics = T.let([], T::Array[GaugeMetric])
1316
inbound_explicit_dependency_by_package = {}
1417
packages.each do |package|
@@ -26,17 +29,17 @@ def self.get_metrics(prefix, packages, app_name)
2629
#
2730
package.dependencies.each do |explicit_dependency|
2831
to_package = ParsePackwerk.find(explicit_dependency)
29-
if to_package.nil?
30-
raise StandardError, "Could not find matching package #{explicit_dependency}"
31-
end
32+
raise StandardError, "Could not find matching package #{explicit_dependency}" if to_package.nil?
3233

3334
owner = Private.package_owner(to_package)
34-
tags = package_tags + [Tag.for('other_package', Metrics.humanized_package_name(explicit_dependency))] + Metrics.tags_for_other_team(owner)
35+
tags = package_tags + [Tag.for('other_package',
36+
Metrics.humanized_package_name(explicit_dependency))] + Metrics.tags_for_other_team(owner)
3537
all_metrics << GaugeMetric.for('by_package.dependencies.by_other_package.count', 1, tags)
3638
end
3739

3840
all_metrics << GaugeMetric.for('by_package.dependencies.count', package.dependencies.count, package_tags)
39-
all_metrics << GaugeMetric.for('by_package.depended_on.count', inbound_explicit_dependency_by_package[package.name]&.count || 0, package_tags)
41+
all_metrics << GaugeMetric.for('by_package.depended_on.count',
42+
inbound_explicit_dependency_by_package[package.name]&.count || 0, package_tags)
4043
end
4144

4245
all_metrics

0 commit comments

Comments
 (0)