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

Sales endpoint should return empty array when provided an invalid payment ID #6823

Open
cklosowski opened this issue Aug 2, 2018 · 0 comments

Comments

@cklosowski
Copy link
Contributor

See: https://github.com/easydigitaldownloads/EDD-Software-Licensing/issues/1411

Bug Report

Expected behavior

When attempting to retrieve a sale by id via the EDD REST API, and the provided id does not exist, the response should be an empty sales record, e.g.

GET /edd-api/sales/?id=1&key=xxx&token=yyy

{
  "sales"=> [
    {}
  ],
  "request_speed"=>0.005464792251586914
}

Actual behavior

When attempting to retrieve a sale by id via the EDD REST API, and the provided id does not exist, the response is an empty sales record, e.g.

The get sales by id is probably expected to be a low-intensity request, and too many clients hitting the "get sales" endpoint with an id that doesn't exist can result in an inadvertent DOS attack against a large site.

GET /edd-api/sales/?id=1&key=xxx&token=yyy

{
  "sales"=> [
    {
      "ID"=>"",
      "transaction_id"=>nil,
      "key"=>"",
      "subtotal"=>0,
      "tax"=>0,
      "fees"=>nil,
      "total"=>0,
      "gateway"=>"",
      "email"=>"",
      "date"=>"",
      "discounts"=>nil,
      "products"=>[],
  ],
  "request_speed"=>30.093647003173828
}

Steps to reproduce the behavior

Perform a request to the REST API sales endpoint with an id that does exist, e.g.: GET /edd-api/sales/?id=1&key=xxx&token=yyy.

The response will include an empty sales record,

Proposed Fix

The most conservative fix would seem to be we should return an empty set of sales, instead of an empty sales object.

Information:

EDD Version (or branch): master
WordPress Version: All

@cklosowski cklosowski added this to the 3.0 milestone Aug 2, 2018
@cklosowski cklosowski self-assigned this Aug 2, 2018
@pippinsplugins pippinsplugins modified the milestones: 3.0, 3.1 Aug 27, 2018
@cklosowski cklosowski removed this from the 3.1 milestone Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants