Skip to content

Commit

Permalink
Merge pull request #3330 from dependabot/brrygrdn/native-helpers-vali…
Browse files Browse the repository at this point in the history
…date-bundler-version

Avoid subtle runtime failures by raising if a native helper is invoked with the wrong bundler version
  • Loading branch information
brrygrdn authored Mar 23, 2021
2 parents 7dc92fd + d6616a5 commit 38a739f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bundler/helpers/v1/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@

require "functions"

MAX_BUNDLER_VERSION="2.0.0"

def validate_bundler_version!
return true if correct_bundler_version?

raise StandardError, "Called with Bundler '#{Bundler::VERSION}', expected < '#{MAX_BUNDLER_VERSION}'"
end

def correct_bundler_version?
Gem::Version.new(Bundler::VERSION) < Gem::Version.new(MAX_BUNDLER_VERSION)
end

def output(obj)
print JSON.dump(obj)
end

begin
validate_bundler_version!

request = JSON.parse($stdin.read)

function = request["function"]
Expand Down
14 changes: 14 additions & 0 deletions bundler/helpers/v2/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@

require "functions"

MIN_BUNDLER_VERSION = "2.0.0"

def validate_bundler_version!
return true if correct_bundler_version?

raise StandardError, "Called with Bundler '#{Bundler::VERSION}', expected >= '#{MIN_BUNDLER_VERSION}'"
end

def correct_bundler_version?
Gem::Version.new(Bundler::VERSION) >= Gem::Version.new(MIN_BUNDLER_VERSION)
end

def output(obj)
print JSON.dump(obj)
end

begin
validate_bundler_version!

request = JSON.parse($stdin.read)

function = request["function"]
Expand Down

0 comments on commit 38a739f

Please sign in to comment.