Skip to content

Commit

Permalink
Validate the JSON data in load
Browse files Browse the repository at this point in the history
Check to make sure that the loaded JSON actually contains data in the keys we are going to use before we use them, to avoid runtime exceptions on Nil.
  • Loading branch information
ashleym1972 authored Jun 29, 2017
1 parent 16fbd3d commit cc4c70d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/u2f/register_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def self.load_from_json(json)
raise RegistrationError, code: data['errorCode']
end

if data['clientData'].blank? || data['registrationData'].blank?
raise RegistrationError, code: 2
end

instance = new
instance.client_data_json =
::U2F.urlsafe_decode64(data['clientData'])
Expand Down

0 comments on commit cc4c70d

Please sign in to comment.