File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -44,5 +44,5 @@ Style/StringLiterals:
4444Style/TrailingCommaInArguments :
4545 EnforcedStyleForMultiline : comma
4646
47- Style/TrailingCommaInLiteral :
47+ Style/TrailingCommaInArrayLiteral :
4848 EnforcedStyleForMultiline : comma
Original file line number Diff line number Diff line change 1- require "omniauth-oauth2/version" # rubocop:disable FileName
1+ require "omniauth-oauth2/version"
22require "omniauth/strategies/oauth2"
Original file line number Diff line number Diff line change @@ -106,14 +106,14 @@ def options_for(option)
106106 end
107107
108108 # constant-time comparison algorithm to prevent timing attacks
109- def secure_compare ( a , b )
110- return false unless a . bytesize == b . bytesize
109+ def secure_compare ( string_a , string_b )
110+ return false unless string_a . bytesize == string_b . bytesize
111111
112- l = a . unpack "C#{ a . bytesize } "
112+ l = string_a . unpack "C#{ string_a . bytesize } "
113113
114114 res = 0
115- b . each_byte { |byte | res |= byte ^ l . shift }
116- res == 0
115+ string_b . each_byte { |byte | res |= byte ^ l . shift }
116+ res . zero?
117117 end
118118
119119 # An error that is indicated in the OAuth 2.0 callback.
Original file line number Diff line number Diff line change @@ -87,6 +87,16 @@ def app
8787 instance . callback_phase
8888 end
8989 end
90+
91+ describe "#secure_params" do
92+ subject { fresh_strategy }
93+
94+ it "returns true when the two inputs are the same and false otherwise" do
95+ instance = subject . new ( "abc" , "def" )
96+ expect ( instance . send ( :secure_compare , "a" , "a" ) ) . to be true
97+ expect ( instance . send ( :secure_compare , "b" , "a" ) ) . to be false
98+ end
99+ end
90100end
91101
92102describe OmniAuth ::Strategies ::OAuth2 ::CallbackError do
You can’t perform that action at this time.
0 commit comments