Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 [security] [ruby] Update rails 6.1.7.10 → 7.0.8.1 (major) #4030

Merged
merged 15 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'

group :default do
gem 'bootsnap'
gem 'rails', '~> 6.1.7'
gem 'rails', '~> 7.0.8'

# Fix incompatibility with between Ruby 3.1 and Psych 4 (used for yaml)
# see https://stackoverflow.com/a/71192990
Expand Down
131 changes: 65 additions & 66 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,70 +34,76 @@ GEM
specs:
aasm (5.5.0)
concurrent-ruby (~> 1.0)
actioncable (6.1.7.10)
actionpack (= 6.1.7.10)
activesupport (= 6.1.7.10)
actioncable (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.10)
actionpack (= 6.1.7.10)
activejob (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
actionmailbox (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
mail (>= 2.7.1)
actionmailer (6.1.7.10)
actionpack (= 6.1.7.10)
actionview (= 6.1.7.10)
activejob (= 6.1.7.10)
activesupport (= 6.1.7.10)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.1)
actionpack (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activesupport (= 7.0.8.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (6.1.7.10)
actionview (= 6.1.7.10)
activesupport (= 6.1.7.10)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.8.1)
actionview (= 7.0.8.1)
activesupport (= 7.0.8.1)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionpack-xml_parser (2.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
actiontext (6.1.7.10)
actionpack (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
actiontext (7.0.8.1)
actionpack (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (6.1.7.10)
activesupport (= 6.1.7.10)
actionview (7.0.8.1)
activesupport (= 7.0.8.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.7.10)
activesupport (= 6.1.7.10)
activejob (7.0.8.1)
activesupport (= 7.0.8.1)
globalid (>= 0.3.6)
activemodel (6.1.7.10)
activesupport (= 6.1.7.10)
activerecord (6.1.7.10)
activemodel (= 6.1.7.10)
activesupport (= 6.1.7.10)
activemodel (7.0.8.1)
activesupport (= 7.0.8.1)
activerecord (7.0.8.1)
activemodel (= 7.0.8.1)
activesupport (= 7.0.8.1)
activerecord-import (1.7.0)
activerecord (>= 4.2)
activestorage (6.1.7.10)
actionpack (= 6.1.7.10)
activejob (= 6.1.7.10)
activerecord (= 6.1.7.10)
activesupport (= 6.1.7.10)
activestorage (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activesupport (= 7.0.8.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.10)
activesupport (7.0.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
after_commit_everywhere (1.4.0)
Expand Down Expand Up @@ -279,7 +285,7 @@ GEM
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.6)
net-imap (0.5.0)
net-imap (0.5.1)
date
net-protocol
net-ldap (0.19.0)
Expand Down Expand Up @@ -330,21 +336,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.10)
actioncable (= 6.1.7.10)
actionmailbox (= 6.1.7.10)
actionmailer (= 6.1.7.10)
actionpack (= 6.1.7.10)
actiontext (= 6.1.7.10)
actionview (= 6.1.7.10)
activejob (= 6.1.7.10)
activemodel (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
rails (7.0.8.1)
actioncable (= 7.0.8.1)
actionmailbox (= 7.0.8.1)
actionmailer (= 7.0.8.1)
actionpack (= 7.0.8.1)
actiontext (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activemodel (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
bundler (>= 1.15.0)
railties (= 6.1.7.10)
sprockets-rails (>= 2.0.0)
railties (= 7.0.8.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -362,12 +367,13 @@ GEM
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-perftest (0.0.7)
railties (6.1.7.10)
actionpack (= 6.1.7.10)
activesupport (= 6.1.7.10)
railties (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
Expand Down Expand Up @@ -491,13 +497,6 @@ GEM
sorted_set (1.0.3)
rbtree
set (~> 1.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
ssrf_filter (1.1.2)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
Expand All @@ -516,7 +515,7 @@ GEM
thor (1.3.2)
tilt (2.4.0)
timecop (0.9.10)
timeout (0.4.1)
timeout (0.4.2)
traceroute (0.8.1)
rails (>= 3.0.0)
tzinfo (2.0.6)
Expand Down Expand Up @@ -610,7 +609,7 @@ DEPENDENCIES
rack-acceptable
rack-cors
rack-mini-profiler
rails (~> 6.1.7)
rails (~> 7.0.8)
rails-controller-testing
rails-erd
rails-perftest
Expand Down
2 changes: 1 addition & 1 deletion app/api/core/io/json/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def encode(object, options = {}) # rubocop:todo Metrics/CyclomaticComplexity
when ActiveSupport::TimeWithZone
string_encode(object.to_s)
when Time
string_encode(object.to_s(:compatible))
string_encode(object.to_fs(:compatible))
when Hash
hash_encode(object, options)
when ZIPPABLE
Expand Down
4 changes: 2 additions & 2 deletions app/models/accession_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def submit(user, *accessionables) # rubocop:todo Metrics/CyclomaticComplexity
ensure
files.each(&:close) # not really necessary but recommended
end

return accessionables.map(&:accession_number) # rubocop:todo Rails/TransactionExitStatement
end

accessionables.map(&:accession_number)
Comment on lines -125 to +127
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have changed line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, returning in a transaction causes a rollback (silently) in rails 7. Took at least a day of debugging to change this one line 🤦

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning from within a transaction was too much trouble during the updates to rails 7. Those blocks need to check what to do, break the loop, set a flag, rollback if necessary and the method should return after the transaction blocks. @dasunpubudumal .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, I expected those cases to be covered by tests but it doesn't look like it is... Ill have a look.

Copy link
Contributor

@BenTopping BenTopping Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoldas After some testing I don't think this change affects the behaviour as the transaction will raise an error before the return if there are any issues and if an error is raised the return isn't reached. So the behaviour of the function remains unchanged.

end

# rubocop:enable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
Expand Down
2 changes: 1 addition & 1 deletion app/models/bait_library_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BaitLibraryType < ApplicationRecord

# category is used for billing, to differentiate between products with Custom and Standard bait libraries
# Automated billing report stuff has been removed, but this is still useful downstream so we'll keep it
enum category: { standard: 0, custom: 1 }
enum :category, { standard: 0, custom: 1 }

has_many :bait_libraries

Expand Down
3 changes: 2 additions & 1 deletion app/models/barcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Barcode < ApplicationRecord
after_commit :broadcast_barcode

# Caution! Do not adjust the index of existing formats.
enum format: {
enum :format,
{
sanger_ean13: 0,
infinium: 1,
fluidigm: 2,
Expand Down
4 changes: 2 additions & 2 deletions app/models/barcode_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class BarcodePrinter < ApplicationRecord
delegate :printer_type_id, to: :barcode_printer_type

# this is for Limber. Moving it over to pmb v2 would allow this to be removed.
enum print_service: { 'PMB' => 0, 'SPrint' => 1 }
enum :print_service, { 'PMB' => 0, 'SPrint' => 1 }

# it would possibly make more sense to have squix as 0 but this fits with PMB but creates no dependency
enum printer_type: { squix: 1, toshiba: 0 }
enum :printer_type, { squix: 1, toshiba: 0 }

def plate384_printer?
barcode_printer_type.name == '384 Well Plate'
Expand Down
7 changes: 0 additions & 7 deletions app/models/failure.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# frozen_string_literal: true
class Failure < ApplicationRecord
belongs_to :failable, polymorphic: true
after_create :notify_remote

def notify_remote
if notify_remote?
# Send event to Studies here
end
end
end
2 changes: 1 addition & 1 deletion app/models/insdc/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Country < ApplicationRecord
# Indicates if a region is valid for selection or not
# @note This has been implemented as an enum for flexible extension at a later date.
# @return [Symbol] :valid or :invalid
enum validation_state: { valid: 0, invalid: 1 }, _suffix: :state
enum :validation_state, { valid: 0, invalid: 1 }, suffix: :state

validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :sort_priority, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/labware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Labware < Asset

attr_reader :storage_location_service

enum retention_instruction: { destroy_after_2_years: 0, return_to_customer_after_2_years: 1, long_term_storage: 2 }
enum :retention_instruction, { destroy_after_2_years: 0, return_to_customer_after_2_years: 1, long_term_storage: 2 }

delegate :metadata, to: :custom_metadatum_collection, allow_nil: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/location_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LocationReport < ApplicationRecord
serialize :plate_purpose_ids, Array
serialize :barcodes, Array
self.per_page = 20
enum report_type: { type_selection: 0, type_labwhere: 1 }
enum :report_type, { type_selection: 0, type_labwhere: 1 }

# relations
belongs_to :study, optional: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/location_report/location_report_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LocationReport::LocationReportForm

def name=(input_name)
@name = input_name.gsub(/[^A-Za-z0-9_\-.\s]/, '').squish.gsub(/\s/, '_') if input_name.present?
@name = Time.current.to_formatted_s(:number) if input_name.blank?
@name = Time.current.to_fs(:number) if input_name.blank?
end

def location_barcode=(location_barcode)
Expand Down
2 changes: 1 addition & 1 deletion app/models/pick_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PickList < ApplicationRecord
belongs_to :submission, optional: false, autosave: true
has_many :batches, -> { distinct }, through: :submission

enum state: { pending: 0, built: 1 }
enum :state, { pending: 0, built: 1 }

delegate :orders, to: :submission

Expand Down
1 change: 0 additions & 1 deletion app/models/plate/fluidigm_behaviour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def retrieve_fluidigm_data
# rubocop:enable Rails/TransactionExitStatement

apply_fluidigm_data(FluidigmFile.new(fluidigm_data.content))
return true # rubocop:todo Rails/TransactionExitStatement
StephenHulme marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down
5 changes: 1 addition & 4 deletions app/models/plate/sample_tube_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def self.create_sample_tubes_asset_group_and_print_barcodes(plates, barcode_prin

plate_barcodes = plates.map(&:barcode_number)
asset_group =
AssetGroup.find_or_create_asset_group(
"#{plate_barcodes.join('-')} #{Time.current.to_formatted_s(:sortable)} ",
study
)
AssetGroup.find_or_create_asset_group("#{plate_barcodes.join('-')} #{Time.current.to_fs(:sortable)} ", study)
plates.each do |plate|
factory = Plate::SampleTubeFactory.new(plate)
next if factory.wells.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/models/presenters/qc_report_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def new_or_all
end

def created_date
qc_report.created_at.to_formatted_s(:rfc822)
qc_report.created_at.to_fs(:rfc822)
end

def state_description
Expand Down
2 changes: 1 addition & 1 deletion app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def stock_criteria
end

def display_name
deprecated? ? "#{name} (Deprecated #{deprecated_at.to_formatted_s(:iso8601)})" : name
deprecated? ? "#{name} (Deprecated #{deprecated_at.to_fs(:iso8601)})" : name
end
end
2 changes: 1 addition & 1 deletion app/models/qc_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def identifier_required?
def generate_report_identifier
return true if study.nil? || product_criteria.nil?

rid = [study.abbreviation, product_criteria.product.name, DateTime.now.to_formatted_s(:number)].compact
rid = [study.abbreviation, product_criteria.product.name, DateTime.now.to_fs(:number)].compact
.join('_')
.downcase
.gsub(/[^\w]/, '_')
Expand Down
2 changes: 1 addition & 1 deletion app/models/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def date_for_state(state)
# cf. RequestType which defines how it will be fulfilled.
# Both RequestType and Request have a purpose, with the former acting as the default for
# the latter.
enum request_purpose: { standard: 1, internal: 2, qc: 3, control: 4 }
enum :request_purpose, { standard: 1, internal: 2, qc: 3, control: 4 }

# Validations
# On create we perform a full and complete validation.
Expand Down
Loading
Loading