Bug 1333084 - API - PUT method for applying errata to hosts does not validate values
Summary: API - PUT method for applying errata to hosts does not validate values
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Kavita
QA Contact: Roman Plevka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-04 15:38 UTC by Roman Plevka
Modified: 2018-09-04 17:46 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-09-04 17:46:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 18744 0 Normal Resolved API - PUT method for applying errata to hosts does not validate values 2020-08-30 19:05:59 UTC

Description Roman Plevka 2016-05-04 15:38:56 UTC
Description of problem:
there seems to be no input validation for parameters provided to /api/hosts/<host>/errata/apply (specifically errata_ids parameter):

<pre>
$ curl -k -u admin:changeme -X PUT -H 'Content-Type: application/json' -d '{"errata_ids": []}' https://sat6.server.com/api/v2/hosts/12977/errata/apply
{"displayMessage":"undefined method `-' for nil:NilClass","errors":["undefined method `-' for nil:NilClass"]}

$ curl -k -u admin:changeme -X PUT -H 'Content-Type: application/json' -d '{"errata_ids": 1}' https://sat6.server.com/api/v2/hosts/12977/errata/apply
{"displayMessage":"ERROR:  operator does not exist: character varying = integer\nLINE 1: ...ROM \"katello_errata\"  WHERE \"katello_errata\".\"errata_id\" = 1\n                                                                    ^\nHINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.\n","errors":["ERROR:  operator does not exist: character varying = integer\nLINE 1: ...ROM \"katello_errata\"  WHERE \"katello_errata\".\"errata_id\" = 1\n                                                                    ^\nHINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.\n"]}
</pre>



Version-Release number of selected component (if applicable):
6.2.0 Beta

How reproducible:
always

Steps to Reproduce:
1. get some hosts registered to your satellite
2. send out one of the PUT HTTP requests (as stated above)

Actual results:
no input validation happens on the parameters, so the code uses any input and crashes with it (wrong or null type, etc.)

Expected results:
validation takes place and raise proper exception if the input is invalid, user receives properly formatted error message in the JSON response.

Additional info:

Comment 2 Brad Buckingham 2016-06-06 19:51:25 UTC
Note: this bug is similar to bug 1222127 which requests a similar validation for host-collections.

Comment 4 Ondřej Pražák 2017-03-01 10:44:25 UTC
Created redmine issue http://projects.theforeman.org/issues/18744 from this bug

Comment 5 Satellite Program 2017-03-05 17:08:27 UTC
Upstream bug assigned to kgaikwad

Comment 6 Bryan Kearney 2018-09-04 17:46:00 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.


Note You need to log in before you can comment on or make changes to this bug.