Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

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.