Bug 1333084

Summary: API - PUT method for applying errata to hosts does not validate values
Product: Red Hat Satellite Reporter: Roman Plevka <rplevka>
Component: APIAssignee: Kavita <kgaikwad>
Status: CLOSED WONTFIX QA Contact: Roman Plevka <rplevka>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: erinn.looneytriggs, kgaikwad, oprazak
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-04 17:46:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.