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 1283933 - WebUI - scoped search raises PGError on feeding a non-integer value for a integer field
Summary: WebUI - scoped search raises PGError on feeding a non-integer value for a int...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Search
Version: Nightly
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: 6.4.0
Assignee: Kavita
QA Contact: Roman Plevka
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-20 10:24 UTC by Roman Plevka
Modified: 2020-12-11 11:58 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-16 18:57:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 12547 0 None None None 2016-04-22 15:40:42 UTC

Description Roman Plevka 2015-11-20 10:24:42 UTC
Description of problem:
while performing a search on any Foreman entity, there is an error raised on filtering integer-based attributes with non-integer values:

This error exposes a SQL query:

Warning!
PGError: ERROR: invalid input syntax for integer: "not_an_int" LINE 1: ... WHERE (("operatingsystems"."hostgroups_count" <= 'not_an_int')) ORDE... ^ : SELECT "operatingsystems".* FROM "operatingsystems" WHERE (("operatingsystems"."hostgroups_count" <= 'not_an_int')) ORDER BY title LIMIT 20 OFFSET 0

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

# rpm -qa katello
katello-2.4.0-6.nightly.el7.noarch
# rpm -qa foreman*
foreman-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-proxy-1.11.0-0.develop.201511161424gitf24be74.el7.noarch
foreman-release-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-libvirt-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-release-scl-1-1.el7.x86_64
foreman-ovirt-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-postgresql-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-selinux-1.11.0-0.develop.201510071426git6234447.el7.noarch
foreman-debug-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-compute-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-gce-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch
foreman-vmware-1.11.0-0.develop.201511181617git2fc4d6d.el7.noarch

How reproducible:
every time

Steps to Reproduce:
1. login to webui
2. go to any foreman entity summary page (e.g. architectures, operating systems,..)
3. type in a query based on an integer-based attribute (e.g.  hosts_count) and provide a non-integer value (e.g. hosts_count = 'foo')

Actual results:
PGError warning

Expected results:
Although it is alright for the query to fail, the input should be validated before passed to the actual SQL query (perhaps a sql injection might be possible?).
The neat solution might be to display an error notification as a popup, so user doesn't need to leave the search page every time he makes an error in the search query


Additional info:
no SQL tables were harmed during producing this BZ.

Comment 1 Roman Plevka 2015-11-20 10:27:21 UTC
Created redmine issue http://projects.theforeman.org/issues/12547 from this bug

Comment 2 Bryan Kearney 2015-11-20 11:02:46 UTC
Upstream bug component is Provisioning

Comment 3 Roman Plevka 2016-01-08 12:25:47 UTC
The error is present on Katello instances as well (scoped search) -
All that is needed to reproduce the issue is to put a large number into search box for a model that contains any integer-based fields.
The scoped search then queries each field and crashes on the integer one.

related to: BZ#1252046

Comment 4 Bryan Kearney 2016-07-26 19:09:52 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 5 Bryan Kearney 2016-08-10 19:11:15 UTC
Upstream bug component is Search

Comment 6 Bryan Kearney 2016-08-10 20:12:18 UTC
Upstream bug component is Provisioning

Comment 7 Bryan Kearney 2016-08-10 22:11:59 UTC
Upstream bug component is Search

Comment 8 Shimon Shtein 2016-10-13 13:30:23 UTC
Update: This waits for a fix in scoped_search gem. Once the fix is there, we can add a PR to foreman with proper validation.

Comment 9 Shimon Shtein 2016-12-14 12:28:37 UTC
It will require moving to scoped_search 4.0 I am not sure it will get to 6.2

Comment 16 Satellite Program 2017-09-11 20:15:20 UTC
Upstream bug assigned to kgaikwad

Comment 22 Roman Plevka 2018-05-30 13:35:09 UTC
VERIFIED
on sat6.4.0-5

$ curl -sku admin:changeme "https://sat640.com/katello/api/v2/repositories?enabled=true&library=true&organization_id=1&page=1&paged=true&per_page=20&product_id=303&search=02835944670070534073007027150547768990625906784325107068940431181405948459994084618692975345435345345"
{"total":1,"subtotal":0,"page":"1","per_page":"20","error":null,"search":"02835944670070534073007027150547768990625906784325107068940431181405948459994084618692975345435345345","sort":{"by":"name","order":"asc"},"results":[]}

Comment 23 Bryan Kearney 2018-10-16 18:57:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927


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