Skip to content

BazaRb#balance treats malformed response bodies as zero #494

Description

@gemshrine

BazaRb#balance converts the response body with String#to_f without checking whether the response is numeric. Ruby turns a nonnumeric or empty string into 0.0, so a malformed HTTP 200 response is indistinguishable from a real zero balance.

Steps to reproduce:

  1. Have GET /account/balance return HTTP 200 with not-a-balance.
  2. Call BazaRb#balance.

Actual result: the method returns 0.0.

Expected result: it should reject an empty or nonnumeric response body instead of returning a valid-looking zero balance.

The unchecked conversion is in lib/baza-rb.rb, in BazaRb#balance. This is separate from the malformed job ID and exit-code responses covered by #458.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions